Package com.tangosol.coherence.dslquery
Class FilterBuilder
- java.lang.Object
-
- com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
-
- com.tangosol.coherence.dslquery.FilterBuilder
-
- All Implemented Interfaces:
TermWalker
public class FilterBuilder extends com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
FilterBuilder is a visitor class that converts a given Abstract Syntax Tree into a Filter. The Filter can be a deep nesting of Filters.- Author:
- djl 2009.08.31, jk 2013.12.02
-
-
Field Summary
Fields Modifier and Type Field Description protected ParameterResolver
f_defaultNamedBindVars
The default named bind variables.protected List
f_listDefaultBindVars
The default indexed bind variables.protected String
m_sCacheName
The cache name this FilterBuilder is buildingFilter
s to query against.protected Term
m_term
The Term that is the AST that encodes the Filter to be made.
-
Constructor Summary
Constructors Constructor Description FilterBuilder()
Construct a new FilterBuilder.FilterBuilder(CoherenceQueryLanguage language)
Construct a new FilterBuilder.FilterBuilder(Term term)
Construct a new FilterBuilder that can construct a Filter from the given Term.FilterBuilder(Object[] aoBindVars)
Construct a new FilterBuilder with given binding environment.FilterBuilder(Object[] aoBindVars, Map mapNamedBindVars)
Construct a new FilterBuilder with given binding environment.FilterBuilder(List indexedBindVars, ParameterResolver namedBindVars, CoherenceQueryLanguage language)
Construct a new FilterBuilder with given default bind variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
acceptBinaryOperator(String sOperator, Term termLeft, Term termRight)
This method will take a Binary Operator and the left and rightTerm
s for the operator and result in the creation of aFilter
or aValueExtractor
.protected void
acceptIdentifier(String sIdentifier)
The receiver has classified an identifier node.protected void
acceptList(NodeTerm termList)
The receiver has classified a list node.protected void
acceptPath(NodeTerm term)
The receiver has classified a path node.protected void
acceptUnaryOperator(String sOperator, Term t)
The receiver has classified a unary operation node.ValueExtractor
makeExtractor(NodeTerm term)
Process the AST Tree using the given Term that represents getter.Filter
makeFilter()
Make a new Filter from the set AST.Filter
makeFilter(Term term)
Make a new Filter from the given AST.Filter
makeFilter(Term term, Object[] aoIndexedBindVars)
Make a new Filter from the given AST using given array for Bind vars.Filter
makeFilter(Term term, Object[] aoIndexedBindVars, Map mapNamedBindVars)
Make a new Filter from the given AST using the given bind variables.Filter
makeFilter(Term term, List listBindVars, ParameterResolver namedBindVars)
Make a new Filter from the given AST using the given bind variables.Filter
makeFilterForCache(String sCacheName, Term term, List indexedBindVars, ParameterResolver namedBindVars)
Make a new Filter from the given AST using given array for Bind vars.protected static ParameterList
newParameterListFromMap(Map<?,?> map)
Convert the givenMap
into aParameterList
.-
Methods inherited from class com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
acceptAtom, acceptCall, acceptIdentifierInternal, acceptKeyedBinding, acceptLiteral, acceptNode, acceptNumericBinding, acceptPathAsChainedExtractor, acceptTerm, append, buildExtractor, getResult, reflectiveMakeObject, setAlias, setExtendedLanguage, setResult, walk
-
-
-
-
Field Detail
-
m_term
protected Term m_term
The Term that is the AST that encodes the Filter to be made.
-
m_sCacheName
protected String m_sCacheName
The cache name this FilterBuilder is buildingFilter
s to query against.This is used by the
language's
ExtractorBuilder
to map attribute names to POF indices. A null cache name results in the use ofReflectionExtractor
s.
-
f_listDefaultBindVars
protected final List f_listDefaultBindVars
The default indexed bind variables.
-
f_defaultNamedBindVars
protected final ParameterResolver f_defaultNamedBindVars
The default named bind variables.
-
-
Constructor Detail
-
FilterBuilder
public FilterBuilder()
Construct a new FilterBuilder.
-
FilterBuilder
public FilterBuilder(CoherenceQueryLanguage language)
Construct a new FilterBuilder.- Parameters:
language
- theCoherenceQueryLanguage
instance to use
-
FilterBuilder
public FilterBuilder(Object[] aoBindVars)
Construct a new FilterBuilder with given binding environment.- Parameters:
aoBindVars
- an Object array of indexed bind variables
-
FilterBuilder
public FilterBuilder(Term term)
Construct a new FilterBuilder that can construct a Filter from the given Term.- Parameters:
term
- the Term to use in the construction of a filter
-
FilterBuilder
public FilterBuilder(Object[] aoBindVars, Map mapNamedBindVars)
Construct a new FilterBuilder with given binding environment.- Parameters:
aoBindVars
- indexed bind variablesmapNamedBindVars
- named bind variables
-
FilterBuilder
public FilterBuilder(List indexedBindVars, ParameterResolver namedBindVars, CoherenceQueryLanguage language)
Construct a new FilterBuilder with given default bind variables.- Parameters:
indexedBindVars
- the indexed bind variablesnamedBindVars
- the named bind variableslanguage
- theCoherenceQueryLanguage
instance to use
-
-
Method Detail
-
makeFilter
public Filter makeFilter()
Make a new Filter from the set AST.- Returns:
- the constructed Filter
-
makeFilter
public Filter makeFilter(Term term)
Make a new Filter from the given AST.- Parameters:
term
- the AST to turn into a Filter- Returns:
- the constructed Filter
-
makeFilter
public Filter makeFilter(Term term, Object[] aoIndexedBindVars)
Make a new Filter from the given AST using given array for Bind vars.- Parameters:
term
- the AST to turn into a FilteraoIndexedBindVars
- the array of Objects to use for Bind vars- Returns:
- the constructed Filter
-
makeFilter
public Filter makeFilter(Term term, Object[] aoIndexedBindVars, Map mapNamedBindVars)
Make a new Filter from the given AST using the given bind variables.- Parameters:
term
- the AST to turn into a FilteraoIndexedBindVars
- the array of Objects to use for bind variablesmapNamedBindVars
- the named bind variables to use- Returns:
- the constructed Filter
-
makeFilter
public Filter makeFilter(Term term, List listBindVars, ParameterResolver namedBindVars)
Make a new Filter from the given AST using the given bind variables.- Parameters:
term
- the AST to turn into a FilterlistBindVars
- the indexed bind variablesnamedBindVars
- the named bind variables- Returns:
- the constructed Filter
-
makeFilterForCache
public Filter makeFilterForCache(String sCacheName, Term term, List indexedBindVars, ParameterResolver namedBindVars)
Make a new Filter from the given AST using given array for Bind vars.- Parameters:
sCacheName
- the name of the cache the Filter is to queryterm
- the AST to turn into a FilterindexedBindVars
- the indexed bind variables to usenamedBindVars
- the named bind variables to use- Returns:
- the constructed Filter
-
makeExtractor
public ValueExtractor makeExtractor(NodeTerm term)
Process the AST Tree using the given Term that represents getter.- Parameters:
term
- the AST used- Returns:
- the resulting ValueExtractor
-
acceptList
protected void acceptList(NodeTerm termList)
Description copied from class:com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
The receiver has classified a list node.- Overrides:
acceptList
in classcom.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
- Parameters:
termList
- the Term whose children represent the elements of the list
-
acceptIdentifier
protected void acceptIdentifier(String sIdentifier)
Description copied from class:com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
The receiver has classified an identifier node.- Overrides:
acceptIdentifier
in classcom.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
- Parameters:
sIdentifier
- the String representing the identifier
-
acceptBinaryOperator
protected void acceptBinaryOperator(String sOperator, Term termLeft, Term termRight)
This method will take a Binary Operator and the left and rightTerm
s for the operator and result in the creation of aFilter
or aValueExtractor
.- Overrides:
acceptBinaryOperator
in classcom.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
- Parameters:
sOperator
- the string representing the operatortermLeft
- the left Term of the operationtermRight
- the right Term of the operation
-
acceptUnaryOperator
protected void acceptUnaryOperator(String sOperator, Term t)
Description copied from class:com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
The receiver has classified a unary operation node.- Overrides:
acceptUnaryOperator
in classcom.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
- Parameters:
sOperator
- the string representing the operatort
- the Term being operated upon
-
acceptPath
protected void acceptPath(NodeTerm term)
Description copied from class:com.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
The receiver has classified a path node.- Overrides:
acceptPath
in classcom.tangosol.coherence.dslquery.internal.AbstractCoherenceQueryWalker
- Parameters:
term
- a Term whose children are the elements of the path
-
newParameterListFromMap
protected static ParameterList newParameterListFromMap(Map<?,?> map)
Convert the givenMap
into aParameterList
. The key of the map is used as the parameter name and the corresponding value as the parameter value.- Parameters:
map
- the Map to convert to a ParameterList- Returns:
- a ParameterList made up of the contents of the specified Map
-
-