Algernon Software

org.algernon.kb
Interface AlgernonClass

All Superinterfaces:
AlgernonFrame, Displayable
All Known Implementing Classes:
AlgernonProtegeClass

public interface AlgernonClass
extends AlgernonFrame

This defines an interface for an Algernon Class


Method Summary
 void addRelation(AlgernonRelation relation)
          Adds a new relation to this class.
 AlgernonInstance createInstance(String name)
          Creates an instance with the given name.
 AlgernonInstance createInstance(String name, String displayName)
          Creates an instance with the given name and stores the "pretty" name in the display name slot.
 Collection getDirectInstances()
           
 Collection getDirectSubclasses()
           
 Collection getDirectSuperclasses()
           
 Collection getInstances()
           
 Collection getLeafSubclasses()
          Returns a collection of subclasses of this class that are leaves.
 List getRelationArgumentTypes(AlgernonRelation relation)
          Gets the argument types of a relation as defined for that class.
 Collection getSubclasses()
           
 Collection getTemplateRelations()
          Returns the relations that are templates on this class.
 boolean hasDirectInstance(AlgernonInstance instance)
          Returns true if this class includes instance as one of its direct instances.
 boolean hasDirectSuperclass(AlgernonClass theClass)
          Returns true if this class includes superclass as one of its direct superclasses.
 boolean hasInstance(AlgernonInstance instance)
          Returns true if this class includes instance as one of its direct instances, or as a direct instance of one of its subclasses.
 boolean hasLeafSubclass(AlgernonClass leaf)
          Returns true if leaf is a leaf subclass of this class.
 boolean hasTemplateRelation(AlgernonRelation relation)
          Returns true if the given relation is a template relation of this class.
 boolean isLeafClass()
          Returns true if this is one of the leaf classes of the KB.
 boolean isRootClass()
          Returns true if this is one of the root classes of the KB.
 AlgernonRelation lookupRelation(String name)
          Some KBMS support redefining relations (slots) at different classes.
 void setRelationDefaultValue(AlgernonRelation relation, Object defaultValue)
          Sets the default value of a relation as defined on this class.
 void setRelationInverseRelation(AlgernonRelation relation, AlgernonRelation inverseRelation)
          Sets the inverse relation of a relation as defined on this class.
 void setRelationMaxCardinality(AlgernonRelation relation, Integer maxCardinality)
          Sets the maximum cardinality of a relation as defined on this class.
 void setRelationMinCardinality(AlgernonRelation relation, Integer minCardinality)
          Sets the minimum cardinality of a relation as defined on this class.
 void setRelationRange(AlgernonRelation relation, AlgernonClass theClass)
          Sets the range of a relation as defined on this class.
 void setRelationRange(AlgernonRelation relation, LispValue valueType)
          Sets the range of a relation as defined on this class.
 
Methods inherited from interface org.algernon.kb.AlgernonFrame
addRelationValue, deleteAllRelationValues, deleteRelationValue, deleteRelationValues, getDisplayName, getImplementation, getKB, getName, getOwnRelationValues, getParents, getPossibleRelationValues, getRelationValues, getRootClasses, getSuperclasses, hasParent, hasRootClass, hasSuperclass, setDisplayName, setName
 
Methods inherited from interface org.algernon.io.Displayable
display
 

Method Detail

createInstance

public AlgernonInstance createInstance(String name)
Creates an instance with the given name. To also assign a "pretty" name, use the two-argument form of this method.


createInstance

public AlgernonInstance createInstance(String name,
                                       String displayName)
                                throws AlgernonDataException
Creates an instance with the given name and stores the "pretty" name in the display name slot.

Throws:
AlgernonDataException

addRelation

public void addRelation(AlgernonRelation relation)
Adds a new relation to this class. In other words, it sets this class as an allowed domain of the relation.


getInstances

public Collection getInstances()

getDirectInstances

public Collection getDirectInstances()

