Algernon Software

org.algernon.kb
Class AlgernonKBSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byorg.algernon.kb.AlgernonKBSet
All Implemented Interfaces:
Cloneable, Collection, List, RandomAccess, Serializable

public class AlgernonKBSet
extends ArrayList

AlgernonKBSet is a class that contains a list of KBs and implements methods to be performed on them.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
static String DEFAULT_IMPORTANT_SUPERSET_SLOTNAME
           
protected  Algernon m_algernon
           
protected  String m_name
           
static String UNNAMED
           
 
Fields inherited from class java.util.ArrayList
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
AlgernonKBSet(AlgernonKB kb, Algernon algernon)
           
AlgernonKBSet(String name, Algernon algernon)
           
 
Method Summary
 void addKB(AlgernonKB kb)
          Adds a KB to this KBSet.
 boolean containsClause(Clause queryClause)
          Returns true if the KBSet contains the given clause.
 boolean containsClause(Clause queryClause, int state)
          Returns true if the KBSet contains the given clause.
 AlgernonClass createClass(AlgernonKB kb, LispValue name, AlgernonClass superclass)
          Creates a new class in the given KB.
 AlgernonClass createClass(LispValue name, AlgernonClass superclass)
          Creates a new class in the given KB.
 boolean generalIsa(String child, String parent)
          Returns true if the first argument is an instance or subclass of the second argument.
 boolean generalNotIsa(String child, String parent)
          Returns true if the first argument is not an instance or subclass of the second argument.
 String getImportantSupersetSlotName()
          Returns the name of the slot that represents the relation between a class and a superclass for inheritance purposes.
 AlgernonKB getKB()
          Returns the first KB in the list.
 AlgernonKB getKB(String name)
          returns a KB by its name.
 String getName()
           
 boolean isClassToInstanceRelation(String relationName)
          Returns true if the given string is the name of the relation/slot linking a class to its instance in any KB of this AlgernonKBSet.
 boolean isDisjointRelation(String relationName)
          Returns true if the given string is the name of a relation specifying that two classes are disjoint
 boolean isFrame(String frameName)
          Returns true if the given string is the name of a frame in any KB of this AlgernonKBSet.
 boolean isInstanceToClassRelation(String relationName)
          Returns true if the given string is the name of the relation/slot linking an instance to its class in any KB of this AlgernonKBSet.
 boolean isNameRelation(String relationName)
          Returns true if the given string is the name of the name relation (or attribute) in any KB of this AlgernonKBSet.
 boolean isRelation(String relationName)
          Returns true if the given string is the name of a relation in any KB in the given AlgernonKBSet.
 boolean isSubclassToSuperclassRelation(String relationName)
          Returns true if the given string is the name of the relation/slot linking a frame to its name in any KB in the given AlgernonKBSet.
 boolean isSuperclassToSubclassRelation(String relationName)
          Returns true if the given string is the name of the relation/slot linking a frame to its name in any KB in the given AlgernonKBSet.
 AlgernonClass lookupClass(String name)
          Returns a class with the given name if it can find one in any of the KBs in this KBSet.
 AlgernonFacet lookupFacet(String name)
          Returns a facet with the given name if it can find one in any of the KBs in this KBSet.
 AlgernonFrame lookupFrame(String name)
          Returns a frame with the given name if it can find one in any of the KBs in this KBSet.
 AlgernonInstance lookupInstance(String name)
           
 AlgernonRelation lookupRelation(String name)
          Returns a relation with the given name if it can find one in the given KB.
 AlgernonRelation lookupRelation(String name, Set classes)
          Returns a relation with the given name if it can find one in the given KB.
 void printProfileStatistics()
           
 LispValue query(Clause clause)
          Queries KBs until one of the queries is successful.
 void resetProfiler()
           
 void setName(String newName)
           
 void setProfilerEnabled(boolean state)
           
 LispValue store(Clause clause)
          Stores the clause in the first KB that accepts it.
 boolean supportsNegatedClauses()
          Returns true if any of the KBs in the set support negated clauses.
 LispValue verify(Clause clause)
          Verifies against all of the KBs in the KBSet.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

UNNAMED

public static final String UNNAMED
See Also:
Constant Field Values

m_name

protected String m_name

DEFAULT_IMPORTANT_SUPERSET_SLOTNAME

public static String DEFAULT_IMPORTANT_SUPERSET_SLOTNAME

m_algernon

protected Algernon m_algernon
Constructor Detail

AlgernonKBSet

public AlgernonKBSet(String name,
                     Algernon algernon)

AlgernonKBSet

public AlgernonKBSet(AlgernonKB kb,
                     Algernon algernon)
Method Detail

query

public LispValue query(Clause clause)
                throws AlgernonException
Queries KBs until one of the queries is successful. Returns the value from the first one. If none are successful, returns null.

Throws:
AlgernonException

verify

public LispValue verify(Clause clause)
                 throws AlgernonStorageException,
                        AlgernonDataException
Verifies against all of the KBs in the KBSet. Returns the first non-null result.

Throws:
AlgernonStorageException
AlgernonDataException

store

public LispValue store(Clause clause)
                throws AlgernonStorageException,
                       AlgernonDataException
Stores the clause in the first KB that accepts it. Returns null if none do.

