org.mindswap.pellet.query.impl
Class QueryImpl

java.lang.Object
  extended by org.mindswap.pellet.query.impl.QueryImpl
All Implemented Interfaces:
Query

public class QueryImpl
extends java.lang.Object
implements Query

Author:
Evren Sirin

Constructor Summary
QueryImpl(KnowledgeBase kb)
           
QueryImpl(KnowledgeBase kb, boolean isDistinct)
           
 
Method Summary
 void addConstraint(aterm.ATermAppl lit, Datatype dt)
           
 void addDistVar(aterm.ATermAppl var)
          Add a distinguished variable to the query but not change the result variables.
 void addEdgePattern(aterm.ATermAppl s, aterm.ATermAppl p, aterm.ATermAppl o)
           
 void addPattern(int index, QueryPattern pattern)
           
 void addPattern(QueryPattern pattern)
           
 void addResultVar(aterm.ATermAppl var)
          Add a result variable to the query which makes this variable distinguished and appear in the results.
 void addTypePattern(aterm.ATermAppl ind, aterm.ATermAppl c)
           
 Query apply(QueryResultBinding binding)
          Replace the variables in the query with the values specified in the binding and return a new query instance.
 java.util.List findPatterns(aterm.ATermAppl subj, aterm.ATermAppl pred, aterm.ATermAppl obj)
          Find edges in the query graph that matches the pattern (where null matches anything)
 aterm.ATermList getClasses(aterm.ATermAppl term)
           
 java.util.Set getConstants()
          Return all the (individual) constants used in this query.
 Datatype getDatatype(aterm.ATermAppl term)
           
 java.util.Set getDistLitVars()
          Return the distinguished literal variables.
 java.util.Set getDistObjVars()
          Return the distinguished object variables.
 java.util.Set getDistVars()
          Return all the distinguished variables.
 KnowledgeBase getKB()
          The KB that will be used to answer this query.
 java.util.Set getLitVars()
          Return all the literal variables, i.e.
 java.util.Set getObjVars()
          Return all the object variables, i.e.
 QueryParameters getQueryParameters()
          Return query parameterization values
 java.util.List getQueryPatterns()
          Return all the query patterns in this query.
 java.util.List getResultVars()
          Return all the variables that will be in the results.
 java.util.Set getVars()
          Return all the variables used in this query.
 boolean hasUndefinedPredicate()
           
 void insertEdgePattern(aterm.ATermAppl s, aterm.ATermAppl p, aterm.ATermAppl o)
           
 boolean isDistinct()
          Returns true if no duplicates are wanted in the results.
 boolean isGround()
          Returns true if there are not variables in the query (only constants).
 void prepare()
           
 void printName(aterm.ATermAppl term, java.lang.StringBuffer sb)
           
 void removePattern(QueryPattern pattern)
           
 Query reorder(int[] ordering)
          Reorder the patterns in the query with respect to given ordering.
 aterm.ATermAppl rollUpTo(aterm.ATermAppl var)
           
 void setDistinct(boolean isDistinct)
           
 void setHasUndefinedPredicate(boolean hasUndefinedPredicate)
           
 void setKB(KnowledgeBase kb)
           
 void setQueryParameters(QueryParameters parameters)
          Enables 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)

QueryImpl

public QueryImpl(KnowledgeBase kb,
                 boolean isDistinct)
Method Detail

setKB

public void setKB(KnowledgeBase kb)
Specified by:
setKB in interface Query

setQueryParameters

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

Specified by:
setQueryParameters in interface Query

getQueryParameters

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

Specified by:
getQueryParameters in interface Query
Returns:
QueryParameters

addDistVar

public void addDistVar(aterm.ATermAppl var)
Description copied from interface: Query
Add a distinguished variable to the query but not change the result variables.

Specified by:
addDistVar in interface Query
Parameters:
var - Variable

addResultVar

public void addResultVar(aterm.ATermAppl var)
Description copied from interface: Query
Add a result variable to the query which makes this variable distinguished and appear in the results.

Specified by:
addResultVar in interface Query
Parameters:
var - Variable

addPattern

public void addPattern(QueryPattern pattern)
Specified by:
addPattern in interface Query

addPattern

public void addPattern(int index,
                       QueryPattern pattern)

