com.clarkparsia.pellet.sparqldl.model
Class QueryImpl

java.lang.Object
  extended by com.clarkparsia.pellet.sparqldl.model.QueryImpl
All Implemented Interfaces:
Query

public class QueryImpl
extends java.lang.Object
implements Query

Title: Default implementation of the Query

Description:

Copyright: Copyright (c) 2007

Company: Clark & Parsia, LLC.

Author:
Petr Kremen

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.clarkparsia.pellet.sparqldl.model.Query
Query.VarType
 
Constructor Summary
QueryImpl(KnowledgeBase kb, boolean distinct)
           
QueryImpl(Query query)
           
 
Method Summary
 void add(QueryAtom atom)
          Adds an query atom to the query.
 void addDistVar(aterm.ATermAppl a, Query.VarType type)
          Adds a distinguished variable to the query with its type - there can be more variable types to support punning.
 void addResultVar(aterm.ATermAppl a)
          Adds a distinguished variable that appears in the result projection to the query;
 Query apply(ResultBinding binding)
          Replace the variables in the query with the values specified in the binding and return a new query instance (without modifying this query).
 java.util.List<QueryAtom> findAtoms(QueryPredicate predicate, aterm.ATermAppl... args)
          Searches for given atom pattern.
 java.util.List<QueryAtom> getAtoms()
          Get all the atoms in the query.
 java.util.Set<aterm.ATermAppl> getConstants()
          Return individuals and literals used in this query.
 java.util.Set<aterm.ATermAppl> getDistVars()
          Return all the distinguished variables.
 java.util.Set<aterm.ATermAppl> getDistVarsForType(Query.VarType type)
          Returns variables that occur in the subquery specified by the given type.
 Filter getFilter()
          Sets the filter for this query.
 KnowledgeBase getKB()
          The KB that will be used to answer this query.
 aterm.ATermAppl getName()
          Return the name of this query
 QueryParameters getQueryParameters()
          Get the query parameterization values
 java.util.List<aterm.ATermAppl> getResultVars()
          Return all the variables that will be in the results.
 java.util.Set<aterm.ATermAppl> getUndistVars()
          Return all undistinguished variables used in this query.
 java.util.Set<aterm.ATermAppl> getVars()
          Return all the variables used in this query.
 boolean isDistinct()
          Returns true if distinct results are required.
 boolean isGround()
          Checks whether the query is ground.
 void remove(QueryAtom atom)
          
 Query reorder(int[] ordering)
          Creates a subquery from the given query.
 aterm.ATermAppl rollUpTo(aterm.ATermAppl var, java.util.Collection<aterm.ATermAppl> stopList, boolean stopOnConstants)
          Rolls up the query to the given variable.
 void setFilter(Filter filter)
          Sets the filter for this query.
 void setKB(KnowledgeBase kb)
          Sets the KB that will be used to answer this query.
 void setName(aterm.ATermAppl name)
          Sets the name of this query
 void setQueryParameters(QueryParameters parameters)
          Set the query parameterization
 java.lang.String toString()
           
 java.lang.String toString(boolean multiLine)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryImpl

public QueryImpl(KnowledgeBase kb,
                 boolean distinct)

QueryImpl

public QueryImpl(Query query)
Method Detail

add

public void add(QueryAtom atom)
Adds an query atom to the query.

Specified by:
add in interface Query

getDistVarsForType

public java.util.Set<aterm.ATermAppl> getDistVarsForType(Query.VarType type)
Returns variables that occur in the subquery specified by the given type.

Specified by:
getDistVarsForType in interface Query
Returns:

addDistVar

public void addDistVar(aterm.ATermAppl a,
                       Query.VarType type)
Adds a distinguished variable to the query with its type - there can be more variable types to support punning.

Specified by:
addDistVar in interface Query

addResultVar

public void addResultVar(aterm.ATermAppl a)
Adds a distinguished variable that appears in the result projection to the query;

