org.ceryle.tm
Class InferencerImpl

java.lang.Object
  extended by org.ceryle.tm.InferencerImpl
All Implemented Interfaces:
Inferencer

public class InferencerImpl
extends Object
implements Inferencer

Implements the inferencing API for topic map constructs. The TopicMap used for each method is obtained from its first parameter. In instances where the the parameters of the method must come from the same TopicMap object, an exception is thrown.

Copyright 2001-2007 Murray Altheim. All Rights Reserved.

Since:
JDK1.4
Version:
$Id: InferencerImpl.java,v 3.7 2007-06-15 12:09:32 altheim Exp $
Author:
Murray Altheim
See Also:
Inferencer

Field Summary
protected  TopicMap map
          The TopicMap used temporarily by this Inferencer (on a method-by-method basis).
protected  MessageHandler mh
           
protected  Services srvs
           
protected  TopicMapProcessor tmproc
          The TopicMapProcessor used by this Inferencer.
 
Fields inherited from interface org.ceryle.tm.Inferencer
LOGIC_PSI, PSI_false, PSI_true
 
Constructor Summary
InferencerImpl()
          Default constructor.
 
Method Summary
 Set getClasses(Topic topic)
          Returns a Set containing the classes to which the Topic topic is a direct instance.
 Set getInstances(Topic topic)
          Returns a Set containing the instances of the class Topic topic.
 Set getSubclasses(Topic topic)
          Returns a Set containing the subclasses of the Topic topic.
 Set getSuperclasses(Topic topic)
          Returns a Set containing the superclasses of the Topic topic.
 Association instanceOf(Topic instance, Topic classTopic)
          Creates Topic instance as an instance of the class Topic classTopic, adding it to the topic map as a new Association.
 boolean isClass(Topic topic)
          Returns true if Topic topic plays the role of class in any class-instance associations.
 boolean isClassInstance(Association assoc)
          Returns true if Association assoc is an instance of a class-instance association.
 boolean isClassOf(Topic classTopic, Topic instance, boolean proper)
          Returns true if Topic classTopic is a class for which Topic instance is an instance.
 boolean isInstance(Topic topic)
          Returns true if Topic topic plays the role of instance in any class-instance associations.
 boolean isInstanceOf(Topic instance, Topic classTopic, boolean proper)
          Returns true if Topic instance is an instance of Topic classTopic.
 boolean isMemberOf(Topic topic, Association assoc)
          Returns true if the Topic topic is a Member of Association assoc, regardless of role or type.
 boolean isSubclass(Topic topic)
          Returns true if Topic topic plays the role of subclass in any superclass-subclass associations.
 boolean isSubclassOf(Topic subclass, Topic superclass, boolean proper)
          Returns true if Topic subclass is a subclass of Topic superclass.
 boolean isSuperclass(Topic topic)
          Returns true if Topic topic plays the role of superclass in any superclass-subclass associations.
 boolean isSuperclassOf(Topic superclass, Topic subclass, boolean proper)
          Returns true if Topic superclass is a superclass of Topic subclass.
 boolean isSuperclassSubclass(Association assoc)
          Returns true if Association assoc is an instance of a superclass-subclass association.
 boolean playsRoleInAssociation(Topic topic, Topic rolespec, Topic type)
          Returns true if the Topic topic plays the role of rolespec in any Associations of Topic type.
 boolean playsRoleOfClassIn(Topic topic, Association assoc)
          Returns true if Topic topic plays the role of 'class' in Association assoc, which must be a class-instance association.
 boolean playsRoleOfInstanceIn(Topic topic, Association assoc)
          Returns true if Topic topic plays the role of 'instance' in Association assoc, which must be a class-instance association.
 boolean playsRoleOfSubclassIn(Topic topic, Association assoc)
          Returns true if Topic topic plays the role of 'subclass' in Association assoc, which must be a superclass-subclass association.
 boolean playsRoleOfSuperclassIn(Topic topic, Association assoc)
          Returns true if Topic topic plays the role of 'superclass' in Association assoc, which must be a superclass-subclass association.
