Class Lexer<T extends FormatterSupport>
- java.lang.Object
-
- io.cui.tools.formatting.template.lexer.Lexer<T>
-
- Type Parameters:
T- bounds lexer to one type to avoid cross using accidentally
- All Implemented Interfaces:
Serializable
public abstract class Lexer<T extends FormatterSupport> extends Object implements Serializable
Functionality of scanning plain text and split this to tokens- Author:
- Eugen Fischer
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLexer.ExpressionLanguageSupported expression language
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)protected List<String>getTokenList()inthashCode()abstract List<Token>scan(String input)Parse template into Token List according attribute listprotected static voidthrowUnsupportedTokenException(String wrongToken, List<String> allowedTokens)Throw IllegalArgumentException with information about wrong token and supported tokensStringtoString()voidvalidateTemplate(String input)Validate template by scan this
-
-
-
Constructor Detail
-
Lexer
protected Lexer(T source)
Constructor of Lexer. Source provide information of "tokens" which he supports. ThereforeFormatterSupport.getSupportedPropertyNames()will be used.- Parameters:
source- must not be null- Throws:
NullPointerException- if source is missingIllegalArgumentException- if attribute is null or empty
-
-
Method Detail
-
throwUnsupportedTokenException
protected static final void throwUnsupportedTokenException(String wrongToken, List<String> allowedTokens)
Throw IllegalArgumentException with information about wrong token and supported tokens- Parameters:
wrongToken- must not be nullallowedTokens- must not be null
-
scan
public abstract List<Token> scan(String input)
Parse template into Token List according attribute list- Parameters:
input- template string- Returns:
- created list of token, list could be empty if input template is null or empty
- Throws:
IllegalArgumentException- if template include unknown token, or doesn't fit the rules
-
validateTemplate
public final void validateTemplate(String input)
Validate template by scan this- Parameters:
input- to be validated
-
getTokenList
protected List<String> getTokenList()
-
-