com.springsource.util.parser.manifest.internal
Class SourceContext

java.lang.Object
  extended by 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

Field Summary
private  int[] linebreaks
           
private  java.lang.String theSource
           
 
Constructor Summary
SourceContext(java.lang.String theSource)
           
 
Method Summary
 int getColumn(int offset)
           
 int getEndColumn(ManifestProblem manifestParserProblemInstance)
           
 int getEndColumn(Token token)
           
 int getEndLine(Token token)
           
 int getLine(int offset)
           
 int getLine(ManifestProblem manifestParserProblemInstance)
           
 int getLine(Token token)
          Compute the line that the token is on, using the linebreak information and the tokens offset
 java.lang.String getLineAsString(int relevantLine)
           
 int[] getLinebreaks()
           
private  int getRelevantEndLinebreakEntry(int offset)
           
private  int getRelevantStartLinebreakEntry(int startoffset)
           
 int getStartColumn(ManifestProblem manifestParserProblemInstance)
           
 int getStartColumn(Token token)
           
 void setLinebreaks(java.util.List<java.lang.Integer> linebreaks)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

linebreaks

private int[] linebreaks

theSource

private java.lang.String theSource
Constructor Detail

SourceContext

public SourceContext(java.lang.String theSource)
Method Detail

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)