Module de.cuioss.java.tools
Class Lexer<T extends FormatterSupport>
java.lang.Object
de.cuioss.tools.formatting.template.lexer.Lexer<T>
- Type Parameters:
T- bounds lexer to one type to avoid cross using accidentally
- All Implemented Interfaces:
Serializable
Functionality of scanning plain text and split this to tokens
- Author:
- Eugen Fischer
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSupported expression language -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionParse template into Token List according attribute listprotected static final voidthrowUnsupportedTokenException(String wrongToken, List<String> allowedTokens) Throw IllegalArgumentException with information about wrong token and supported tokensfinal voidvalidateTemplate(String input) Validate template by scan this
-
Constructor Details
-
Lexer
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 Details
-
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
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
Validate template by scan this- Parameters:
input- to be validated
-