Class QueryProcessor
- java.lang.Object
-
- net.ontopia.topicmaps.query.impl.basic.AbstractQueryProcessor
-
- net.ontopia.topicmaps.query.impl.basic.QueryProcessor
-
- All Implemented Interfaces:
IndexIF
,QueryProcessorIF
public class QueryProcessor extends AbstractQueryProcessor implements QueryProcessorIF, IndexIF
INTERNAL: This query processor implementation can be used to query any topic map implementation; it makes no assumptions about the stored form of the topic map.
-
-
Field Summary
Fields Modifier and Type Field Description protected Collator
collator
protected TologOptions
options
protected TologParser
parser
protected TopicMapIF
topicmap
-
Constructor Summary
Constructors Constructor Description QueryProcessor(TopicMapIF topicmap)
QueryProcessor(TopicMapIF topicmap, LocatorIF base)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryMatches
count(TologQuery query, QueryMatches matches)
INTERNAL: Replaces count($A) variables by their relevant counts.QueryMatches
createInitialMatches(TologQuery query, Collection items, Map arguments)
QueryMatches
createInitialMatches(TologQuery query, Map arguments)
QueryResultIF
execute(String query)
PUBLIC: Parses and executes the query, returning the results.QueryResultIF
execute(String query, Map arguments)
PUBLIC: Parses and executes the query binding the parameters in the query to the values given in the 'arguments' map, returning the results.QueryResultIF
execute(String query, Map arguments, DeclarationContextIF context)
PUBLIC: Parses and executes the query in the given context binding the parameters in the query to the values given in the 'arguments' map, returning the results.QueryResultIF
execute(String query, DeclarationContextIF context)
PUBLIC: Parses and executes the query in the given context, returning the results.QueryResultIF
execute(TologQuery query)
QueryResultIF
execute(TologQuery query, Map arguments)
TologOptions
getOptions()
void
load(Reader ruleset)
DEPRECATED: Loads a set of rules into the query processor from a reader object.void
load(String ruleset)
DEPRECATED: Loads a set of rules into the query processor from a string.ParsedQueryIF
parse(String query)
PUBLIC: Parses the query, returning an object representing the result.ParsedQueryIF
parse(String query, DeclarationContextIF context)
PUBLIC: Parses the query in the given context, returning an object representing the result.protected TologQuery
parseQuery(String query, DeclarationContextIF context)
ParsedModificationStatementIF
parseUpdate(String statement)
PUBLIC: Parses the update statement, returning an object representing the result.ParsedModificationStatementIF
parseUpdate(String statement, DeclarationContextIF context)
PUBLIC: Parses the update statement in the given context, returning an object representing the result.protected ModificationStatement
parseUpdateStatement(String statement, DeclarationContextIF ctx)
QueryMatches
reduce(TologQuery query, QueryMatches matches)
INTERNAL: Projects the query results onto the set of variables specified in the 'select' clause.protected int
runUpdate(ModificationStatement statement, Map<String,?> params)
void
sort(TologQuery query, QueryMatches matches)
INTERNAL: Sorts the query result as requested.int
update(String query)
PUBLIC: Runs the update statement, returning the number of modified objects.int
update(String query, Map<String,?> params)
PUBLIC: Runs the update statement with the given parameters, returning the number of modified objects.int
update(String query, Map<String,?> params, DeclarationContextIF context)
PUBLIC: Runs the update statement in the given declaration context with the given parameters, returning the number of modified objects.int
update(String query, DeclarationContextIF context)
PUBLIC: Runs the update statement in the given declaration context, returning the number of modified objects.-
Methods inherited from class net.ontopia.topicmaps.query.impl.basic.AbstractQueryProcessor
findClauseItems, findClauseVariables, satisfy
-
-
-
-
Field Detail
-
topicmap
protected TopicMapIF topicmap
-
collator
protected Collator collator
-
options
protected TologOptions options
-
parser
protected TologParser parser
-
-
Constructor Detail
-
QueryProcessor
public QueryProcessor(TopicMapIF topicmap)
-
QueryProcessor
public QueryProcessor(TopicMapIF topicmap, LocatorIF base)
-
-
Method Detail
-
getOptions
public TologOptions getOptions()
-
execute
public QueryResultIF execute(String query) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses and executes the query, returning the results.- Specified by:
execute
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
execute
public QueryResultIF execute(String query, DeclarationContextIF context) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses and executes the query in the given context, returning the results.- Specified by:
execute
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
execute
public QueryResultIF execute(String query, Map arguments) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses and executes the query binding the parameters in the query to the values given in the 'arguments' map, returning the results.- Specified by:
execute
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
execute
public QueryResultIF execute(String query, Map arguments, DeclarationContextIF context) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses and executes the query in the given context binding the parameters in the query to the values given in the 'arguments' map, returning the results.- Specified by:
execute
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
parse
public ParsedQueryIF parse(String query) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses the query, returning an object representing the result.- Specified by:
parse
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
parse
public ParsedQueryIF parse(String query, DeclarationContextIF context) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses the query in the given context, returning an object representing the result.- Specified by:
parse
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
parseQuery
protected TologQuery parseQuery(String query, DeclarationContextIF context) throws InvalidQueryException
- Throws:
InvalidQueryException
-
load
public void load(String ruleset) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
DEPRECATED: Loads a set of rules into the query processor from a string. The rules will then be available for use in queries throughout the lifetime of the current scope.- Specified by:
load
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
load
public void load(Reader ruleset) throws InvalidQueryException, IOException
Description copied from interface:QueryProcessorIF
DEPRECATED: Loads a set of rules into the query processor from a reader object. The rules will then be available for use in queries throughout the lifetime of the current scope.- Specified by:
load
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
IOException
-
execute
public QueryResultIF execute(TologQuery query) throws InvalidQueryException
- Throws:
InvalidQueryException
-
execute
public QueryResultIF execute(TologQuery query, Map arguments) throws InvalidQueryException
- Throws:
InvalidQueryException
-
update
public int update(String query) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Runs the update statement, returning the number of modified objects.- Specified by:
update
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
update
public int update(String query, DeclarationContextIF context) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Runs the update statement in the given declaration context, returning the number of modified objects.- Specified by:
update
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
update
public int update(String query, Map<String,?> params) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Runs the update statement with the given parameters, returning the number of modified objects.- Specified by:
update
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
update
public int update(String query, Map<String,?> params, DeclarationContextIF context) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Runs the update statement in the given declaration context with the given parameters, returning the number of modified objects.- Specified by:
update
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
parseUpdate
public ParsedModificationStatementIF parseUpdate(String statement) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses the update statement, returning an object representing the result.- Specified by:
parseUpdate
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
parseUpdate
public ParsedModificationStatementIF parseUpdate(String statement, DeclarationContextIF context) throws InvalidQueryException
Description copied from interface:QueryProcessorIF
PUBLIC: Parses the update statement in the given context, returning an object representing the result.- Specified by:
parseUpdate
in interfaceQueryProcessorIF
- Throws:
InvalidQueryException
-
parseUpdateStatement
protected ModificationStatement parseUpdateStatement(String statement, DeclarationContextIF ctx) throws InvalidQueryException
- Throws:
InvalidQueryException
-
runUpdate
protected int runUpdate(ModificationStatement statement, Map<String,?> params) throws InvalidQueryException
- Throws:
InvalidQueryException
-
createInitialMatches
public QueryMatches createInitialMatches(TologQuery query, Map arguments)
-
createInitialMatches
public QueryMatches createInitialMatches(TologQuery query, Collection items, Map arguments)
-
reduce
public QueryMatches reduce(TologQuery query, QueryMatches matches)
INTERNAL: Projects the query results onto the set of variables specified in the 'select' clause. If there is no 'select' clause nothing is done.- Parameters:
query
- The parsed query.matches
- The query result.
-
count
public QueryMatches count(TologQuery query, QueryMatches matches)
INTERNAL: Replaces count($A) variables by their relevant counts.- Parameters:
query
- The parsed query.matches
- The query result.
-
sort
public void sort(TologQuery query, QueryMatches matches)
INTERNAL: Sorts the query result as requested.- Parameters:
query
- The parsed query.matches
- The query result.
-
-