Package io.pebbletemplates.pebble.lexer
Class TemplateSource
java.lang.Object
io.pebbletemplates.pebble.lexer.TemplateSource
- All Implemented Interfaces:
CharSequence
An implementation of CharSequence that is tuned to be used specifically by
LexerImpl. It
is possible to advance through the sequence without allocating a copy and it is possible to
perform regex matches from the logical beginning of the remaining un-tokenized source. This class
will also standardize newline characters from different architectures.- Author:
- mbosecke
-
Constructor Details
-
TemplateSource
Constructor- Parameters:
reader- Reader provided by the Loaderfilename- Filename of the template- Throws:
IOException- Exceptions thrown from the reader
-
-
Method Details
-
advance
public void advance(int amount) Moves the start index a certain amount. While traversing this amount we will count how many newlines have been encountered.- Parameters:
amount- Amount of characters to advance by
-
advanceThroughWhitespace
public void advanceThroughWhitespace() -
substring
-
substring
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
getLineNumber
public int getLineNumber() -
getFilename
-