public abstract class BaseOperator<F extends Filter> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String[] |
f_asAlias
An array of optional aliases for this operator.
|
protected boolean |
f_fConditional
Flag indicating whether this operator can be used as a conditional operator,
for example ==, >=, etc, as opposed to a non-conditional operator such as +, -, etc.
|
protected String |
f_sSymbol
The symbol for this operator.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BaseOperator(String sSymbol,
boolean fConditional,
String... asAlias)
Create an instance of a BaseOperator with the specified
symbol, conditional flag and aliases.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAliases(TokenTable tokenTable)
Add any aliases of this operator to the specified token table.
|
abstract void |
addToTokenTable(TokenTable tokenTable)
Add this operator to the given
TokenTable. |
String[] |
getAliases()
Return the alternative symbols to use in CohQL that represent this operator.
|
String |
getSymbol()
Return the symbol to use in CohQL that represents this operator.
|
boolean |
isConditional()
Return true if this operator can be used as a conditional operator.
|
ValueExtractor |
makeExtractor(Object oLeft,
Object oRight)
Create a
ValueExtractor for this BaseOperator using the
specified left and right values. |
ValueExtractor |
makeExtractor(Term termLeft,
Term termRight,
TermWalker walker)
|
F |
makeFilter(Object oLeft,
Object oRight)
Create a
Filter for this BaseOperator using the
specified left and right values. |
F |
makeFilter(Term termLeft,
Term termRight,
TermWalker walker)
|
String |
toString() |
protected static Set |
unmodifiableSet(Object oValue)
Return an immutable Set accounting for the provided object being an array,
a Collection or a single item in the returned Set.
|
protected final String f_sSymbol
protected final String[] f_asAlias
protected final boolean f_fConditional
protected BaseOperator(String sSymbol, boolean fConditional, String... asAlias)
sSymbol - the symbol for this operatorfConditional - a flag indicating whether this operator is conditionalasAlias - an optional list of aliases for this operatorpublic String getSymbol()
public String[] getAliases()
public F makeFilter(Term termLeft, Term termRight, TermWalker walker)
Filter for this BaseOperator using the
specified left and right Terms.
Note: This method should be thread safe as operators are stored in a static map so may be called by multiple threads.
termLeft - the left term to use to build a FiltertermRight - the right term to use to build a Filterwalker - the TermWalker to use to process the left and
right termspublic F makeFilter(Object oLeft, Object oRight)
Filter for this BaseOperator using the
specified left and right values.
Note: This method should be thread safe as operators are stored in a static map so may be called by multiple threads.
oLeft - the left value to use to build a FilteroRight - the right value to use to build a Filterpublic ValueExtractor makeExtractor(Term termLeft, Term termRight, TermWalker walker)
ValueExtractor for this BaseOperator using the
specified left and right Terms.
Note: This method should be thread safe as operators are stored in a static map so may be called by multiple threads.
termLeft - the left term to use to build a ValueExtractortermRight - the right term to use to build a ValueExtractorwalker - the TermWalker to use to process the left and
right termspublic ValueExtractor makeExtractor(Object oLeft, Object oRight)
ValueExtractor for this BaseOperator using the
specified left and right values.
Note: This method should be thread safe as operators are stored in a static map so may be called by multiple threads.
oLeft - the left value to use to build a ValueExtractoroRight - the right value to use to build a ValueExtractorpublic boolean isConditional()
public abstract void addToTokenTable(TokenTable tokenTable)
TokenTable.
This typically means adding this operator using its
symbol and also adding any aliases.tokenTable - the TokenTable to add this operator toprotected void addAliases(TokenTable tokenTable)
tokenTable - the token table to add aliases toprotected static Set unmodifiableSet(Object oValue)
oValue - either an object array, a collection or a single item to
be returned as a Set