org.modeshape.graph.query.parse
Class QueryParsers

java.lang.Object
  extended by org.modeshape.graph.query.parse.QueryParsers

@ThreadSafe
public class QueryParsers
extends Object

A thread-safe collection of QueryParser implementations that can be used to parse queries by language.


Constructor Summary
QueryParsers(Iterable<QueryParser> parsers)
          Create a new collection of the supplied QueryParser objects.
QueryParsers(QueryParser... parsers)
          Create a new collection of the supplied QueryParser objects.
 
Method Summary
 void addLanguage(QueryParser languageParser)
          Add a language to this engine by supplying its parser.
 void addLanguages(Iterable<QueryParser> languages)
          Add one or more languages to this engine by supplying the corresponding parsers.
 void addLanguages(QueryParser firstLanguage, QueryParser... additionalLanguages)
          Add one or more languages to this engine by supplying the corresponding parsers.
 boolean equals(Object obj)
          
 Set<String> getLanguages()
          Get the set of languages that this engine is capable of parsing.
 QueryParser getParserFor(String language)
          Get the parser for the supplied language.
 int hashCode()
          
 QueryCommand parse(TypeSystem typeSystem, String language, String query)
          Execute the supplied query by planning, optimizing, and then processing it.
 QueryParser removeLanguage(String language)
          Remove from this engine the language with the given name.
 Collection<QueryParser> removeLanguages(String firstLanguage, String... additionalLanguages)
          Remove from this engine the language with the given name.
 String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryParsers

public QueryParsers(QueryParser... parsers)
Create a new collection of the supplied QueryParser objects.

Parameters:
parsers - the parsers

QueryParsers

public QueryParsers(Iterable<QueryParser> parsers)
Create a new collection of the supplied QueryParser objects.

Parameters:
parsers - the parsers
Method Detail

addLanguage

public void addLanguage(QueryParser languageParser)
Add a language to this engine by supplying its parser.

Parameters:
languageParser - the query parser for the language
Throws:
IllegalArgumentException - if the language parser is null

addLanguages

public void addLanguages(QueryParser firstLanguage,
                         QueryParser... additionalLanguages)
Add one or more languages to this engine by supplying the corresponding parsers.

Parameters:
firstLanguage - the query parser for the first language
additionalLanguages - the query parsers for the additional languages
Throws:
IllegalArgumentException - if the language parser is null

addLanguages

public void addLanguages(Iterable<QueryParser> languages)
Add one or more languages to this engine by supplying the corresponding parsers.

Parameters:
languages - the query parsers for the languages that are to be added
Throws:
IllegalArgumentException - if the iterable reference is null

removeLanguage

public QueryParser removeLanguage(String language)
Remove from this engine the language with the given name.

Parameters:
language - the name of the language, which is to match the language of the parser
Returns:
the parser for the language, or null if the engine had no support for the named language
Throws:
IllegalArgumentException - if the language is null

removeLanguages

public Collection<QueryParser> removeLanguages(String firstLanguage,
                                               String... additionalLanguages)
Remove from this engine the language with the given name.

Parameters:
firstLanguage - the name of the first language to remove, which must match the language of the parser
additionalLanguages - the names of the additional languages to remove, which must match the language of the parser
Returns:
the parser for the language, or null if the engine had no support for the named language
Throws:
IllegalArgumentException - if the language is null

getLanguages

public Set<String> getLanguages()
Get the set of languages that this engine is capable of parsing.

Returns:
the unmodifiable copy of the set of languages; never null but possibly empty

getParserFor

public QueryParser getParserFor(String language)
Get the parser for the supplied language.

Parameters:
language - the language in which the query is expressed; must case-insensitively match one of the supported languages
Returns:
the query parser, or null if the supplied language is not supported
Throws:
IllegalArgumentException - if the language is null

parse

public QueryCommand parse(TypeSystem typeSystem,
                          String language,
                          String query)
Execute the supplied query by planning, optimizing, and then processing it.

Parameters:
typeSystem - the type system that should be used
language - the language in which the query is expressed; must case-insensitively match one of the supported languages
query - the query that is to be executed
Returns:
the parsed query command; never null
Throws:
IllegalArgumentException - if the language, context or query references are null, or if the language is not known
ParsingException - if there is an error parsing the supplied query
InvalidQueryException - if the supplied query can be parsed but is invalid

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.