com.veromodo.tempo.util
Class Extent

java.lang.Object
  extended by com.veromodo.tempo.util.Extent

public class Extent
extends java.lang.Object

An Extent describes the location of a sequence of input bytes. The sequence is contained in a single file. It is determined by the offset and length of the sequence in its file.

An Extent is immutable.

Author:
L. Michel, S. Garland

Field Summary
static Extent UNKNOWN
          UNKNOWN is used to encode the absence of extent.
 
Constructor Summary
Extent(Extent e1, Extent e2)
          Constructs an Extent that spans two other Extents.
Extent(int line, int col, int offset, int length)
          Constructs an Extent with an empty file name.
Extent(java.lang.String fileName, int line, int col, int offset, int length)
          Constructs an Extent for bytes on a single line of text.
Extent(antlr.Token t)
          Constructs the Extent for an input token.
Extent(antlr.Token t1, antlr.Token t2)
          Constructs an Extent that spans the region between (and including) two tokens.
 
Method Summary
 void dump(java.lang.String label)
          Produces a human readable print out on the standard output.
 int endCol()
           
 int endLine()
           
 int endOffset()
           
 java.lang.String fileName()
           
 int length()
           
 java.lang.String report()
          Accessor
 int startCol()
           
 int startLine()
           
 int startOffset()
          Accessor.
 java.lang.String toString()
          Accessor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final Extent UNKNOWN
UNKNOWN is used to encode the absence of extent.

Constructor Detail

Extent

public Extent(int line,
              int col,
              int offset,
              int length)
Constructs an Extent with an empty file name.

Parameters:
line - the start line
col - the starting column
offset - the starting byte offset in the source file (assuming ASCII encoding)
length - the length of the extent (in bytes/characters -- assuming ASCII encoding)
See Also:
Extent(String, int, int, int, int)

Extent

public Extent(java.lang.String fileName,
              int line,
              int col,
              int offset,
              int length)
Constructs an Extent for bytes on a single line of text.

Parameters:
fileName - name of file containing the Extent
line - line number for the bytes in the Extent
col - column number for the first byte in the Extent
offset - byte offest of the first byte in the Extent
length - number of bytes in the Extent

Extent

public Extent(Extent e1,
              Extent e2)
Constructs an Extent that spans two other Extents. This is a union operation based on actual byte offsets. The implementation does not require any ordering for the two extents The resulting extent will start on the first symbol of the "smallest" extent and end on the last symbol for the "largest" extent.

Parameters:
e1 - the first extent
e2 - the second extent TODO Find and fix bug that miscomputes the Extent for a TIOA state definition.

Extent

public Extent(antlr.Token t)
Constructs the Extent for an input token.

Parameters:
t - a token from an input stream. The extent will span that token.

Extent

public Extent(antlr.Token t1,
              antlr.Token t2)
Constructs an Extent that spans the region between (and including) two tokens. Requires that the two tokens come from the same file and that the first occurs before the second.

Parameters:
t1 - the start token
t2 - the last token The routine expects t1 to precede t2. It will cause an assertion failure if the two tokens do not come from the same stream.
Method Detail

dump

public void dump(java.lang.String label)
Produces a human readable print out on the standard output. Debugging purposes.

Parameters:
label -

startOffset

public int startOffset()
Accessor.

Returns:
Retrieves the offset of the start of the extent

startLine

public int startLine()

endOffset

public int endOffset()

endLine

public int endLine()

startCol

public int startCol()

endCol

public int endCol()

length

public int length()

fileName

public java.lang.String fileName()

report

public java.lang.String report()
Accessor

Returns:
a string that holds a human-readable print out of the start of the extent

toString

public java.lang.String toString()
Accessor

Overrides:
toString in class java.lang.Object