Class QueryParser<O>
- java.lang.Object
-
- com.googlecode.cqengine.query.parser.common.QueryParser<O>
-
public abstract class QueryParser<O> extends Object
A service provider interface for parsers which can convert string queries to CQEngine native queries. Subclasses can implement this to support string-based queries in various dialects, such as SQL or a string representation of a CQEngine native query.- Author:
- Niall Gallagher
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Attribute<O,?>>
attributes
protected ValueParser<Object>
fallbackValueParser
protected Class<O>
objectType
protected static org.antlr.v4.runtime.BaseErrorListener
SYNTAX_ERROR_LISTENER
protected Map<Class<?>,ValueParser<?>>
valueParsers
-
Constructor Summary
Constructors Constructor Description QueryParser(Class<O> objectType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <A> Attribute<O,A>
getAttribute(org.antlr.v4.runtime.tree.ParseTree attributeNameContext, Class<A> expectedSuperType)
Class<O>
getObjectType()
abstract ParseResult<O>
parse(String query)
Parses the given query and its query options, encapsulating both in the object returned.<A> A
parseValue(Attribute<O,A> attribute, org.antlr.v4.runtime.tree.ParseTree parameterContext)
<A> A
parseValue(Class<A> valueType, String text)
<A> A
parseValue(Class<A> valueType, org.antlr.v4.runtime.tree.ParseTree parameterContext)
Query<O>
query(String query)
Shortcut for callingparse(query).getQuery()
.QueryOptions
queryOptions(String query)
Shortcut for callingparse(query).getQueryOptions()
.<A> void
registerAttribute(Attribute<O,A> attribute)
void
registerAttributes(Iterable<? extends Attribute<O,?>> attributes)
void
registerAttributes(Map<String,? extends Attribute<O,?>> attributes)
void
registerFallbackValueParser(ValueParser<Object> fallbackValueParser)
<A> void
registerValueParser(Class<A> valueType, ValueParser<A> valueParser)
ResultSet<O>
retrieve(IndexedCollection<O> collection, String query)
Shortcut for parsing the given query and its query options, and then retrieving objects matching the query from the given collection, using the parsed query options.
-
-
-
Field Detail
-
valueParsers
protected final Map<Class<?>,ValueParser<?>> valueParsers
-
fallbackValueParser
protected volatile ValueParser<Object> fallbackValueParser
-
SYNTAX_ERROR_LISTENER
protected static final org.antlr.v4.runtime.BaseErrorListener SYNTAX_ERROR_LISTENER
-
-
Method Detail
-
registerAttributes
public void registerAttributes(Map<String,? extends Attribute<O,?>> attributes)
-
registerValueParser
public <A> void registerValueParser(Class<A> valueType, ValueParser<A> valueParser)
-
registerFallbackValueParser
public void registerFallbackValueParser(ValueParser<Object> fallbackValueParser)
-
getAttribute
public <A> Attribute<O,A> getAttribute(org.antlr.v4.runtime.tree.ParseTree attributeNameContext, Class<A> expectedSuperType)
-
parseValue
public <A> A parseValue(Attribute<O,A> attribute, org.antlr.v4.runtime.tree.ParseTree parameterContext)
-
parseValue
public <A> A parseValue(Class<A> valueType, org.antlr.v4.runtime.tree.ParseTree parameterContext)
-
parse
public abstract ParseResult<O> parse(String query)
Parses the given query and its query options, encapsulating both in the object returned.- Parameters:
query
- The query to parse- Returns:
- An object encapsulating the parsed query and its query options
-
retrieve
public ResultSet<O> retrieve(IndexedCollection<O> collection, String query)
Shortcut for parsing the given query and its query options, and then retrieving objects matching the query from the given collection, using the parsed query options.- Parameters:
query
- The query to parse- Returns:
- The results of querying the collection with the parsed query and its query options
-
query
public Query<O> query(String query)
Shortcut for callingparse(query).getQuery()
.- Parameters:
query
- The query to parse- Returns:
- The parsed query on its own, without any query options
-
queryOptions
public QueryOptions queryOptions(String query)
Shortcut for callingparse(query).getQueryOptions()
.- Parameters:
query
- The query to parse- Returns:
- The query options, without the actual query
-
-