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)
           
 
Method Summary
 void addConstraint(aterm.ATermAppl lit, Datatype dt)
           
 void addDistVar(aterm.ATermAppl var)
          Add a distiguished 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 var to the query whihc 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, i.e. variables that will be bound to individuals (or data values).
 KnowledgeBase getKB()
          The KB that will be used to answer this query.
 java.util.Set getLitVars()
          Return all the literal variables, i.e. variables that will be replaced with data values.
 java.util.Set getObjVars()
          Return all the object variables, i.e. variables that will be replaced with individual names.
 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.
 void insertEdgePattern(aterm.ATermAppl s, aterm.ATermAppl p, aterm.ATermAppl o)
           
 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)
           
 aterm.ATermAppl rollUpTo(aterm.ATermAppl var)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryImpl

public QueryImpl(KnowledgeBase kb)
Method Detail

addDistVar

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

Specified by:
addDistVar in interface Query

addResultVar

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

Specified by:
addResultVar in interface Query

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)

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:

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:

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:

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 RDQL, these are the variables in the SELECT clause.

Specified by:
getResultVars in interface Query
Returns:

getDistVars

public java.util.Set getDistVars()
Description copied from interface: Query
Return all the distinguished variables, i.e. variables that will be bound to individuals (or data values). Normally, this is supposed to be equal to the result vars but sometimes variables not in the result may be forced to be distinguished. For example, in the query
 SELECT ?y WHERE (?x p ?y) AND (?y langEq "en") 
 
?x is not a result var but it is a distinguised variable because there is no other way for an individual to have a property value with a language tag if that value does not already exist in the ABox.

Specified by:
getDistVars in interface Query
Returns:

getDistObjVars

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

Specified by:
getDistObjVars in interface Query
Returns:

getDistLitVars

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

Specified by:
getDistLitVars in interface Query
Returns:

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:

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

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


Copyright © 2007-2009 Natalya Keberle. All Rights Reserved.