jade.onto
Class DefaultOntology

java.lang.Object
  |
  +--jade.onto.DefaultOntology

public final class DefaultOntology
extends java.lang.Object
implements Ontology

A simple implementation of the Ontology interface. Instances of this class keeps all the ontology data in memory, and don't support an external archive format.

Author:
Giovanni Rimassa - Universita` di Parma

Constructor Summary
DefaultOntology()
          Default constructor.
 
Method Summary
 void addRole(java.lang.String roleName, SlotDescriptor[] slots)
          Adds a new role to this ontology, without a user defined Java class to represent it.
 void addRole(java.lang.String roleName, SlotDescriptor[] slots, RoleEntityFactory ref)
          Adds a new role to this ontology, with a user defined Java class to represent it.
 void check(Frame f)
          Checks whether a given frame is correct with respect to this ontology.
 void check(java.lang.Object o, java.lang.String roleName)
          Checks whether a given Java object is correct with respect to the given role in this ontology.
 Frame createFrame(java.lang.Object o, java.lang.String roleName)
          Creates a frame from a given Java Object representing an instance of a given role.
 java.util.List createObject(java.util.List v)
          Creates a List of Java objects from the given list of frame.
 RoleEntityFactory getFactory(java.lang.String roleName)
          Returns the factory for instances of the user defined class representing a given role
 java.lang.String getRoleName(java.lang.Class c)
           
 SlotDescriptor[] getSlots(java.lang.String roleName)
          Get the descriptions for all the slots that define the structure of a given ontological role.
 java.util.List getVocabulary()
           
 boolean isRole(java.lang.String roleName)
          Checks whether a given string is the name of a role in this ontology.
 void joinOntology(Ontology o)
          Adds to this ontology all roles included into another ontology
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultOntology

public DefaultOntology()
Default constructor.
Method Detail

addRole

public void addRole(java.lang.String roleName,
                    SlotDescriptor[] slots)
             throws OntologyException
Adds a new role to this ontology, without a user defined Java class to represent it.
Specified by:
addRole in interface Ontology
See Also:
Ontology.addRole(String roleName, SlotDescriptor[] slots)

addRole

public void addRole(java.lang.String roleName,
                    SlotDescriptor[] slots,
                    RoleEntityFactory ref)
             throws OntologyException
Adds a new role to this ontology, with a user defined Java class to represent it.
Specified by:
addRole in interface Ontology
See Also:
Ontology.addRole(String roleName, SlotDescriptor[] slots, RoleEntityFactory ref)

joinOntology

public void joinOntology(Ontology o)
                  throws OntologyException
Adds to this ontology all roles included into another ontology
Specified by:
joinOntology in interface Ontology
Parameters:
o - The Ontology object whose roles will be added
See Also:
Ontology.joinOntology(Ontology o)

createObject

public java.util.List createObject(java.util.List v)
                            throws OntologyException
Creates a List of Java objects from the given list of frame.
Specified by:
createObject in interface Ontology
See Also:
Ontology.createObject(List v)

createFrame

public Frame createFrame(java.lang.Object o,
                         java.lang.String roleName)
                  throws OntologyException
Creates a frame from a given Java Object representing an instance of a given role.
Specified by:
createFrame in interface Ontology
See Also:
Ontology.createFrame(Object o, String roleName)

check

public void check(Frame f)
           throws OntologyException
Checks whether a given frame is correct with respect to this ontology.
Specified by:
check in interface Ontology
See Also:
Ontology.check(Frame f)

check

public void check(java.lang.Object o,
                  java.lang.String roleName)
           throws OntologyException
Checks whether a given Java object is correct with respect to the given role in this ontology.
Specified by:
check in interface Ontology
See Also:
Ontology.check(Object o, String roleName)

isRole

public boolean isRole(java.lang.String roleName)
               throws OntologyException
Checks whether a given string is the name of a role in this ontology.
Specified by:
isRole in interface Ontology
See Also:
Ontology.isRole(String roleName)

getSlots

public SlotDescriptor[] getSlots(java.lang.String roleName)
                          throws OntologyException
Get the descriptions for all the slots that define the structure of a given ontological role.
Specified by:
getSlots in interface Ontology
See Also:
Ontology.getSlots(String roleName)

getRoleName

public java.lang.String getRoleName(java.lang.Class c)
                             throws OntologyException
Specified by:
getRoleName in interface Ontology
Returns:
the name of the role represented by the passed class as registered in this ontology
Throws:
OntologyException - if no role is found for this class
See Also:
Ontology.getRoleName(Class c)

getVocabulary

public java.util.List getVocabulary()
Specified by:
getVocabulary in interface Ontology
Returns:
a List including the names of all the roles in the ontology, i.e. the Vocabulary used by the ontology
See Also:
Ontology.getVocabulary()

getFactory

public RoleEntityFactory getFactory(java.lang.String roleName)
                             throws OntologyException
Returns the factory for instances of the user defined class representing a given role
Specified by:
getFactory in interface Ontology
Parameters:
roleName - The name of the ontological role.
Returns:
the factory for instances of the user defined class representing a given role
Throws:
OntologyException - if no role is found with the specified name or if a factory is not registered for the role
See Also:
Ontology.getFactory(String roleName)