|
Algernon Software | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jatha.dynatype.StandardLispValue
org.algernon.kb.okbc.protege.AlgernonProtegeObject
org.algernon.kb.okbc.protege.AlgernonProtegeKB
Implements a Protege KB for Algernon. This interface adds just a few functions on top of the existing Protege interface.
Field Summary | |
protected AlgernonProtegeRelation |
f_displayNameRelation
|
protected String |
f_displayNameRelationName
|
protected KnowledgeBase |
f_kb
|
protected URI |
f_projectURI
|
protected HashMap |
localCache
|
protected HashMap |
localDisplayNameCache
|
Fields inherited from class org.algernon.kb.okbc.protege.AlgernonProtegeObject |
f_algy |
Fields inherited from class org.jatha.dynatype.StandardLispValue |
f_lisp |
Constructor Summary | |
AlgernonProtegeKB(Algernon algy)
Creates a new in-memory Protege project. |
|
AlgernonProtegeKB(Algernon algy,
KnowledgeBase kb)
Adds a kb that is already open. |
|
AlgernonProtegeKB(Algernon algy,
String projectFileName)
Opens the given Protege project file. |
Method Summary | |
void |
addToCache(Object frameImplementation,
Object algernonFrame)
Adds a pairing of frames to the frame cache. |
void |
addToDisplayNameCache(String displayName,
AlgernonFrame frame)
Adds a mapping from a DisplayName to an AlgernonFrame to the display name frame cache. |
boolean |
canAssignToValueType(Object o,
LispValue vt)
Check if you can assign a Java Object o to a Protege slot having a ValueType vt |
void |
close()
Closes a KB. |
boolean |
containsClause(Clause clause,
int state)
State is Algernon.NEGATED or something else. |
Collection |
convertFromAlgernon(Collection coll)
Converts a collection of Algernon objects to a collection of Protege objects, if possible. |
Object |
convertFromAlgernon(Object obj)
Converts an Algernon object to a Protege object, if possible. |
Collection |
convertToAlgernon(Collection coll)
Converts a collection of Protege objects to a collection of Algernon objects, if possible. |
Object |
convertToAlgernon(Object obj)
Converts a Protege object to a ProtegeAlgernon object, if possible. |
AlgernonClass |
createClass(String frameName,
AlgernonClass superclass)
Creates a new frame in the storage. |
AlgernonClass |
createClass(String frameName,
AlgernonClass superclass,
AlgernonClass metaClass)
Creates a new frame in the storage. |
AlgernonFacet |
createFacet(String facetName)
Creates a new facet in the storage. |
AlgernonInstance |
createInstance(String frameName,
AlgernonClass theClass)
Creates a new instance in the storage. |
AlgernonRelation |
createRelation(String relationName,
LispValue domain,
LispValue range,
Integer minCardinality,
Integer maxCardinality,
Object defaultValue,
AlgernonRelation inverseRelation)
Helper method that creates a set around single domain and range to pass into the actual createRelation method. |
AlgernonRelation |
createRelation(String relationName,
Set domains,
Set ranges,
Integer minCardinality,
Integer maxCardinality,
Object defaultValue,
AlgernonRelation inverseRelation)
Creates a new relation in this KB. |
void |
deleteClass(AlgernonClass frame)
Deletes a frame and all of its relations from storage. |
void |
deleteClauses(Clause clause)
Deletes one or more clauses from the storage. |
void |
deleteClauses(Clause clause,
AlgernonFacet facet)
Deletes one or more clauses from the storage. |
void |
deleteFacet(AlgernonFacet frame)
Deletes a frame and all of its relations from storage. |
void |
deleteFrame(AlgernonFrame frame)
Deletes a frame and all of its relations from storage. |
void |
deleteInstance(AlgernonInstance frame)
Deletes a frame and all of its relations from storage. |
void |
deleteRelation(AlgernonRelation frame)
Deletes a relation from storage. |
Collection |
frameSearch(String searchString)
Performs a string search within the KB for frames whose name contains the given string. |
Collection |
frameSearch(String searchString,
String nameSlot)
Performs a string search within the KB for frames whose name contains the given string. |
Collection |
frameSearch(String searchString,
String nameSlot,
int limit)
Performs a string search within the KB for frames whose name contains the given string. |
boolean |
generalIsa(String child,
String parent)
Returns true if the first argument is an instance or subclass of the second argument in this KB. |
boolean |
generalNotIsa(String child,
String parent)
Returns true if the first argument is not an instance or subclass of the second argument this KB. |
LispValue |
getAllFrames()
Returns a collection of all frames in the KB. |
AlgernonRelation |
getDisplayNameRelation()
Get the actual DisplayName slot. |
String |
getDisplayNameRelationName()
Get the name of the DisplayName slot. |
AlgernonFrame |
getFrame(String name)
Returns a frame with the given name, if any exists. |
AlgernonProtegeObject |
getFromCache(Object frameImplementation)
Retrieves a Algernon-level frame or other value given a KBMS-level object as the key. |
AlgernonFrame |
getFromDisplayNameCache(String displayName)
Retrieves an Algernon frame from its display name. |
Object |
getImplementation()
Returns the KBMS-specific object implementing this interface. |
KnowledgeBase |
getKb()
|
String |
getName()
Returns the name of this KB as a string. |
AlgernonClass |
getRootClass()
Returns a the "first" root class in the KB. |
Collection |
getRootClasses()
Returns a Collection of the root classes of the KB. |
String |
getUserName()
Returns a String containing the name of the current user of this KB. |
LispValue |
getValueType(Object o)
Get the data type of the Java object passed in; we expect this to be Integer, Float, Boolean, Frame, etc., etc |
Collection |
getValueTypes()
Returns a collection of AlgernonValueTypes, listing all the value types the kb knows about |
boolean |
isClass(String frameName)
Returns the Class if the String is the name of a frame that is a class in the KB. |
boolean |
isClassToInstanceRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking a class to its instance in this KB. |
boolean |
isDisjointRelation(String relationName)
Always returns false - Protege has no default disjoint relation. |
boolean |
isFacet(String frameName)
Returns true if the String is the name of a frame that is a facet in the KB. |
boolean |
isFrame(String frameName)
Returns the Frame if the String is the name of a frame in the KB. |
boolean |
isInstance(String frameName)
Returns the Instance if the String is the name of a frame that is an instance in the KB. |
boolean |
isInstanceToClassRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking an instance to its class in this KB. |
boolean |
isNameRelation(String relationName)
Returns true if the string is the name of a NAME relation in this KB. |
boolean |
isRelation(String frameName)
Returns the Relation if the String is the name of a frame that is a relation in the KB. |
boolean |
isSimpleType(AlgernonFrame frame,
AlgernonRelation slot)
Determines if this slot takes an atomic data type value. |
boolean |
isSimpleType(AlgernonRelation relation)
Determines if this slot takes an atomic data type value |
static boolean |
isSimpleType(Frame frame,
Slot slot)
Checks the ValueType of slot AT THE CLASS--returns true if it's simple |
static boolean |
isSimpleType(Slot slot)
|
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. |
AlgernonFrame |
leastCommonSuperclass(AlgernonFrame frame1,
AlgernonFrame frame2)
Returns the most specialized common superclass of the two classes or instances. |
AlgernonClass |
lookupClass(String name)
Returns a class with the given name if it can find one in this KB. |
AlgernonFacet |
lookupFacet(String name)
Returns a frame with the given name if it can find one in this KB. |
AlgernonFrame |
lookupFrame(String name)
Returns a frame with the given name if it can find one in this KB. |
AlgernonInstance |
lookupInstance(String name)
Returns a frame with the given name if it can find one in this KB. |
AlgernonInstance |
lookupInstance(String javaClassName,
String name)
Returns a frame with the given name if it can find one in this KB. |
AlgernonInstance |
lookupInstance(String javaClassName,
String name,
String field)
Returns a frame with the given name if it can find one in this KB. |
AlgernonRelation |
lookupRelation(String name)
Returns a relation with the given name if it can find one in this KB. |
AlgernonRelation |
lookupRelation(String name,
Set classes)
Returns a relation with the given name, if any. |
private boolean |
myContains(Collection values,
LispValue value)
Needed because ArrayList.contains calls Object.equals() for some bizarre reason rather than LispValue.equals. |
protected KnowledgeBase |
openKB(String projectFile)
|
LispValue |
query(Clause clause)
Returns all of the values that match the given clause. |
LispValue |
query(Clause clause,
AlgernonFacet facet)
See the simpler form getValues. |
void |
removeFromCache(Object frameImplementation)
Removes a frame from the cache. |
void |
removeFromDisplayNameCache(String objectName)
Removes it from the display name cache. |
void |
reset()
Resets a KB. |
void |
save()
Saves the kb to a file. |
void |
setDisplayNameRelationName(String relationName)
Sets the name of the relation (slot) used for "pretty names", "common names", "display names" or whatever you want to call it. |
void |
setName(String newName)
Sets the name of the KB. |
LispValue |
store(Clause clause)
Asserts the given clause into the storage. |
LispValue |
store(Clause clause,
AlgernonFacet facet)
Asserts the given clause into the storage. |
boolean |
supportsNegatedClauses()
Returns true if this KB supports negated clauses. |
ValueType |
toValueType(Object range)
Range should be one of the ranges specified in the Algernon class, such as BOOLEAN_TYPE, STRING_TYPE, etc. |
ValueType |
valueOf(LispValue typeName)
Returns the Protege value type for the given named type |
Collection |
valueSearch(String searchString)
Performs a string search within the KB for slot values that contain the given string. |
Collection |
valueSearch(String searchString,
Collection frames,
Collection slots)
Performs a string search within the KB for slot values that contain the given string. |
Collection |
valueSearch(String searchString,
Collection frames,
Collection slots,
int limit)
Performs a string search within the KB for slot values that contain the given string. |
LispValue |
verify(Clause clause)
Verifies that the clause is in the KB. |
Methods inherited from class org.algernon.kb.okbc.protege.AlgernonProtegeObject |
getAlgernon, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected KnowledgeBase f_kb
protected URI f_projectURI
protected String f_displayNameRelationName
protected AlgernonProtegeRelation f_displayNameRelation
protected HashMap localCache
protected HashMap localDisplayNameCache
Constructor Detail |
public AlgernonProtegeKB(Algernon algy)
public AlgernonProtegeKB(Algernon algy, String projectFileName) throws AlgernonStorageException
public AlgernonProtegeKB(Algernon algy, KnowledgeBase kb)
Method Detail |
public Object getImplementation()
getImplementation
in interface AlgernonKB
protected KnowledgeBase openKB(String projectFile) throws AlgernonStorageException
AlgernonStorageException
public void close()
close
in interface AlgernonKB
public void reset() throws AlgernonStorageException
reset
in interface AlgernonKB
AlgernonStorageException
public LispValue getAllFrames()
getAllFrames
in interface AlgernonKB
public KnowledgeBase getKb()
public String getName()
getName
in interface AlgernonKB
getName
in class AlgernonProtegeObject
public void setName(String newName)
setName
in interface AlgernonKB
public LispValue query(Clause clause) throws AlgernonStorageException, AlgernonException
query
in interface AlgernonKB
AlgernonStorageException
AlgernonException
Clause
public LispValue query(Clause clause, AlgernonFacet facet) throws AlgernonStorageException, AlgernonDataException
query
in interface AlgernonKB
AlgernonStorageException
AlgernonDataException
public Collection frameSearch(String searchString) throws AlgernonStorageException
frameSearch
in interface AlgernonKB
searchString
- a string that must be contained in the value
AlgernonStorageException
valueSearch(java.lang.String)
public Collection frameSearch(String searchString, String nameSlot) throws AlgernonStorageException
frameSearch
in interface AlgernonKB
searchString
- a string that must be contained in the valuenameSlot
- an optional slot to be used as the search value. Enter null to use the default slot.
AlgernonStorageException
valueSearch(java.lang.String)
public Collection frameSearch(String searchString, String nameSlot, int limit) throws AlgernonStorageException
frameSearch
in interface AlgernonKB
searchString
- a string that must be contained in the valuenameSlot
- an optional slot to be used as the search value. Enter null to use the default slot.limit
- a limit on the number of frames to return. Use -1 for unlimited.
AlgernonStorageException
valueSearch(java.lang.String)
public Collection valueSearch(String searchString) throws AlgernonStorageException
valueSearch
in interface AlgernonKB
searchString
- a string that must be contained in the value
AlgernonStorageException
frameSearch(java.lang.String)
public Collection valueSearch(String searchString, Collection frames, Collection slots) throws AlgernonStorageException
valueSearch
in interface AlgernonKB
searchString
- a string that must be contained in the valueframes
- an optional Collection of frames or frame names to be searchedslots
- an optional Collection of slots or slot names to be searched
AlgernonStorageException
frameSearch(java.lang.String)
public Collection valueSearch(String searchString, Collection frames, Collection slots, int limit) throws AlgernonStorageException
valueSearch
in interface AlgernonKB
searchString
- a string that must be contained in the valueframes
- an optional Collection of frames or frame names to be searchedslots
- an optional Collection of slots or slot names to be searchedlimit
- a limit on the number of frames to return. Use -1 for unlimited.
AlgernonStorageException
frameSearch(java.lang.String)
public LispValue verify(Clause clause) throws AlgernonStorageException, AlgernonDataException
verify
in interface AlgernonKB
AlgernonStorageException
AlgernonDataException
private boolean myContains(Collection values, LispValue value)
public AlgernonClass getRootClass()
getRootClass
in interface AlgernonKB
public Collection getRootClasses()
getRootClasses
in interface AlgernonKB
public String getUserName()
getUserName
in interface AlgernonKB
public LispValue store(Clause clause) throws AlgernonStorageException, AlgernonDataException
store
in interface AlgernonKB
AlgernonStorageException
AlgernonDataException
public LispValue store(Clause clause, AlgernonFacet facet) throws AlgernonStorageException, AlgernonDataException
NOT YET IMPLEMENTED.
store
in interface AlgernonKB
AlgernonStorageException
AlgernonDataException
public AlgernonClass createClass(String frameName, AlgernonClass superclass) throws AlgernonRuntimeException
createClass
in interface AlgernonKB
AlgernonRuntimeException
public AlgernonClass createClass(String frameName, AlgernonClass superclass, AlgernonClass metaClass) throws AlgernonRuntimeException
createClass
in interface AlgernonKB
AlgernonRuntimeException
public AlgernonFacet createFacet(String facetName)
createFacet
in interface AlgernonKB
public AlgernonInstance createInstance(String frameName, AlgernonClass theClass)
createInstance
in interface AlgernonKB
public AlgernonRelation createRelation(String relationName, LispValue domain, LispValue range, Integer minCardinality, Integer maxCardinality, Object defaultValue, AlgernonRelation inverseRelation) throws AlgernonDataException
createRelation
in interface AlgernonKB
AlgernonDataException
public AlgernonRelation createRelation(String relationName, Set domains, Set ranges, Integer minCardinality, Integer maxCardinality, Object defaultValue, AlgernonRelation inverseRelation) throws AlgernonDataException
createRelation
in interface AlgernonKB
AlgernonDataException
public void deleteClass(AlgernonClass frame) throws AlgernonException
deleteClass
in interface AlgernonKB
AlgernonException
public void deleteFacet(AlgernonFacet frame) throws AlgernonException
deleteFacet
in interface AlgernonKB
AlgernonException
public void deleteFrame(AlgernonFrame frame) throws AlgernonException
deleteFrame
in interface AlgernonKB
AlgernonException
public void deleteInstance(AlgernonInstance frame) throws AlgernonException
deleteInstance
in interface AlgernonKB
AlgernonException
public void deleteRelation(AlgernonRelation frame) throws AlgernonException
deleteRelation
in interface AlgernonKB
AlgernonException
public void deleteClauses(Clause clause)
deleteClauses
in interface AlgernonKB
public void deleteClauses(Clause clause, AlgernonFacet facet)
deleteClauses
in interface AlgernonKB
public boolean isClass(String frameName) throws AlgernonDataException
isClass
in interface AlgernonKB
AlgernonDataException
public boolean isFacet(String frameName) throws AlgernonDataException
isFacet
in interface AlgernonKB
AlgernonDataException
public boolean isInstance(String frameName) throws AlgernonDataException
isInstance
in interface AlgernonKB
AlgernonDataException
public boolean isFrame(String frameName) throws AlgernonDataException
isFrame
in interface AlgernonKB
AlgernonDataException
public boolean isRelation(String frameName) throws AlgernonDataException
isRelation
in interface AlgernonKB
AlgernonDataException
public Collection convertToAlgernon(Collection coll)
convertToAlgernon
in interface AlgernonKB
public Object convertToAlgernon(Object obj)
convertToAlgernon
in interface AlgernonKB
public Collection convertFromAlgernon(Collection coll)
convertFromAlgernon
in interface AlgernonKB
public Object convertFromAlgernon(Object obj)
convertFromAlgernon
in interface AlgernonKB
public Collection getValueTypes()
public ValueType valueOf(LispValue typeName)
valueOf
in interface AlgernonKB
public LispValue getValueType(Object o)
getValueType
in interface AlgernonKB
public boolean canAssignToValueType(Object o, LispValue vt)
canAssignToValueType
in interface AlgernonKB
public static boolean isSimpleType(Slot slot)
public boolean isSimpleType(AlgernonRelation relation)
isSimpleType
in interface AlgernonKB
public static boolean isSimpleType(Frame frame, Slot slot)
public boolean isSimpleType(AlgernonFrame frame, AlgernonRelation slot)
isSimpleType
in interface AlgernonKB
frame
- ignoredslot
- its implementation's value type is checked.public void addToCache(Object frameImplementation, Object algernonFrame)
frameImplementation
- The KBMS-level (e.g. Protege) instancealgernonFrame
- The Algernon equivalent.public AlgernonProtegeObject getFromCache(Object frameImplementation)
frameImplementation
- The KBMS-level (e.g. Protege) instancepublic void removeFromCache(Object frameImplementation)
public void removeFromDisplayNameCache(String objectName)
objectName
- public boolean isNameRelation(String relationName)
isNameRelation
in interface AlgernonKB
public boolean isInstanceToClassRelation(String relationName)
isInstanceToClassRelation
in interface AlgernonKB
public boolean isClassToInstanceRelation(String relationName)
isClassToInstanceRelation
in interface AlgernonKB
public boolean isSubclassToSuperclassRelation(String relationName)
isSubclassToSuperclassRelation
in interface AlgernonKB
public boolean isSuperclassToSubclassRelation(String relationName)
isSuperclassToSubclassRelation
in interface AlgernonKB
public boolean isDisjointRelation(String relationName)
isDisjointRelation
in interface AlgernonKB
public boolean generalIsa(String child, String parent) throws AlgernonDataException
generalIsa
in interface AlgernonKB
AlgernonDataException
public boolean generalNotIsa(String child, String parent)
generalNotIsa
in interface AlgernonKB
public AlgernonClass lookupClass(String name) throws AlgernonDataException
lookupClass
in interface AlgernonKB
AlgernonDataException
public AlgernonFacet lookupFacet(String name) throws AlgernonDataException
lookupFacet
in interface AlgernonKB
AlgernonDataException
public AlgernonFrame lookupFrame(String name) throws AlgernonDataException
lookupFrame
in interface AlgernonKB
AlgernonDataException
public AlgernonInstance lookupInstance(String name) throws AlgernonDataException
lookupInstance
in interface AlgernonKB
AlgernonDataException
public AlgernonInstance lookupInstance(String javaClassName, String name) throws AlgernonDataException
lookupInstance
in interface AlgernonKB
AlgernonDataException
public AlgernonInstance lookupInstance(String javaClassName, String name, String field) throws AlgernonDataException
lookupInstance
in interface AlgernonKB
AlgernonDataException
public AlgernonRelation lookupRelation(String name) throws AlgernonDataException
lookupRelation
in interface AlgernonKB
AlgernonDataException
public AlgernonRelation lookupRelation(String name, Set classes) throws AlgernonDataException
AlgernonKB
lookupRelation
in interface AlgernonKB
AlgernonDataException
public AlgernonFrame getFrame(String name) throws AlgernonDataException
getFrame
in interface AlgernonKB
AlgernonDataException
public AlgernonFrame getFromDisplayNameCache(String displayName)
displayName
- The display name of a frame.AlgernonFrame
,
AlgernonKB
public void addToDisplayNameCache(String displayName, AlgernonFrame frame)
displayName
- The display name of the frame.frame
- The Algernon frame.AlgernonFrame
,
AlgernonKB
public String getDisplayNameRelationName()
getDisplayNameRelationName
in interface AlgernonKB
public AlgernonRelation getDisplayNameRelation() throws AlgernonDataException
getDisplayNameRelation
in interface AlgernonKB
AlgernonDataException
public void setDisplayNameRelationName(String relationName)
setDisplayNameRelationName
in interface AlgernonKB
public void save() throws AlgernonStorageException
save
in interface AlgernonKB
AlgernonStorageException
public boolean supportsNegatedClauses()
AlgernonKB
supportsNegatedClauses
in interface AlgernonKB
public AlgernonFrame leastCommonSuperclass(AlgernonFrame frame1, AlgernonFrame frame2)
leastCommonSuperclass
in interface AlgernonKB
public boolean containsClause(Clause clause, int state) throws AlgernonDataException
containsClause
in interface AlgernonKB
clause
- state
- is Algernon.NEGATED or something else.
AlgernonDataException
public ValueType toValueType(Object range)
range
-
|
Algernon Software | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |