edu.umd.cfar.lamp.viper.util.reader
Class VReader.TextLine

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.reader.VReader.TextLine
Enclosing class:
VReader

protected class VReader.TextLine
extends java.lang.Object

This class is used to represent a line of text or a sequence of lines connected by '\' characters. It supports various operations to treat lines and multilines in a consistent manner.


Constructor Summary
protected VReader.TextLine()
           
 
Method Summary
 boolean add(java.lang.String nextLine)
          Adds the next line to the current multiline, replacing it if the last one was done, appending to it if it wasn't, and returning true if it is now done.
 void clear()
          This clears the current multiline.
 boolean done()
          Returns true if the current line does not end in a continuation.
 boolean empty()
          Returns true if the current line contains no data.
 int getColumn(int offset)
          This returns what column in a multiline the specified character would be found.
 int getLineNum()
          Returns the line number of this line or the last line if this is a multiline.
 int getLineNum(int start)
          This finds the line number of a specific character.
 void insert(java.lang.String prefix)
          This appends a string to the beginning of the current line.
 java.lang.String numbered()
          This returns the current multiline with the line number appended to the front.
 java.lang.String numbered(int start, int end)
          This prints out only the lines containing character offsets between start and end, inclusive, using the same format as numbered().
 void setLineNum(int lineNumber)
          Set the current line number.
 boolean startsWith(java.lang.String prefix)
          Equivalent to toString.startsWith, but faster on lines that are not finished.
 java.lang.String toString()
          Returns the String representation of the current line or mutliline as one whole line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VReader.TextLine

protected VReader.TextLine()
Method Detail

insert

public void insert(java.lang.String prefix)
This appends a string to the beginning of the current line. Useful for commenting things out, and in general prefixing lines.

Parameters:
prefix - the string to insert onto the current line.

numbered

public java.lang.String numbered()
This returns the current multiline with the line number appended to the front. If it is more than two lines, it will put ". . ." between the first and last lines. The format is " 1234567. " + line.

Returns:
The line with the line number before it, and split, like jikes.

numbered

public java.lang.String numbered(int start,
                                 int end)
This prints out only the lines containing character offsets between start and end, inclusive, using the same format as numbered().

Parameters:
start - The character offset of the beginning of the error.
end - The character offset of the end of the error.
Returns:
The current line marked up for locating the error, like jikes

empty

public boolean empty()
Returns true if the current line contains no data.

Returns:
true if the current line is empty.

setLineNum

public void setLineNum(int lineNumber)
Set the current line number. The first line is always 1, and counts up whenever a new line is added. Use this when starting deeper into a file, when going back, etc.

Parameters:
lineNumber - The new line number.

getColumn

public int getColumn(int offset)
This returns what column in a multiline the specified character would be found. Mutliline returns a sequence of connected lines as a single string, so this is necessary to know what actual column in the file a specific string started.

Parameters:
offset - the character
Returns:
the column of the offset into the multiline section

getLineNum

public int getLineNum()
Returns the line number of this line or the last line if this is a multiline.

Returns:
the last line of the multiline

getLineNum

public int getLineNum(int start)
This finds the line number of a specific character. This is useful for printing out errors and warnings.

Parameters:
start - the line number of the character in the multiline segment
Returns:
the line number

toString

public java.lang.String toString()
Returns the String representation of the current line or mutliline as one whole line.

Returns:

clear

public void clear()
This clears the current multiline. (empty will return true)


done

public boolean done()
Returns true if the current line does not end in a continuation.

Returns:
false if the current line continues

add

public boolean add(java.lang.String nextLine)
Adds the next line to the current multiline, replacing it if the last one was done, appending to it if it wasn't, and returning true if it is now done.

Parameters:
nextLine - puts the next line into the multiline
Returns:
isDone()

startsWith

public boolean startsWith(java.lang.String prefix)
Equivalent to toString.startsWith, but faster on lines that are not finished.

Parameters:
prefix - the prefix to check for
Returns:
toString().startsWith(prefix)