addTypePattern

public void addTypePattern(aterm.ATermAppl ind,
                           aterm.ATermAppl c)
Specified by:
addTypePattern in interface Query

addEdgePattern

public void addEdgePattern(aterm.ATermAppl s,
                           aterm.ATermAppl p,
                           aterm.ATermAppl o)
Specified by:
addEdgePattern in interface Query

insertEdgePattern

public void insertEdgePattern(aterm.ATermAppl s,
                              aterm.ATermAppl p,
                              aterm.ATermAppl o)

removePattern

public void removePattern(QueryPattern pattern)
Specified by:
removePattern in interface Query

addConstraint

public void addConstraint(aterm.ATermAppl lit,
                          Datatype dt)
Specified by:
addConstraint in interface Query

getVars

public java.util.Set getVars()
Description copied from interface: Query
Return all the variables used in this query.

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

getObjVars

public java.util.Set getObjVars()
Description copied from interface: Query
Return all the object variables, i.e. variables that will be replaced with individual names.

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

getLitVars

public java.util.Set getLitVars()
Description copied from interface: Query
Return all the literal variables, i.e. variables that will be replaced with data values.

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

getConstants

public java.util.Set getConstants()
Description copied from interface: Query
Return all the (individual) constants used in this query.

Specified by:
getConstants in interface Query
Returns:

getResultVars

public java.util.List getResultVars()
Description copied from interface: Query
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

getDistVars

public java.util.Set getDistVars()
Description copied from interface: Query
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

getDistObjVars

public java.util.Set getDistObjVars()
Description copied from interface: Query
Return the distinguished object variables.

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

getDistLitVars

public java.util.Set getDistLitVars()
Description copied from interface: Query
Return the distinguished literal variables.

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

getQueryPatterns

public java.util.List getQueryPatterns()
Description copied from interface: Query
Return all the query patterns in this query.

Specified by:
getQueryPatterns in interface Query
Returns:
List of QueryPatterns

rollUpTo

public aterm.ATermAppl rollUpTo(aterm.ATermAppl var)
Specified by:
rollUpTo in interface Query

getKB

public KnowledgeBase getKB()
Description copied from interface: Query
The KB that will be used to answer this query.

Specified by:
getKB in interface Query
Returns:

apply

public Query apply(QueryResultBinding binding)
Description copied from interface: Query
Replace the variables in the query with the values specified in the binding and return a new query instance.

Specified by:
apply in interface Query
Returns:

isGround

public boolean isGround()
Description copied from interface: Query
Returns true if there are not variables in the query (only constants).

Specified by:
isGround in interface Query
Returns:

findPatterns

public java.util.List findPatterns(aterm.ATermAppl subj,
                                   aterm.ATermAppl pred,
                                   aterm.ATermAppl obj)
Description copied from interface: Query
Find edges in the query graph that matches the pattern (where null matches anything)

Specified by:
findPatterns in interface Query
Returns:

getClasses

public aterm.ATermList getClasses(aterm.ATermAppl term)
Specified by:
getClasses in interface Query

getDatatype

public Datatype getDatatype(aterm.ATermAppl term)
Specified by:
getDatatype in interface Query

reorder

public Query reorder(int[] ordering)
Description copied from interface: Query
Reorder the patterns in the query with respect to given ordering. In the new query, the pattern at position i will be the pattern ordering[i] from the previous query.

Specified by:
reorder in interface Query
Returns:

prepare

public void prepare()
Specified by:
prepare in interface Query

printName

public void printName(aterm.ATermAppl term,
                      java.lang.StringBuffer sb)

toString

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

toString

public java.lang.String toString(boolean multiLine)
Specified by:
toString in interface Query

hasUndefinedPredicate

public boolean hasUndefinedPredicate()
Specified by:
hasUndefinedPredicate in interface Query

setHasUndefinedPredicate

public void setHasUndefinedPredicate(boolean hasUndefinedPredicate)

isDistinct

public boolean isDistinct()
Description copied from interface: Query
Returns true if no duplicates are wanted in the results.

Specified by:
isDistinct in interface Query
Returns:

setDistinct

public void setDistinct(boolean isDistinct)
Specified by:
setDistinct in interface Query


Copyright © 2004 Evren Sirin. All Rights Reserved.