Package com.iizix.prop
Class SelectorExpression
java.lang.Object
com.iizix.prop.SelectorExpression
- Direct Known Subclasses:
EditorSelectorExpression
The Selector Expression Parser.
- Author:
- Christopher Mindus
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Reference class holding the string reference and its location in the expression.static enum
The token enumeration.static class
Tokens data class with token information, and positions (offsets) in the expression String.Field Summary
Modifier and TypeFieldDescriptionstatic final SelectorExpression.Reference[]
Empty Reference array.final String
The parsed expression.protected final ArrayList
<SelectorExpression.TokenData> The tokens.Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Evaluates an expression at specified index.getClassRefactoredExpression
(String oldClassName, String newClassName) Outputs the expression reformatted used for class refactoring.getError()
Gets the error.int
Gets the error position.Outputs the expression reformatted.Gets the selector and class references in the expression.void
getReferences
(HashSet<String> selectors, HashSet<String> classes) Gets the selector and class references in the expression.getSelectorRefactoredExpression
(String oldSelectorName, String newSelectorName) Outputs the expression reformatted used for Selector refactoring.boolean
isSelected
(Selector selector, EnvProps envProps) Called to resolve the SelectorExpression by custom Java code.boolean
isValidWordCharacter
(int ch) Checks for valid character in a word.static void
Command line.boolean
parse()
Parses the expression.
Field Details
EMPTY
Empty Reference array.expression
The parsed expression.tokens
The tokens.
Constructor Details
SelectorExpression
Creates the Expression String.There are four special sub expressions that are specified within brackets:
- { dev: "device" } device or OS selection,
- { lang: "language" } language selection,
- { sel: "selectorReference" } used to get the result of another selector (circular references not allowed),
- { wc: environmentVariable: "Wild*Card?String" } matches an environment variable,
- { regexp: environmentVariable: "RegularExpressionWithinQuotes" } matches an environment variable in a Regular Expression,
- { java: "javaClassName" } executes a Java class implementing the interface
ISelectorExpression
.
- Parameters:
expression
- The expression.
Method Details
isValidWordCharacter
public boolean isValidWordCharacter(int ch) Checks for valid character in a word.The word has the same syntax validity as
Atom
names, i.e. the characters :/\{}"'?*^,; are not allowed, but augmented with white space characters - \t \r \n and space.- Parameters:
ch
- The character to test.- Returns:
- true for valid character, false otherwise.
parse
public boolean parse()Parses the expression.- Returns:
- true for success, false if errors are present.
getErrorPosition
public int getErrorPosition()Gets the error position.- Returns:
- The error position or -1 for no error.
getError
Gets the error.- Returns:
- The error, or null for no error.
getExpression
Outputs the expression reformatted.If an error is present, the original expression is returned.
- Returns:
- The expression reformatted as a string.
getClassRefactoredExpression
Outputs the expression reformatted used for class refactoring.If an error is present, the original expression is returned.
- Parameters:
oldClassName
- The old class name.newClassName
- The new class name.- Returns:
- The expression reformatted as a string.
getSelectorRefactoredExpression
Outputs the expression reformatted used for Selector refactoring.If an error is present, the original expression is returned.
- Parameters:
oldSelectorName
- The old Selector name.newSelectorName
- The new Selector name.- Returns:
- The expression reformatted as a string.
getReferences
Gets the selector and class references in the expression.getReferences
Gets the selector and class references in the expression.isSelected
Called to resolve the SelectorExpression by custom Java code.- Parameters:
envProps
- The client environment properties to verify for environment.- Returns:
- true if the Selector is selected to be used, false otherwise.
eval
Evaluates an expression at specified index.- Parameters:
selector
- The selector.envProps
- The client environment properties to verify for environment.index
- The index in [0] processed.isDesigner
- If true, Java classes always return true and are not called.- Returns:
- Result from expression evaluation.
main
Command line.