Specified by:
addResultVar in interface Query

getAtoms

public java.util.List<QueryAtom> getAtoms()
Get all the atoms in the query.

Specified by:
getAtoms in interface Query
Returns:

getConstants

public java.util.Set<aterm.ATermAppl> getConstants()
Return individuals and literals used in this query.

Specified by:
getConstants in interface Query
Returns:

getDistVars

public java.util.Set<aterm.ATermAppl> getDistVars()
Return all the distinguished variables. These are variables that will be bound to individuals (or data values) existing in the KB.

Specified by:
getDistVars in interface Query
Returns:
Set of variables

getUndistVars

public java.util.Set<aterm.ATermAppl> getUndistVars()
Return all undistinguished variables used in this query.

Specified by:
getUndistVars in interface Query
Returns:
Set of variables

getResultVars

public java.util.List<aterm.ATermAppl> getResultVars()
Return all the variables that will be in the results. For SPARQL, these are the variables in the SELECT clause.

Specified by:
getResultVars in interface Query
Returns:
Set of variables

getVars

public java.util.Set<aterm.ATermAppl> getVars()
Return all the variables used in this query.

Specified by:
getVars in interface Query
Returns:
Set of variables

isGround

public boolean isGround()
Checks whether the query is ground.

Specified by:
isGround in interface Query
Returns:
true iff the query is ground

getKB

public KnowledgeBase getKB()
The KB that will be used to answer this query.

Specified by:
getKB in interface Query
Returns:

setKB

public void setKB(KnowledgeBase kb)
Sets the KB that will be used to answer this query.

Specified by:
setKB in interface Query
Parameters:
kb - KB that will be used to answer this query

apply

public Query apply(ResultBinding binding)
Replace the variables in the query with the values specified in the binding and return a new query instance (without modifying this query).

Specified by:
apply in interface Query
Returns:

rollUpTo

public aterm.ATermAppl rollUpTo(aterm.ATermAppl var,
                                java.util.Collection<aterm.ATermAppl> stopList,
                                boolean stopOnConstants)
Rolls up the query to the given variable. TODO

Specified by:
rollUpTo in interface Query
Returns:

findAtoms

public java.util.List<QueryAtom> findAtoms(QueryPredicate predicate,
                                           aterm.ATermAppl... args)
Searches for given atom pattern. This also might be used for different types of rolling-up, involving various sets of allowed atom types.

Specified by:
findAtoms in interface Query
Returns:
query atoms in the order as they appear in the query

reorder

public Query reorder(int[] ordering)
Creates a subquery from the given query. Atoms are listed according to the 'atoms' parameter.

Specified by:
reorder in interface Query
Parameters:
ordering - selected atom indices
Returns:
subquery

remove

public void remove(QueryAtom atom)

Specified by:
remove in interface Query

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean multiLine)

isDistinct

public boolean isDistinct()
Returns true if distinct results are required.

Specified by:
isDistinct in interface Query
Returns:

getFilter

public Filter getFilter()
Sets the filter for this query.

Specified by:
getFilter in interface Query
Returns:

setFilter

public void setFilter(Filter filter)
Sets the filter for this query.

Specified by:
setFilter in interface Query

setQueryParameters

public void setQueryParameters(QueryParameters parameters)
Description copied from interface: Query
Set the query parameterization

Specified by:
setQueryParameters in interface Query

getQueryParameters

public QueryParameters getQueryParameters()
Description copied from interface: Query
Get the query parameterization values

Specified by:
getQueryParameters in interface Query
Returns:
QueryParameters

getName

public aterm.ATermAppl getName()
Description copied from interface: Query
Return the name of this query

Specified by:
getName in interface Query
Returns:
name of the query

setName

public void setName(aterm.ATermAppl name)
Description copied from interface: Query
Sets the name of this query

Specified by:
setName in interface Query
Parameters:
name - name of the query


Copyright © 2004 Evren Sirin. All Rights Reserved.