JADE_SL.onto
Class Ontology

java.lang.Object
  extended byJADE_SL.onto.Ontology
Direct Known Subclasses:
ACLOntology, BasicOntology, SLOntology

public class Ontology
extends java.lang.Object

An application-specific ontology describes the elements that agents can use within content of messages. It defines a vocabulary and relationships between the elements in such a vocabulary. The relationships can be:

Application-specific ontologies are implemented through objects of class Ontology.
An ontology is characterized by: Element schemas are objects describing the structure of concepts, actions, and predicates. that are allowed in messages. For example, People ontology contains an element schema called Person. This schema states that a Person is characterized by a name and by an address: ConceptSchema personSchema = new ConceptSchema(PERSON); personSchema.addSlot(NAME, stringSchema); personSchema.addSlot(ADDRESS, addressSchema, ObjectSchema.OPTIONAL); where PERSON, NAME and ADDRESS are string constants. When you register your schema with the ontology, such constants become part of the vocabulary of the ontology.
Schemas that describe concepts support inheritance. You can define the concept Man as a refinement of the concept Person: ConceptSchema manSchema = new ConceptSchema(MAN); manSchema.addSuperSchema(personSchema); Each element schema can be associated with a Java class to map elements of the ontology that comply with a schema with Java objects of that class. The following is a class that might be associated with the Person schema: public class Person extends Concept { private String name = null; private Address address = null; public void setName(String name) { this.name = name; } public void setAddress(Address address) { this.address = address; } public String getName() { return name; } public Address getAddress() { return address; } } When sending/receiving messages you can represent your content in terms of objects belonging to classes that the ontology associates with schemas.
As the previous example suggests, you cannot use objects of class Person when asking for the value of some attribute, e.g., when asking for the value of address. Basically, the problem is that you cannot 'assign' a variable to an attribute of an object, i.e. you cannot write something like: person.setName(new Variable("X")).
In order to solve this problem, you can describe your content in terms of abstract descriptors. An abstract descriptor is an object that reifies an element of the ontology. The following is the creation of an abstract descriptor for a concept of type Man: AbsConcept absMan = new AbsConcept(MAN); absMan.setSlot(NAME, "John"); absMan.setSlot(ADDRESS, absAddress); where absAddress is the abstract descriptor for John's address: AbsConcept absAddress = new AbsConcept(ADDRESS); absAddress.setSlot(CITY, "London"); Objects of class Ontology allows you to: The framework already provides two ontologies that you can use for building your application-specific ontologies: Application-specific ontologies should be implemented extending one of them