protected  void setTopicMap(TopicMapObject o)
          Sets the TopicMap used for internal operations.
 Association subclassOf(Topic subclass, Topic superclass)
          Creates Topic subclass as a subclass of Topic superclass, adding it to the topic map as a new Association.
 String truthValue(boolean value)
          Converts from a Java boolean value to the Ceryle PSIs for true and false.
 boolean truthValue(String uri)
          Converts from the Ceryle PSIs for true and false to a Java boolean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected TopicMap map
The TopicMap used temporarily by this Inferencer (on a method-by-method basis).


tmproc

protected TopicMapProcessor tmproc
The TopicMapProcessor used by this Inferencer.


mh

protected MessageHandler mh

srvs

protected Services srvs
Constructor Detail

InferencerImpl

public InferencerImpl()
Default constructor.

Method Detail

setTopicMap

protected void setTopicMap(TopicMapObject o)
                    throws TopicMapException
Sets the TopicMap used for internal operations. This potentially changes with each method call, and is only used as a convenience.

Throws:
TopicMapException

truthValue

public boolean truthValue(String uri)
                   throws InferenceException
Converts from the Ceryle PSIs for true and false to a Java boolean. This is a simple String match.

Specified by:
truthValue in interface Inferencer
Throws:
InferenceException - if the URI is not recognized

truthValue

public String truthValue(boolean value)
Converts from a Java boolean value to the Ceryle PSIs for true and false.

Specified by:
truthValue in interface Inferencer

isClass

public boolean isClass(Topic topic)
                throws InferenceException
Returns true if Topic topic plays the role of class in any class-instance associations.

Specified by:
isClass in interface Inferencer
Throws:
InferenceException

isInstance

public boolean isInstance(Topic topic)
                   throws InferenceException
Returns true if Topic topic plays the role of instance in any class-instance associations.

Specified by:
isInstance in interface Inferencer
Throws:
InferenceException

isSuperclass

public boolean isSuperclass(Topic topic)
                     throws InferenceException
Returns true if Topic topic plays the role of superclass in any superclass-subclass associations.

Specified by:
isSuperclass in interface Inferencer
Throws:
InferenceException

isSubclass

public boolean isSubclass(Topic topic)
                   throws InferenceException
Returns true if Topic topic plays the role of subclass in any superclass-subclass associations.

Specified by:
isSubclass in interface Inferencer
Throws:
InferenceException

isClassInstance

public boolean isClassInstance(Association assoc)
                        throws InferenceException
Returns true if Association assoc is an instance of a class-instance association.

This uses XTM's PSI class-instance to identify the association type.

Specified by:
isClassInstance in interface Inferencer
Throws:
InferenceException

isSuperclassSubclass

public boolean isSuperclassSubclass(Association assoc)
                             throws InferenceException
Returns true if Association assoc is an instance of a superclass-subclass association.

This uses XTM's PSI superclass-subclass to identify the association type.

Specified by:
isSuperclassSubclass in interface Inferencer
Throws:
InferenceException

isMemberOf

public boolean isMemberOf(Topic topic,
                          Association assoc)
Returns true if the Topic topic is a Member of Association assoc, regardless of role or type.

Specified by:
isMemberOf in interface Inferencer

playsRoleOfClassIn

public boolean playsRoleOfClassIn(Topic topic,
                                  Association assoc)
                           throws InferenceException
Returns true if Topic topic plays the role of 'class' in Association assoc, which must be a class-instance association.

Specified by:
playsRoleOfClassIn in interface Inferencer
Throws:
InferenceException - if the Association is of the wrong type

playsRoleOfInstanceIn

public boolean playsRoleOfInstanceIn(Topic topic,
                                     Association assoc)
                              throws InferenceException
Returns true if Topic topic plays the role of 'instance' in Association assoc, which must be a class-instance association.

Specified by:
playsRoleOfInstanceIn in interface Inferencer
Throws:
InferenceException - if the Association is of the wrong type

playsRoleOfSuperclassIn

public boolean playsRoleOfSuperclassIn(Topic topic,
                                       Association assoc)
                                throws InferenceException
Returns true if Topic topic plays the role of 'superclass' in Association assoc, which must be a superclass-subclass association.