Throws:
AlgernonStorageException
AlgernonDataException

getImportantSupersetSlotName

public String getImportantSupersetSlotName()
Returns the name of the slot that represents the relation between a class and a superclass for inheritance purposes. What if it isn't consistent across KBs in the set??


getKB

public AlgernonKB getKB(String name)
returns a KB by its name. Case is ignored. Returns null if none exists by that name.


getKB

public AlgernonKB getKB()
Returns the first KB in the list. This may not correspond to insertion order. Returns null if there are no KBs in this AlgernonKBSet.


resetProfiler

public void resetProfiler()

setProfilerEnabled

public void setProfilerEnabled(boolean state)

printProfileStatistics

public void printProfileStatistics()

getName

public String getName()

setName

public void setName(String newName)

isFrame

public boolean isFrame(String frameName)
                throws AlgernonDataException
Returns true if the given string is the name of a frame in any KB of this AlgernonKBSet.

Throws:
AlgernonDataException

isRelation

public boolean isRelation(String relationName)
                   throws AlgernonDataException
Returns true if the given string is the name of a relation in any KB in the given AlgernonKBSet.

Throws:
AlgernonDataException

isDisjointRelation

public boolean isDisjointRelation(String relationName)
Returns true if the given string is the name of a relation specifying that two classes are disjoint


isNameRelation

public boolean isNameRelation(String relationName)
                       throws AlgernonDataException
Returns true if the given string is the name of the name relation (or attribute) in any KB of this AlgernonKBSet.

Throws:
AlgernonDataException

isInstanceToClassRelation

public boolean isInstanceToClassRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking an instance to its class in any KB of this AlgernonKBSet.


isClassToInstanceRelation

public boolean isClassToInstanceRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking a class to its instance in any KB of this AlgernonKBSet.


isSubclassToSuperclassRelation

public boolean isSubclassToSuperclassRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking a frame to its name in any KB in the given AlgernonKBSet.


isSuperclassToSubclassRelation

public boolean isSuperclassToSubclassRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking a frame to its name in any KB in the given AlgernonKBSet.


generalIsa

public boolean generalIsa(String child,
                          String parent)
                   throws AlgernonDataException
Returns true if the first argument is an instance or subclass of the second argument. Both arguments must be frames. Checks all KBs in this AlgernonKBSet.

Throws:
AlgernonDataException

generalNotIsa

public boolean generalNotIsa(String child,
                             String parent)
                      throws AlgernonDataException
Returns true if the first argument is not an instance or subclass of the second argument. Both arguments must be frames. Checks all KBs in this AlgernonKBSet.

Throws:
AlgernonDataException

addKB

public void addKB(AlgernonKB kb)
Adds a KB to this KBSet.


createClass

public AlgernonClass createClass(LispValue name,
                                 AlgernonClass superclass)
                          throws AlgernonRuntimeException
Creates a new class in the given KB.

Throws:
AlgernonRuntimeException

createClass

public AlgernonClass createClass(AlgernonKB kb,
                                 LispValue name,
                                 AlgernonClass superclass)
                          throws AlgernonRuntimeException
Creates a new class in the given KB.

Throws:
AlgernonRuntimeException

lookupClass

public AlgernonClass lookupClass(String name)
                          throws AlgernonDataException
Returns a class with the given name if it can find one in any of the KBs in this KBSet. Otherwise returns null.

Throws:
AlgernonDataException

lookupFrame

public AlgernonFrame lookupFrame(String name)
                          throws AlgernonDataException
Returns a frame with the given name if it can find one in any of the KBs in this KBSet. Otherwise returns null.

Throws:
AlgernonDataException

lookupFacet

public AlgernonFacet lookupFacet(String name)
                          throws AlgernonDataException
Returns a facet with the given name if it can find one in any of the KBs in this KBSet. Otherwise returns null.

Throws:
AlgernonDataException

lookupRelation

public AlgernonRelation lookupRelation(String name)
                                throws AlgernonDataException
Returns a relation with the given name if it can find one in the given KB. Otherwise returns null.

Throws:
AlgernonDataException

lookupRelation

public AlgernonRelation lookupRelation(String name,
                                       Set classes)
                                throws AlgernonDataException
Returns a relation with the given name if it can find one in the given KB. Otherwise returns null. The parameter classes may be null or empty, in which case the general relation will be returned, not the specific relation on the class.

Parameters:
name - The name of the relation.
classes - A list of classes where the program will look for a relation, before just finding the relation as defined for the whole KB.
Throws:
AlgernonDataException

lookupInstance

public AlgernonInstance lookupInstance(String name)
                                throws AlgernonDataException
Throws:
AlgernonDataException

containsClause

public boolean containsClause(Clause queryClause)
                       throws AlgernonDataException
Returns true if the KBSet contains the given clause.

Parameters:
queryClause -
Throws:
AlgernonDataException

containsClause

public boolean containsClause(Clause queryClause,
                              int state)
                       throws AlgernonDataException
Returns true if the KBSet contains the given clause.

Parameters:
queryClause -
Throws:
AlgernonDataException

supportsNegatedClauses

public boolean supportsNegatedClauses()
Returns true if any of the KBs in the set support negated clauses.


Algernon Software