com.springsource.util.parser.manifest.internal
Class SourceContext
java.lang.Object
com.springsource.util.parser.manifest.internal.SourceContext
public class SourceContext
- extends java.lang.Object
SourceContext captures information about the data being processed by the
lexer and parser. This information can be used to provide more accurate
informational or error messages. Internally it has a copy of the original
source and where the linebreaks are within it.
Concurrent Semantics
This class is thread safe.
- Author:
- Andy Clement
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
linebreaks
private int[] linebreaks
theSource
private java.lang.String theSource
SourceContext
public SourceContext(java.lang.String theSource)
setLinebreaks
public void setLinebreaks(java.util.List<java.lang.Integer> linebreaks)
getLinebreaks
public int[] getLinebreaks()
- Returns:
- the positions in the source data where the lines start.
getLine
public int getLine(Token token)
- Compute the line that the token is on, using the linebreak information
and the tokens offset
- Parameters:
token
- on the line
- Returns:
- the line number
getLine
public int getLine(int offset)
getLine
public int getLine(ManifestProblem manifestParserProblemInstance)
getEndLine
public int getEndLine(Token token)
getStartColumn
public int getStartColumn(Token token)
getStartColumn
public int getStartColumn(ManifestProblem manifestParserProblemInstance)
getColumn
public int getColumn(int offset)
getEndColumn
public int getEndColumn(Token token)
getEndColumn
public int getEndColumn(ManifestProblem manifestParserProblemInstance)
getRelevantStartLinebreakEntry
private int getRelevantStartLinebreakEntry(int startoffset)
getRelevantEndLinebreakEntry
private int getRelevantEndLinebreakEntry(int offset)
getLineAsString
public java.lang.String getLineAsString(int relevantLine)