Algernon Software

org.algernon.kb.okbc.protege
Class AlgernonProtegeClass

java.lang.Object
  extended byorg.jatha.dynatype.StandardLispValue
      extended byorg.algernon.kb.okbc.protege.AlgernonProtegeObject
          extended byorg.algernon.kb.okbc.protege.AlgernonProtegeFrame
              extended byorg.algernon.kb.okbc.protege.AlgernonProtegeClass
All Implemented Interfaces:
AlgernonClass, AlgernonFrame, AlgernonObject, Comparable, Displayable, LispValue

public class AlgernonProtegeClass
extends AlgernonProtegeFrame
implements AlgernonClass

This defines an interface for an AlgernonProtegeKB.


Field Summary
 
Fields inherited from class org.algernon.kb.okbc.protege.AlgernonProtegeFrame
m_frame, m_kb
 
Fields inherited from class org.algernon.kb.okbc.protege.AlgernonProtegeObject
f_algy
 
Fields inherited from class org.jatha.dynatype.StandardLispValue
f_lisp
 
Constructor Summary
AlgernonProtegeClass(AlgernonProtegeKB kb, Cls theClass)
           
AlgernonProtegeClass(AlgernonProtegeKB kb, String name, AlgernonClass superclass, AlgernonClass metaClass)
          Creates a new class in Protege, using the metaclass of the given superclass if the metaclass is null.
 
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.
 AlgernonInstance createInstanceAux(String name, int counter)
          auxiliary function to handle duplicate name problems.
 Collection getDirectInstances()
           
 Collection getDirectSubclasses()
           
 Collection getDirectSuperclasses()
           
private  Facet getFacet(Slot slot, String name)
           
 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)
          Returns the definition of the slot that is visible on this class.
 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 class org.algernon.kb.okbc.protege.AlgernonProtegeFrame
addRelationValue, deleteAllRelationValues, deleteRelationValue, deleteRelationValues, display, getDisplayName, getImplementation, getKB, getName, getOwnRelationValues, getParents, getPossibleRelationValues, getRelationValues, getRootClasses, getSuperclasses, hasParent, hasRootClass, hasSuperclass, setDisplayName, setName, toString
 
Methods inherited from class org.algernon.kb.okbc.protege.AlgernonProtegeObject
getAlgernon
 
Methods inherited from class org.jatha.dynatype.StandardLispValue
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_consp, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_listp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, butlast, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, eighth, elt, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_prin1, internal_princ_as_cdr, internal_princ, internal_print_as_cdr, internal_print, iterator, keywordp, last, length, lessThan, lessThanOrEqual, lisp_null, list, listp, max, member, min, multiply, nconc, negate, neql, ninth, nreverse, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, pop, position, prin1, princ, print, push, radiansToDegrees, rassoc, reciprocal, remhash, remove, rest, reverse, rplaca, rplacd, sec, second, set_special, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, type_of, typep, zerop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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
 

Constructor Detail

AlgernonProtegeClass

public AlgernonProtegeClass(AlgernonProtegeKB kb,
                            String name,
                            AlgernonClass superclass,
                            AlgernonClass metaClass)
                     throws AlgernonRuntimeException
Creates a new class in Protege, using the metaclass of the given superclass if the metaclass is null.


AlgernonProtegeClass

public AlgernonProtegeClass(AlgernonProtegeKB kb,
                            Cls theClass)
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.

Specified by:
createInstance in interface AlgernonClass

createInstanceAux

public AlgernonInstance createInstanceAux(String name,
                                          int counter)
auxiliary function to handle duplicate name problems.


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.

Specified by:
createInstance in interface AlgernonClass
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.

Specified by:
addRelation in interface AlgernonClass

getInstances

public Collection getInstances()
Specified by:
getInstances in interface AlgernonClass

getDirectInstances

public Collection getDirectInstances()
Specified by:
getDirectInstances in interface AlgernonClass

getDirectSuperclasses

public Collection getDirectSuperclasses()
Specified by:
getDirectSuperclasses in interface AlgernonClass

getDirectSubclasses

public Collection getDirectSubclasses()
Specified by:
getDirectSubclasses in interface AlgernonClass

getSubclasses

public Collection getSubclasses()
Specified by:
getSubclasses in interface AlgernonClass

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. Calls Cls.getTemplateSlots.

Specified by:
getTemplateRelations in interface AlgernonClass

hasDirectInstance

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

Specified by:
hasDirectInstance in interface AlgernonClass
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 implementation calls hasType() on the instance rather than the mirror method.

Specified by:
hasInstance in interface AlgernonClass
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.

Specified by:
hasDirectSuperclass in interface AlgernonClass
Parameters:
theClass - the superclass to check
Returns:
true if the superclass is a direct superclass of this class, false otherwise.

getLeafSubclasses

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

Specified by:
getLeafSubclasses in interface AlgernonClass
Returns:
a collection of AlgernonClass objects.

hasLeafSubclass

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

Specified by:
hasLeafSubclass in interface AlgernonClass

isLeafClass

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

Specified by:
isLeafClass in interface AlgernonClass

isRootClass

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

Specified by:
isRootClass in interface AlgernonClass

lookupRelation

public AlgernonRelation lookupRelation(String name)
Returns the definition of the slot that is visible on this class.

Specified by:
lookupRelation in interface AlgernonClass
Parameters:
name -
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.

Specified by:
getRelationArgumentTypes in interface AlgernonClass
Parameters:
relation -
Returns:
A List of argument types, same as for AlgernonRelation.getArgumentTypes
Throws:
AlgernonDataException

getFacet

private Facet getFacet(Slot slot,
                       String name)

setRelationRange

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

Specified by:
setRelationRange in interface AlgernonClass
Parameters:
relation -
theClass -

setRelationRange

public void setRelationRange(AlgernonRelation relation,
                             LispValue valueType)
Description copied from interface: AlgernonClass
Sets the range of a relation as defined on this class.

Specified by:
setRelationRange in interface AlgernonClass
Parameters:
relation -
valueType -

setRelationMinCardinality

public void setRelationMinCardinality(AlgernonRelation relation,
                                      Integer minCardinality)
Description copied from interface: AlgernonClass
Sets the minimum cardinality of a relation as defined on this class.

Specified by:
setRelationMinCardinality in interface AlgernonClass
Parameters:
relation -
minCardinality -

setRelationMaxCardinality

public void setRelationMaxCardinality(AlgernonRelation relation,
                                      Integer maxCardinality)
Description copied from interface: AlgernonClass
Sets the maximum cardinality of a relation as defined on this class.

Specified by:
setRelationMaxCardinality in interface AlgernonClass
Parameters:
relation -
maxCardinality -

setRelationDefaultValue

public void setRelationDefaultValue(AlgernonRelation relation,
                                    Object defaultValue)
Description copied from interface: AlgernonClass
Sets the default value of a relation as defined on this class.

Specified by:
setRelationDefaultValue in interface AlgernonClass
Parameters:
relation -
defaultValue -

setRelationInverseRelation

public void setRelationInverseRelation(AlgernonRelation relation,
                                       AlgernonRelation inverseRelation)
Description copied from interface: AlgernonClass
Sets the inverse relation of a relation as defined on this class.

Specified by:
setRelationInverseRelation in interface AlgernonClass
Parameters:
relation -
inverseRelation -

hasTemplateRelation

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

Specified by:
hasTemplateRelation in interface AlgernonClass
Parameters:
relation -
Returns:
a boolean value

Algernon Software