Author:
Federico Bergenti - Universita` di Parma, Giovanni Caire - TILAB
See Also:
Concept, AbsConcept, ConceptSchema, ACLOntology, BasicOntology

Field Summary
private  Ontology[] base
           
private  java.util.Hashtable classes
           
private static java.lang.String DEFAULT_INTROSPECTOR_CLASS
           
private  java.util.Hashtable elements
           
private  Introspector introspector
           
private  java.lang.String name
           
private  java.util.Hashtable schemas
           
 
Constructor Summary
Ontology(java.lang.String name, Introspector introspector)
          Construct an Ontology object with a given name that uses a given Introspector to convert between Java objects and abstract descriptors.
Ontology(java.lang.String name, Ontology base)
          Construct an Ontology object with a given name that extends a given ontology.
Ontology(java.lang.String name, Ontology[] base, Introspector introspector)
          Construct an Ontology object with a given name that extends a given set of ontologies and that uses a given Introspector to convert between Java objects and abstract descriptors.
Ontology(java.lang.String name, Ontology base, Introspector introspector)
          Construct an Ontology object with a given name that extends a given ontology and that uses a given Introspector to convert between Java objects and abstract descriptors.
 
Method Summary
 void add(ObjectSchema schema)
          Adds a schema to this ontology
 void add(ObjectSchema schema, java.lang.Class javaClass)
          Adds a schema to the ontology and associates it to the class javaClass
static void checkIsTerm(java.lang.Object obj)
          Check whether a given object is a valid term.
 AbsObject fromObject(java.lang.Object obj)
          Converts a Java object into a proper abstract descriptor.
private  AbsObject fromObject(java.lang.Object obj, Ontology globalOnto)
          Converts a Java object into a proper abstract descriptor.
(package private)  java.lang.Class getClassForElement(java.lang.String name)
          Retrieves the concrete class associated with name in the vocabulary.
 java.lang.String getName()
          Retrieves the name of this ontology.
(package private)  ObjectSchema getSchema(java.lang.Class javaClass)
          Retrieves the schema associated with javaClass The search is not extended to the base ontologies
 ObjectSchema getSchema(java.lang.String name)
          Retrieves the schema associated with name.
(package private)  ObjectSchema getSchema(java.lang.String name, boolean searchInBase)
          Retrieves the schema associated with name.
static void setAttribute(AbsObject abs, java.lang.String attrName, AbsObject attrValue)
          Set an attribute in an abstract descriptor performing all necessary type checks.
 java.lang.Object toObject(AbsObject abs)
          Converts an abstract descriptor to a Java object of the proper class.
private  java.lang.Object toObject(AbsObject abs, Ontology globalOnto)
          Converts an abstract descriptor to a Java object of the proper class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INTROSPECTOR_CLASS

private static final java.lang.String DEFAULT_INTROSPECTOR_CLASS
See Also:
Constant Field Values

base

private Ontology[] base

name

private java.lang.String name

introspector

private Introspector introspector

elements

private java.util.Hashtable elements

classes

private java.util.Hashtable classes

schemas

private java.util.Hashtable schemas
Constructor Detail

Ontology

public Ontology(java.lang.String name,
                Ontology base)
Construct an Ontology object with a given name that extends a given ontology. The ReflectiveIntrospector is used by default to convert between Java objects and abstract descriptors.

Parameters:
name - The identifier of the ontology.
base - The base ontology.

Ontology

public Ontology(java.lang.String name,
                Introspector introspector)
Construct an Ontology object with a given name that uses a given Introspector to convert between Java objects and abstract descriptors.

Parameters:
name - The identifier of the ontology.
introspector - The introspector.

Ontology

public Ontology(java.lang.String name,
                Ontology base,
                Introspector introspector)
Construct an Ontology object with a given name that extends a given ontology and that uses a given Introspector to convert between Java objects and abstract descriptors.

Parameters:
name - The identifier of the ontology.
base - The base ontology.
introspector - The introspector.

Ontology

public Ontology(java.lang.String name,
                Ontology[] base,
                Introspector introspector)
Construct an Ontology object with a given name that extends a given set of ontologies and that uses a given Introspector to convert between Java objects and abstract descriptors.

Parameters:
name - The identifier of the ontology.
base - The base ontology.
introspector - The introspector.
Method Detail

getName

public java.lang.String getName()
Retrieves the name of this ontology.

Returns:
the name of this ontology.

add

public void add(ObjectSchema schema)
         throws OntologyException
Adds a schema to this ontology

Parameters:
schema - The schema to add
Throws:
OntologyException

add

public void add(ObjectSchema schema,
                java.lang.Class javaClass)
         throws OntologyException
Adds a schema to the ontology and associates it to the class javaClass

Parameters:
schema - the schema.
javaClass - the concrete class.
Throws:
OntologyException

getSchema

public ObjectSchema getSchema(java.lang.String name)
                       throws OntologyException
Retrieves the schema associated with name. The search is extended to the base ontologies if the schema is not found.

Parameters:
name - the name of the schema in the vocabulary.
Returns:
the schema or null if the schema is not found.
Throws:
OntologyException

toObject

public java.lang.Object toObject(AbsObject abs)
                          throws OntologyException,
                                 UngroundedException
Converts an abstract descriptor to a Java object of the proper class.

Parameters:
abs - the abstract descriptor.
Returns:
the object
Throws:
UngroundedException - if the abstract descriptor contains a variable
OntologyException - if some mismatch with the schema is found
See Also:
fromObject(Object)

fromObject

public AbsObject fromObject(java.lang.Object obj)
                     throws OntologyException
Converts a Java object into a proper abstract descriptor.

Parameters:
obj - the object
Returns:
the abstract descriptor.
Throws:
OntologyException - if some mismatch with the schema is found
See Also:
toObject(AbsObject)

getSchema

ObjectSchema getSchema(java.lang.String name,
                       boolean searchInBase)
                 throws OntologyException
Retrieves the schema associated with name.

Parameters:
name - the name of the schema in the vocabulary.
searchInBase - If true the search is extended to the base ontologies if the schema is not found.
Returns:
the schema.
Throws:
OntologyException

getSchema

ObjectSchema getSchema(java.lang.Class javaClass)
                 throws OntologyException
Retrieves the schema associated with javaClass The search is not extended to the base ontologies

Parameters:
javaClass - the Java class
Returns:
the schema
Throws:
OntologyException

getClassForElement

java.lang.Class getClassForElement(java.lang.String name)
                             throws OntologyException
Retrieves the concrete class associated with name in the vocabulary. The search is not extended to the base ontologies

Parameters:
name - the name of the schema.
Returns:
the Java class.
Throws:
OntologyException

toObject

private java.lang.Object toObject(AbsObject abs,
                                  Ontology globalOnto)
                           throws UngroundedException,
                                  OntologyException
Converts an abstract descriptor to a Java object of the proper class.

Parameters:
abs - the abstract descriptor.
globalOnto - The ontology this ontology is part of (i.e. the ontology that extends this ontology).
Returns:
the object
Throws:
OntologyException - if some mismatch with the schema is found
UngroundedException - if the abstract descriptor contains a variable

fromObject

private AbsObject fromObject(java.lang.Object obj,
                             Ontology globalOnto)
                      throws UnknownSchemaException,
                             OntologyException
Converts a Java object into a proper abstract descriptor.

Parameters:
obj - the object
globalOnto - The ontology this ontology is part of (i.e. the ontology that extends this ontology).
Returns:
the abstract descriptor.
Throws:
UnknownSchemaException - If no schema for the object to be translated is defined in this ontology.
OntologyException - if some mismatch with the schema is found

checkIsTerm

public static void checkIsTerm(java.lang.Object obj)
                        throws OntologyException
Check whether a given object is a valid term. If it is an Aggregate (i.e. a List) it also check the elements.

Throws:
OntologyException - if the given object is not a valid term

setAttribute

public static void setAttribute(AbsObject abs,
                                java.lang.String attrName,
                                AbsObject attrValue)
                         throws OntologyException
Set an attribute in an abstract descriptor performing all necessary type checks.

Throws:
OntologyException - if a type mismatch is detected


Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.