org.openanzo.glitter.query
Class QueryController

java.lang.Object
  extended by org.openanzo.glitter.query.QueryController
All Implemented Interfaces:
QueryInformation

public class QueryController
extends java.lang.Object
implements QueryInformation

The QueryController is a central point for much of the information that characterizes a parsed and prepared query. A QueryController is populated as a query is parsed, and its information is used to feed other parts of the query system (e.g. the RDFDataset)

Author:
lee

Constructor Summary
QueryController()
          Default constructor.
 
Method Summary
 void addDefaultGraph(java.net.URI g)
          Notes a default graph found in the query in a FROM clause
 void addNamedGraph(java.net.URI g)
          Notes a named graph found in the query in a FROM NAMED clause
 void addOrderingCondition(OrderingCondition condition)
          Notes an OrderingCondition (expression + sort direction) found in a query in an ORDER BY clause.
 java.net.URI getBaseUri()
           
 java.util.Set<java.net.URI> getDefaultGraphs()
           
 int getLimit()
           
 java.util.Set<java.net.URI> getNamedGraphs()
           
 int getOffset()
           
 java.util.List<OrderingCondition> getOrderingConditions()
           
 GraphPattern getQueryPattern()
           
 QueryResultForm getQueryResultForm()
           
 QueryResults getQueryResults()
          Retrieves the query results.
 java.lang.String getQueryString()
           
 QueryType getQueryType()
           
 SolutionGenerator getSolutionGenerator()
           
 boolean isOrdered()
           
 void mapPrefix(java.lang.String prefix, java.net.URI uri)
          Records a mapping from a given prefix to its URI expansion.
 java.net.URI resolveQName(java.lang.String prefix, java.lang.String localPart)
          Fully resolves a prefixed name into the full URI that it represents
 java.net.URI resolveQName(java.lang.String prefix, java.lang.String localPart, boolean fullyResolve)
          Resolves a prefixed name into the full URI that it represents.
 java.net.URI resolveUri(java.lang.String s)
          See resolveUri(URI).
 java.net.URI resolveUri(java.net.URI u)
          Resolves the given (possibly relative) URI against a base URI, if one has been set.
 void setBaseUri(java.net.URI u)
          Sets the base URI against which relative URIs are resolved.
 void setLimit(int limit)
          Sets the solution limit as given by a LIMIT clause
 void setOffset(int offset)
          Sets the offset into the solution sequence as given by a OFFSET clause
 void setQueryPattern(GraphPattern pattern)
          Sets the root node in the WHERE clause of the query
 void setQueryResultForm(QueryResultForm resultForm)
          Sets the query form.
 void setQueryResults(QueryResults queryResults)
          Sets the results of executing the query.
 void setSolutionGenerator(SolutionGenerator solutionGenerator)
          Sets the SolutionGenerator used for generating bindings while executing the query.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryController

public QueryController()
Default constructor.

Method Detail

addDefaultGraph

public void addDefaultGraph(java.net.URI g)
Notes a default graph found in the query in a FROM clause

Parameters:
g -

addNamedGraph

public void addNamedGraph(java.net.URI g)
Notes a named graph found in the query in a FROM NAMED clause

Parameters:
g -

addOrderingCondition

public void addOrderingCondition(OrderingCondition condition)
Notes an OrderingCondition (expression + sort direction) found in a query in an ORDER BY clause. Note that the order that addOrderingCondition(OrderingCondition) is called is significant and should match the order the conditions are present in the query.

Parameters:
condition -

getBaseUri

public java.net.URI getBaseUri()
Specified by:
getBaseUri in interface QueryInformation
Returns:
The base URI as given by the BASE keyword.

getDefaultGraphs

public java.util.Set<java.net.URI> getDefaultGraphs()
Returns:
The set of URIs that identify the components of the default graph for this query

getLimit

public int getLimit()
Specified by:
getLimit in interface QueryInformation
Returns:
The solution limit as given by the LIMIT keyword.

getNamedGraphs

public java.util.Set<java.net.URI> getNamedGraphs()
Returns:
The set of URIs that identify the named graphs for this query

getOffset

