org.jproggy.snippetory.engine
Class Token

java.lang.Object
  extended by org.jproggy.snippetory.engine.Token

public class Token
extends Object

A token is a portion of the template that fulfills a special purpose, view from the perspective of a syntax to parse this Snippetory template. As Snippetory works with a simple syntax scheme there's only a small number of different purposes such a token can fulfill. They are defined in the enum Token.TokenType.
A token consists of the portion of template code it represents, the start position of this code, the token type and some data that's depends on token type.


Nested Class Summary
static class Token.TokenType
          The token type classifies he meaning of a template element.
 
Constructor Summary
Token(String name, String content, Token.TokenType type, int position)
           
 
Method Summary
 LinkedHashMap<String,String> getAttributes()
          attributes are only provided for Token.TokenType.BlockStart and
 String getContent()
          The complete piece of template code representing this token.
 String getName()
          Not every TokenType has a name in any case.
 int getPosition()
          the position where the content starts within the entire template data.
 Token.TokenType getType()
          The token type categorizes different meanings of the elements represented by the tokens.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Token

public Token(String name,
             String content,
             Token.TokenType type,
             int position)
Method Detail

getAttributes

public LinkedHashMap<String,String> getAttributes()
attributes are only provided for Token.TokenType.BlockStart and


getName

public String getName()
Not every TokenType has a name in any case. For instance the name of a field is optional and comment has no name at all

Returns:
the name of the element represented by this token or null or empty string if none.

getType

public Token.TokenType getType()
The token type categorizes different meanings of the elements represented by the tokens.

Returns:
the token type recognized for the represented element

getContent

public String getContent()
The complete piece of template code representing this token. This can be used to re-assemble the original template from a token stream


getPosition

public int getPosition()
the position where the content starts within the entire template data. It dosen't matter where this syntax started to be used.