getDirectSuperclasses

public Collection getDirectSuperclasses()

getDirectSubclasses

public Collection getDirectSubclasses()

getSubclasses

public Collection getSubclasses()

getTemplateRelations

public Collection getTemplateRelations()
Returns the relations that are templates on this class. That is, those that will be assigned to instances of this class. Returns a Collection of objects of type AlgernonRelation.


hasDirectInstance

public boolean hasDirectInstance(AlgernonInstance instance)
Returns true if this class includes instance as one of its direct instances.

Parameters:
instance - the instance to check
Returns:
true if the instance is a direct instance of this class, false otherwise.

hasInstance

public boolean hasInstance(AlgernonInstance instance)
Returns true if this class includes instance as one of its direct instances, or as a direct instance of one of its subclasses. Since it is cheaper to look upward rather than downard, this actuallcalls AlgernonInstance.hasSuperclass to get the answer.

Parameters:
instance - the instance to check
Returns:
true if the instance is an instance of this class, false otherwise.

hasDirectSuperclass

public boolean hasDirectSuperclass(AlgernonClass theClass)
Returns true if this class includes superclass as one of its direct superclasses.

Parameters:
theClass - the superclass to check
Returns:
true if the superclass is a direct superclass of this class, false otherwise.

hasLeafSubclass

public boolean hasLeafSubclass(AlgernonClass leaf)
Returns true if leaf is a leaf subclass of this class.


getLeafSubclasses

public Collection getLeafSubclasses()
Returns a collection of subclasses of this class that are leaves.

Returns:
a collection of AlgernonClass objects.

isRootClass

public boolean isRootClass()
Returns true if this is one of the root classes of the KB.


isLeafClass

public boolean isLeafClass()
Returns true if this is one of the leaf classes of the KB.


lookupRelation

public AlgernonRelation lookupRelation(String name)
Some KBMS support redefining relations (slots) at different classes. This method will look up the relation at a given class, if it exists. If not, it defaults to looking up the relation on the KB.

Parameters:
name - the name of the relation to be found.
Returns:
an instance of AlgernonRelation, or null.

getRelationArgumentTypes

public List getRelationArgumentTypes(AlgernonRelation relation)
                              throws AlgernonDataException
Gets the argument types of a relation as defined for that class.

Parameters:
relation -
Returns:
A List of argument types, same as for AlgernonRelation.getArgumentTypes
Throws:
AlgernonDataException

setRelationRange

public void setRelationRange(AlgernonRelation relation,
                             AlgernonClass theClass)
Sets the range of a relation as defined on this class.

Parameters:
relation -
theClass -

setRelationRange

public void setRelationRange(AlgernonRelation relation,
                             LispValue valueType)
Sets the range of a relation as defined on this class.

Parameters:
relation -
valueType -

setRelationMinCardinality

public void setRelationMinCardinality(AlgernonRelation relation,
                                      Integer minCardinality)
Sets the minimum cardinality of a relation as defined on this class.

Parameters:
relation -
minCardinality -

setRelationMaxCardinality

public void setRelationMaxCardinality(AlgernonRelation relation,
                                      Integer maxCardinality)
Sets the maximum cardinality of a relation as defined on this class.

Parameters:
relation -
maxCardinality -

setRelationDefaultValue

public void setRelationDefaultValue(AlgernonRelation relation,
                                    Object defaultValue)
Sets the default value of a relation as defined on this class.

Parameters:
relation -
defaultValue -

setRelationInverseRelation

public void setRelationInverseRelation(AlgernonRelation relation,
                                       AlgernonRelation inverseRelation)
Sets the inverse relation of a relation as defined on this class.

Parameters:
relation -
inverseRelation -

hasTemplateRelation

public boolean hasTemplateRelation(AlgernonRelation relation)
Returns true if the given relation is a template relation of this class.

Parameters:
relation -
Returns:
a boolean value

Algernon Software