org.apache.bcel.classfile

## Class LineNumber

- java.lang.Object
- - org.apache.bcel.classfile.LineNumber

- All Implemented Interfaces:
    Cloneable, Node

      public final class LineNumber
      extends Object
      implements Cloneable, Node

  This class represents a (PC offset, line number) pair, i.e., a line number in the source that corresponds to a relative address in the byte code. This is used for debugging purposes.
  See Also:
    `LineNumberTable`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LineNumber(int startPc, int lineNumber)`
    `LineNumber(LineNumber c)` Initialize from another object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `accept(Visitor v)` Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
    `LineNumber` | `copy()`
    `void` | `dump(DataOutputStream file)` Dump line number/pc pair to file stream in binary format.
    `int` | `getLineNumber()`
    `int` | `getStartPC()`
    `void` | `setLineNumber(int lineNumber)`
    `void` | `setStartPC(int startPc)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### LineNumber

          public LineNumber(int startPc,
                            int lineNumber)

      Parameters:
        `startPc` - Program Counter (PC) corresponds to
        `lineNumber` - line number in source file

    - #### LineNumber

          public LineNumber(LineNumber c)

      Initialize from another object.
      Parameters:
        `c` - the object to copy

  - ### Method Detail

    - #### accept

          public void accept(Visitor v)

      Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
      Specified by:
        `accept` in interface `Node`
      Parameters:
        `v` - Visitor object

    - #### copy

          public LineNumber copy()

      Returns:
        deep copy of this object

    - #### dump

          public void dump(DataOutputStream file)
                    throws IOException

      Dump line number/pc pair to file stream in binary format.
      Parameters:
        `file` - Output file stream
      Throws:
        `IOException` - if an I/O Exception occurs in writeShort

    - #### getLineNumber

          public int getLineNumber()

      Returns:
        Corresponding source line

    - #### getStartPC

          public int getStartPC()

      Returns:
        PC in code

    - #### setLineNumber

          public void setLineNumber(int lineNumber)

      Parameters:
        `lineNumber` - the source line number

    - #### setStartPC

          public void setStartPC(int startPc)

      Parameters:
        `startPc` - the pc for this line number

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`
      Returns:
        String representation

Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.