com.springsource.util.osgi.manifest.parse.standard
Class SourceContext

java.lang.Object
  extended by com.springsource.util.osgi.manifest.parse.standard.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.

The header parser actually doesn't benefit from this class knowing about linebreaks because all data is on one line. But for the general Manifest parser where data is split across multiple lines, it is very useful. Concurrent Semantics
Threadsafe.

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 getLine(int offset)
           
 java.lang.String getLineAsString(int relevantLine)
           
 int[] getLinebreaks()
           
private  int getRelevantStartLinebreakEntry(int startoffset)
           
 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(int offset)

getColumn

public int getColumn(int offset)

getRelevantStartLinebreakEntry

private int getRelevantStartLinebreakEntry(int startoffset)

getLineAsString

public java.lang.String getLineAsString(int relevantLine)