Specified by:
playsRoleOfSuperclassIn in interface Inferencer
Throws:
InferenceException - if the Association is of the wrong type

playsRoleOfSubclassIn

public boolean playsRoleOfSubclassIn(Topic topic,
                                     Association assoc)
                              throws InferenceException
Returns true if Topic topic plays the role of 'subclass' in Association assoc, which must be a superclass-subclass association.

Specified by:
playsRoleOfSubclassIn in interface Inferencer
Throws:
InferenceException - if the Association is of the wrong type

playsRoleInAssociation

public boolean playsRoleInAssociation(Topic topic,
                                      Topic rolespec,
                                      Topic type)
                               throws InferenceException
Returns true if the Topic topic plays the role of rolespec in any Associations of Topic type.

Specified by:
playsRoleInAssociation in interface Inferencer
Throws:
InferenceException - if an error occurs while processing.

isSuperclassOf

public boolean isSuperclassOf(Topic superclass,
                              Topic subclass,
                              boolean proper)
                       throws InferenceException
Returns true if Topic superclass is a superclass of Topic subclass. If the boolean proper is true, only proper (direct) relations return true.

Specified by:
isSuperclassOf in interface Inferencer
Throws:
InferenceException

isSubclassOf

public boolean isSubclassOf(Topic subclass,
                            Topic superclass,
                            boolean proper)
                     throws InferenceException
Returns true if Topic subclass is a subclass of Topic superclass. If the boolean proper is true, only proper (direct) relations return true.

Specified by:
isSubclassOf in interface Inferencer
Throws:
InferenceException

isClassOf

public boolean isClassOf(Topic classTopic,
                         Topic instance,
                         boolean proper)
                  throws InferenceException
Returns true if Topic classTopic is a class for which Topic instance is an instance. If the boolean proper is false, a traversal of the superclass-subclass hierarchy is done to determine if any of the class Topic's superclasses are in a class-instance association with the instance Topic.

unimplemented

Specified by:
isClassOf in interface Inferencer
Throws:
InferenceException

isInstanceOf

public boolean isInstanceOf(Topic instance,
                            Topic classTopic,
                            boolean proper)
                     throws InferenceException
Returns true if Topic instance is an instance of Topic classTopic. If the boolean proper is false, a traversal of the superclass-subclass hierarchy is done to determine if this is an instance of any of the class Topic's superclasses.

unimplemented

Specified by:
isInstanceOf in interface Inferencer
Throws:
InferenceException

getSuperclasses

public Set getSuperclasses(Topic topic)
                    throws InferenceException
Returns a Set containing the superclasses of the Topic topic.

Specified by:
getSuperclasses in interface Inferencer
Throws:
InferenceException

getSubclasses

public Set getSubclasses(Topic topic)
                  throws InferenceException
Returns a Set containing the subclasses of the Topic topic.

Specified by:
getSubclasses in interface Inferencer
Throws:
InferenceException

getClasses

public Set getClasses(Topic topic)
               throws InferenceException
Returns a Set containing the classes to which the Topic topic is a direct instance.

unimplemented

Specified by:
getClasses in interface Inferencer
Throws:
InferenceException

getInstances

public Set getInstances(Topic topic)
                 throws InferenceException
Returns a Set containing the instances of the class Topic topic.

Specified by:
getInstances in interface Inferencer
Throws:
InferenceException

subclassOf

public Association subclassOf(Topic subclass,
                              Topic superclass)
                       throws InferenceException
Creates Topic subclass as a subclass of Topic superclass, adding it to the topic map as a new Association. If the Association already exists, returns the existing one.

(This is the equivalent of Cyc's #$genls predicate)

unimplemented

Specified by:
subclassOf in interface Inferencer
Throws:
InferenceException

instanceOf

public Association instanceOf(Topic instance,
                              Topic classTopic)
                       throws InferenceException
Creates Topic instance as an instance of the class Topic classTopic, adding it to the topic map as a new Association. If the Association already exists, returns the existing one.

(This is the equivalent of Cyc's #$isa predicate)

unimplemented

Specified by:
instanceOf in interface Inferencer
Throws:
InferenceException


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.