|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsl.DefaultOntology
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.
| Field Summary | |
private java.util.Map |
roleClasses
|
private java.util.Map |
schemas
|
| Fields inherited from interface sl.Ontology |
ANY_SLOT, ANY_TYPE, BINARY_TYPE, BOOLEAN_TYPE, BYTE_TYPE, CHARACTER_TYPE, DATE_TYPE, DOUBLE_TYPE, FLOAT_TYPE, FRAME_SLOT, INTEGER_TYPE, LONG_TYPE, M, NAME_OF_SEQUENCE_FRAME, NAME_OF_SET_FRAME, O, PRIMITIVE_SLOT, SEQUENCE_SLOT, SET_SLOT, SHORT_TYPE, STRING_TYPE |
| 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,
java.lang.Class newClass)
Adds a new role to this ontology, with a user defined Java class to represent it. |
private void |
addSchemaToTable(java.lang.String roleName,
FrameSchema fs)
|
private void |
buildFromObject(Frame f,
FrameSchema fs,
java.lang.Object o,
java.lang.Class theRoleClass)
|
private java.lang.Object |
castPrimitiveValue(java.lang.Object value,
java.lang.String type)
|
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. |
private void |
checkClass(java.lang.String roleName,
java.lang.Class c)
|
private java.lang.Class |
checkGetAndSet(java.lang.String name,
java.lang.Class c)
|
private java.lang.Class |
checkGetAndSet2(java.lang.String name,
java.lang.Class c)
This method checks for correct get and set methods for the current descriptor and retrieves the implementation type. |
java.lang.Object |
create(Frame f)
Creates an object, starting from a given frame. |
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. |
private java.lang.Object |
createSingleObject(Frame f)
|
private java.lang.reflect.Method |
findMethodCaseInsensitive(java.lang.String name,
java.lang.Class c)
|
void |
fromMetaOntologyRepresentation(AnOntology o)
Initialize this ontology based on the passed meta-ontology |
java.lang.String |
fromSL0String(java.lang.String str)
This method initialized this ontology object on the basis of its representation as an SL-0 expression. |
private int |
getArgumentLength(java.lang.reflect.Method m)
|
private java.lang.Class |
getArgumentType(java.lang.reflect.Method m,
int no)
|
java.lang.Class |
getClassForRole(java.lang.String roleName)
Provides the Java class associated with this ontological role. |
private java.lang.Class |
getReturnType(java.lang.reflect.Method m)
|
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()
|
private java.lang.Object |
initObject(Frame f,
java.lang.Object entity,
java.lang.Class theRoleClass)
|
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 |
(package private) FrameSchema |
lookupSchema(java.lang.String name)
|
AnOntology |
toMetaOntologyRepresentation(java.lang.String ontologyName)
Return an object representing this ontology in terms of the JADE-Meta-Ontology and that is suitable to be encoded as a String and, for instance, become the content of an ACLMessage. |
java.lang.String |
toSL0String(java.lang.String ontologyName)
Writes the ontology represented by this Ontology object as an SL-0 expression. |
java.lang.String |
toString()
Return a String representing this ontology Object by calling the method toSL0String() and catching any exception.
|
private java.lang.String |
translateName(java.lang.String name)
if name starts with UNNAMED_PREFIX, it removes it |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private java.util.Map schemas
private java.util.Map roleClasses
| Constructor Detail |
public DefaultOntology()
| Method Detail |
FrameSchema lookupSchema(java.lang.String name)
public void addRole(java.lang.String roleName,
SlotDescriptor[] slots)
throws OntologyException
addRole in interface OntologyroleName - The name of this role (names are case
preserving but the match is case insensitive).slots - An array of descriptors; each one of them describes a
slot of the role, providing:
OntologyExceptionjade.onto.Ontology#addRole(String roleName, SlotDescriptor[] slots)
public void addRole(java.lang.String roleName,
SlotDescriptor[] slots,
java.lang.Class newClass)
throws OntologyException
addRole in interface OntologyroleName - The name of this role (names are case
preserving but the match is case insensitive).slots - An array of descriptors; each one of them describes a
slot of the role, providing:
OntologyExceptionjade.onto.Ontology#addRole(String roleName, SlotDescriptor[] slots, Class c)
public void joinOntology(Ontology o)
throws OntologyException
joinOntology in interface Ontologyo - The Ontology object whose roles will
be added
OntologyExceptionjade.onto.Ontology#joinOntology(Ontology o)
public java.util.List createObject(java.util.List v)
throws OntologyException
createObject in interface Ontologyv - A List of Frame objects,
from which a List of Java objects is built.
List of Java objects,
each Java object corresponding to a Frame and representing an
entity in the domain.
OntologyException - If a Frame does
not represent an instance of any role in the current ontology,
or if the registered class does not follow the rules for representing a role.jade.onto.Ontology#createObject(List v)
private java.lang.Object createSingleObject(Frame f)
throws OntologyException
OntologyException
public Frame createFrame(java.lang.Object o,
java.lang.String roleName)
throws OntologyException
createFrame in interface Ontologyo - The Java object, from which the Frame will
be built.roleName - The name of the role represented in this ontology by
the class of the given object. Note that the role name does not
necessarily coincide with the name of the class representing the role.
For this reason the role name must be explicitly indicated.
Frame object representing an instance of
the given role, built from the given Object.
OntologyException - If the given role does not exist, or
the given object is not of the correct class.jade.onto.Ontology#createFrame(Object o, String roleName)
public void check(Frame f)
throws OntologyException
check in interface Ontologyf - The Frame object to check.
OntologyException - If the check fails.jade.onto.Ontology#check(Frame f)
public void check(java.lang.Object o,
java.lang.String roleName)
throws OntologyException
check in interface Ontologyo - The Java object to check.roleName - The role against which to check the given object.
OntologyException - If the check fails.jade.onto.Ontology#check(Object o, String roleName)
public boolean isRole(java.lang.String roleName)
throws OntologyException
isRole in interface OntologyroleName - The name of the role to check.
true if a role with the given name exists,
false otherwise.
OntologyExceptionjade.onto.Ontology#isRole(String roleName)
public SlotDescriptor[] getSlots(java.lang.String roleName)
throws OntologyException
getSlots in interface OntologyroleName - The name of the ontological role to examine.
OntologyExceptionjade.onto.Ontology#getSlots(String roleName)
public java.lang.String getRoleName(java.lang.Class c)
throws OntologyException
getRoleName in interface OntologyOntologyException - if no role is found for this classjade.onto.Ontology#getRoleName(Class c)public java.util.List getVocabulary()
getVocabulary in interface OntologyList including the names of all the roles
in the ontology, i.e. the Vocabulary used by the ontologyjade.onto.Ontology#getVocabulary()public java.lang.Class getClassForRole(java.lang.String roleName)
create() method to instantiate
objects. A useful technique is returning an interface or an abstract class,
while using concrete subclasses to create objects.
getClassForRole in interface OntologyDFAgentDescription.classprivate java.lang.String translateName(java.lang.String name)
private java.lang.Class checkGetAndSet(java.lang.String name,
java.lang.Class c)
throws OntologyException
OntologyExceptionprivate int getArgumentLength(java.lang.reflect.Method m)
private java.lang.Class getReturnType(java.lang.reflect.Method m)
private java.lang.Class getArgumentType(java.lang.reflect.Method m,
int no)
private java.lang.Class checkGetAndSet2(java.lang.String name,
java.lang.Class c)
throws OntologyException
For every SlotDescriptor
of category SET_SLOT or SEQUENCE_SLOT
and named XXX, with elements of type T, the
class must have two accessible methods, with the following
signature:
Iterator getAllXXX()
void addXXX(T t)
OntologyException
private void checkClass(java.lang.String roleName,
java.lang.Class c)
throws OntologyException
OntologyException
private java.lang.Object initObject(Frame f,
java.lang.Object entity,
java.lang.Class theRoleClass)
throws OntologyException
OntologyException
private java.lang.Object castPrimitiveValue(java.lang.Object value,
java.lang.String type)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
private void buildFromObject(Frame f,
FrameSchema fs,
java.lang.Object o,
java.lang.Class theRoleClass)
throws OntologyException
OntologyException
private void addSchemaToTable(java.lang.String roleName,
FrameSchema fs)
private java.lang.reflect.Method findMethodCaseInsensitive(java.lang.String name,
java.lang.Class c)
throws OntologyException
OntologyException
public java.lang.String fromSL0String(java.lang.String str)
throws CodecException,
OntologyException
Ontologyjade.onto.JadeMetaOntology
fromSL0String in interface Ontologystr - is the SL-0 expression representing this ontology
CodecException
OntologyExceptionOntology.fromSL0String(String)
public void fromMetaOntologyRepresentation(AnOntology o)
throws OntologyException
Ontology
fromMetaOntologyRepresentation in interface Ontologyo - is a JADE-Meta-Ontology
OntologyExceptionOntology.fromMetaOntologyRepresentation(AnOntology)public java.lang.String toString()
toSL0String() and catching any exception.
Notice that this method ignores the name of the ontology and, therefore,
the method toSL0String() should be preferred, instead.
public AnOntology toMetaOntologyRepresentation(java.lang.String ontologyName)
Ontology
toMetaOntologyRepresentation in interface OntologyontologyName - is the name of this ontology. It cannot be either
null or an empty String.
Ontology.toMetaOntologyRepresentation(String)
public java.lang.String toSL0String(java.lang.String ontologyName)
throws OntologyException
toSL0String in interface OntologyontologyName - the name of this ontology
OntologyExceptionOntology.toSL0String()
public java.lang.Object create(Frame f)
throws OntologyException
Ontology
create in interface Ontologyf - A frame containing initialization data for the object.
getClassForRole(), or one of its subclasses).
OntologyException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||