Fork me on GitHub

TemplateSource

In package com.mitchellbosecke.pebble.lexer

public class TemplateSource extends Object implements CharSequence

An implementation of CharSequence that is tuned to be used specifically by {@link 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.

Constructors

public TemplateSource(Reader reader, String filename)

Constructor

Parameters:
  • Reader reader

    Reader provided by the Loader

  • String filename

    Filename of the template

Methods

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:
  • int amount

    Amount of characters to advance by

public void advanceThroughWhitespace()
Parameters:
  • No parameters
public String substring(int start, int end)
Parameters:
  • int start
  • int end
public String substring(int end)
Parameters:
  • int end
public int length()
Parameters:
  • No parameters
public char charAt(int index)
Parameters:
  • int index
public CharSequence subSequence(int start, int end)
Parameters:
  • int start
  • int end
public String toString()
Parameters:
  • No parameters
public int getLineNumber()
Parameters:
  • No parameters
public String getFilename()
Parameters:
  • No parameters