public int getOffset()
Specified by:
getOffset in interface QueryInformation
Returns:
The solution sequence offset as given by the OFFSET keyword.

getOrderingConditions

public java.util.List<OrderingCondition> getOrderingConditions()
Specified by:
getOrderingConditions in interface QueryInformation
Returns:
The sort conditions as given by the ORDER BY clause.

getQueryPattern

public GraphPattern getQueryPattern()
Specified by:
getQueryPattern in interface QueryInformation
Returns:
The root node in the query's abstract syntax tree.

getQueryResultForm

public QueryResultForm getQueryResultForm()
Specified by:
getQueryResultForm in interface QueryInformation
Returns:
The result form of the query (SELECT, ASK, or CONSTRUCT)

getQueryString

public java.lang.String getQueryString()
Specified by:
getQueryString in interface QueryInformation
Returns:
The original query string.

getQueryType

public QueryType getQueryType()
Specified by:
getQueryType in interface QueryInformation
Returns:
An enumeration denoting the type of query (SELECT, ASK, or CONSTRUCT)

isOrdered

public boolean isOrdered()
Returns:
Whether or not the query is ordered; i.e., if it has any OrderingConditions

mapPrefix

public void mapPrefix(java.lang.String prefix,
                      java.net.URI uri)
Records a mapping from a given prefix to its URI expansion. See resolveQName(String, String)

Parameters:
prefix -
uri -

resolveQName

public java.net.URI resolveQName(java.lang.String prefix,
                                 java.lang.String localPart)
                          throws ParseException
Fully resolves a prefixed name into the full URI that it represents

Parameters:
prefix - The prefix part of the prefixed name (before the ':')
localPart - The local name part of the prefixed name (after the ':')
Returns:
A fully resolved (absolute) URI
Throws:
ParseException

resolveQName

public java.net.URI resolveQName(java.lang.String prefix,
                                 java.lang.String localPart,
                                 boolean fullyResolve)
                          throws ParseException
Resolves a prefixed name into the full URI that it represents.

Parameters:
prefix - The prefix part of the prefixed name (before the ':')
localPart - The local name part of the prefixed name (after the ':')
fullyResolve - If false, simply resolve the prefix. If true, also resolve a relative URI based on our base URI. See resolveUri(String).
Returns:
The resolved prefixed name.
Throws:
ParseException

resolveUri

public java.net.URI resolveUri(java.lang.String s)
                        throws java.net.URISyntaxException
See resolveUri(URI).

Parameters:
s - String form of the URI to resolve.
Returns:
The resolved URI.
Throws:
java.net.URISyntaxException

resolveUri

public java.net.URI resolveUri(java.net.URI u)
Resolves the given (possibly relative) URI against a base URI, if one has been set.

Parameters:
u - The URI to resolve.
Returns:
The resolved URI, or u if no base URI has been set.

setBaseUri

public void setBaseUri(java.net.URI u)
Sets the base URI against which relative URIs are resolved.

Parameters:
u - the bsae URI

setLimit

public void setLimit(int limit)
Sets the solution limit as given by a LIMIT clause

Parameters:
limit -

setOffset

public void setOffset(int offset)
Sets the offset into the solution sequence as given by a OFFSET clause

Parameters:
offset -

setQueryPattern

public void setQueryPattern(GraphPattern pattern)
Sets the root node in the WHERE clause of the query

Parameters:
pattern -

setQueryResultForm

public void setQueryResultForm(QueryResultForm resultForm)
Sets the query form. One of Projection, Ask, or Construct.

Parameters:
resultForm -

getQueryResults

public QueryResults getQueryResults()
Retrieves the query results. This is only valid after setQueryResults(QueryResults) has been called.

Returns:
The QueryResults

setQueryResults

public void setQueryResults(QueryResults queryResults)
Sets the results of executing the query.

Parameters:
queryResults -

getSolutionGenerator

public SolutionGenerator getSolutionGenerator()
Specified by:
getSolutionGenerator in interface QueryInformation
Returns:
The query's backend solution generator.

setSolutionGenerator

public void setSolutionGenerator(SolutionGenerator solutionGenerator)
Sets the SolutionGenerator used for generating bindings while executing the query.

Parameters:
solutionGenerator -


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.