com.vladium.jcd.cls.attribute
Class LineNumberTableAttribute_info

java.lang.Object
  extended by com.vladium.jcd.cls.attribute.Attribute_info
      extended by com.vladium.jcd.cls.attribute.LineNumberTableAttribute_info
All Implemented Interfaces:
IClassFormatOutput, java.lang.Cloneable

public final class LineNumberTableAttribute_info
extends Attribute_info

The LineNumberTable attribute is an optional variable-length attribute in the attributes table of a CodeAttribute_info attribute. It may be used by debuggers to determine which part of the JVM code array corresponds to a given line number in the original source file. If LineNumberTable attributes are present in the attributes table of a given Code attribute, then they may appear in any order. Furthermore, multiple LineNumberTable attributes may together represent a given line of a source file; that is, LineNumberTable attributes need not be one-to-one with source lines.

The LineNumberTable attribute has the following format:

 LineNumberTable_attribute {
          u2 attribute_name_index;
          u4 attribute_length;
          u2 line_number_table_length;
          {  u2 start_pc;             
             u2 line_number;             
          } line_number_table[line_number_table_length];
  }
 
 
 LineNumberTable_attribute structure contains the following items:
 
    line_number_table_length
 
The value of the line_number_table_length item indicates the number of entries in the line_number_table array.
    line_number_table[]
 
Each entry in the line_number_table array indicates that the line number in the original source file changes at a given point in the code array.

Each line_number_table entry must contain the following two items:

    start_pc
 
The value of the start_pc item must indicate the index into the code array at which the code for a new line in the original source file begins. The value of start_pc must be less than the value of the code_length item of the CodeAttribute_info attribute of which this LineNumberTable is an attribute.

    line_number
 
The value of the line_number item must give the corresponding line number in the original source file.

Author:
Vlad Roubtsov, (C) 2003

Field Summary
private  java.util.List m_lines
           
 
Fields inherited from class com.vladium.jcd.cls.attribute.Attribute_info
ATTRIBUTE_BRIDGE, ATTRIBUTE_CODE, ATTRIBUTE_CONSTANT_VALUE, ATTRIBUTE_EXCEPTIONS, ATTRIBUTE_INNERCLASSES, ATTRIBUTE_LINE_NUMBER_TABLE, ATTRIBUTE_SOURCEFILE, ATTRIBUTE_SYNTHETIC, m_attribute_length, m_name_index
 
Constructor Summary
LineNumberTableAttribute_info(int attribute_name_index, long attribute_length, UDataInputStream bytes)
           
 
Method Summary
 void accept(IAttributeVisitor visitor, java.lang.Object ctx)
           
 java.lang.Object clone()
          Performs a deep copy.
 LineNumber_info get(int offset)
          Returns LineNumber_info descriptor at a given offset.
 long length()
          Returns the total length of this attribute when converted to .class format [including the 6-byte header]
 int size()
          Returns the number of descriptors in this collection [can be 0].
 java.lang.String toString()
           
 void writeInClassFormat(UDataOutputStream out)
           
 
Methods inherited from class com.vladium.jcd.cls.attribute.Attribute_info
getName, new_Attribute_info
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_lines

private java.util.List m_lines
Constructor Detail

LineNumberTableAttribute_info

LineNumberTableAttribute_info(int attribute_name_index,
                              long attribute_length,
                              UDataInputStream bytes)
                        throws java.io.IOException
Throws:
java.io.IOException
Method Detail

get

public LineNumber_info get(int offset)
Returns LineNumber_info descriptor at a given offset.

Parameters:
offset - line number entry offset [must be in [0, size()) range; input not checked]
Returns:
LineNumber_info descriptor [never null]
Throws:
java.lang.IndexOutOfBoundsException - if 'offset' is outside of valid range

size

public int size()
Returns the number of descriptors in this collection [can be 0].


length

public long length()
Description copied from class: Attribute_info
Returns the total length of this attribute when converted to .class format [including the 6-byte header]

Specified by:
length in class Attribute_info

accept

public void accept(IAttributeVisitor visitor,
                   java.lang.Object ctx)
Specified by:
accept in class Attribute_info

toString

public java.lang.String toString()
Specified by:
toString in class Attribute_info

clone

public java.lang.Object clone()
Performs a deep copy.

Overrides:
clone in class Attribute_info

writeInClassFormat

public void writeInClassFormat(UDataOutputStream out)
                        throws java.io.IOException
Specified by:
writeInClassFormat in interface IClassFormatOutput
Overrides:
writeInClassFormat in class Attribute_info
Throws:
java.io.IOException