org.activemath.content.mediator.query
Class KBQuery

java.lang.Object
  extended by org.activemath.content.mediator.query.KBQuery
All Implemented Interfaces:
Cloneable

public class KBQuery
extends Object
implements Cloneable

AKBQuery is a Query which knows its KB. A KBQuery can be mapped to the different target ontologies. This is done by the QueryMapper. A KBQuery has queries for Classes, queries for Relation(s) and queries for properties.


Field Summary
protected static boolean DEBUG
           
 
Constructor Summary
KBQuery()
          This constructor creats an empty KBQuery which is needed for gap detection
KBQuery(String querystring)
          This constructor creats a KBQuery out of an incoming String which is in terms of OIO.
KBQuery(String querystring, KBCaller kbCaller)
           
 
Method Summary
 void addClassConstraint(String cl)
           
 void addPropertyConstraint(String prop, String val)
          Adds a new ArrayList representing one propertyConstraint to the propertyConstraint-Set.
 void addRelationConstraint(String relation, String item)
           
 void addToClassConstraints(Set adds)
           
 void addToPropertyConstraints(Set adds)
           
 void changeClassConstraint(String old, String neu)
           
 void changePropertyConstraints(Pattern matchingPattern, Pattern replacementPattern)
           
 void changeRelationConstraints(Set existingRelationTypes, Set replacementRelationTypes)
          Renames all the relationtypes of the relation contraints with respect to both given lists of relationtypes.
 Object clone()
          We need to clone a KBQuery.
 boolean equals(Object obj)
           
 Set getClassConstraints()
           
 KBCaller getKBCaller()
           
 Set getPropertyConstraints()
           
 Set getPropertyConstraints(String propertyName)
           
 KBQuery getRelationClassStub()
          Returns a new Query (not the incoming one!)
 Set getRelationConstraints()
           
 Set getRelationConstraintsTypes()
           
 KBQuery getRelationPropertyStub()
           
 KBQuery getRelationStub()
           
 int hashCode()
           
 boolean hasPropertyConstraint(String propertyName)
           
 boolean isClassConstrained()
           
 boolean isPropertyConstrained()
           
 void removeClassConstraints()
           
 void removeFromClassConstraints(Set removes)
           
 void removeFromPropertyConstraints(Set removes)
           
 void removePropertyConstraints()
           
 void removeRelationConstraint(ArrayList relationConstraint)
           
 void setClassConstraints(Set classConstraints)
           
 void setClassConstraints(String classConstraint)
           
 void setKBCaller(KBCaller kbCaller)
           
 void setPropertyConstraints(Set propertyConstraints)
           
 void setRelationConstraints(Set relationConstraints)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
Constructor Detail

KBQuery

public KBQuery(String querystring)
        throws QueryParseException
This constructor creats a KBQuery out of an incoming String which is in terms of OIO. This method is parsing the incoming String following the EBNF of OIO-queries.

Parameters:
querystring -
Throws:
QueryParseException

KBQuery

public KBQuery()
This constructor creats an empty KBQuery which is needed for gap detection


KBQuery

public KBQuery(String querystring,
               KBCaller kbCaller)
        throws QueryParseException
Throws:
QueryParseException
Method Detail

getKBCaller

public KBCaller getKBCaller()
Returns:
Returns the kbCaller.

setKBCaller

public void setKBCaller(KBCaller kbCaller)
Parameters:
kbCaller - The kbCaller to set.

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
We need to clone a KBQuery. Attention: to avoid shallow-cloning we clone each Field of the KBQuery in this method!

Overrides:
clone in class Object

isClassConstrained

public boolean isClassConstrained()
Returns:

isPropertyConstrained

public boolean isPropertyConstrained()
Returns:

getClassConstraints

public Set getClassConstraints()
Returns:
Returns the classConstraints.

setClassConstraints

public void setClassConstraints(Set classConstraints)

setClassConstraints

public void setClassConstraints(String classConstraint)

changeClassConstraint

public void changeClassConstraint(String old,
                                  String neu)

removeFromClassConstraints

public void removeFromClassConstraints(Set removes)

addToClassConstraints

public void addToClassConstraints(Set adds)

addClassConstraint

public void addClassConstraint(String cl)

setPropertyConstraints

public void setPropertyConstraints(Set propertyConstraints)

hasPropertyConstraint

public boolean hasPropertyConstraint(String propertyName)

getPropertyConstraints

public Set getPropertyConstraints(String propertyName)

removeFromPropertyConstraints

public void removeFromPropertyConstraints(Set removes)

addToPropertyConstraints

public void addToPropertyConstraints(Set adds)

setRelationConstraints

public void setRelationConstraints(Set relationConstraints)

getPropertyConstraints

public Set getPropertyConstraints()
Returns:
Returns the propertyConstraints.

getRelationConstraints

public Set getRelationConstraints()

getRelationConstraintsTypes

public Set getRelationConstraintsTypes()

addPropertyConstraint

public void addPropertyConstraint(String prop,
                                  String val)
Adds a new ArrayList representing one propertyConstraint to the propertyConstraint-Set.

Parameters:
prop - the Property to set
val - the expected value to set

addRelationConstraint

public void addRelationConstraint(String relation,
                                  String item)

changeRelationConstraints

public void changeRelationConstraints(Set existingRelationTypes,
                                      Set replacementRelationTypes)
Renames all the relationtypes of the relation contraints with respect to both given lists of relationtypes. The relationtypes of the first list are replaced with the relationtypes of the second list.

Parameters:
existingRelationTypes -
replacementRelationTypes -

changePropertyConstraints

public void changePropertyConstraints(Pattern matchingPattern,
                                      Pattern replacementPattern)

removeClassConstraints

public void removeClassConstraints()

removePropertyConstraints

public void removePropertyConstraints()

removeRelationConstraint

public void removeRelationConstraint(ArrayList relationConstraint)

getRelationClassStub

public KBQuery getRelationClassStub()
Returns a new Query (not the incoming one!) which is similar to the given one but which has no PropertyConstraints anymore. It returns the Query Stub which only contains the Relation- and the ClassConstraints.
We need these stubs to store parts of results in our cache.

Returns:
a Query stub

getRelationPropertyStub

public KBQuery getRelationPropertyStub()

getRelationStub

public KBQuery getRelationStub()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object