jade.content.schema
Class TermSchema

java.lang.Object
  |
  +--jade.content.schema.ObjectSchema
        |
        +--jade.content.schema.ObjectSchemaImpl
              |
              +--jade.content.schema.TermSchema
All Implemented Interfaces:
java.io.Serializable, Serializable
Direct Known Subclasses:
AggregateSchema, ConceptSchema, IRESchema, PrimitiveSchema, VariableSchema

public class TermSchema
extends jade.content.schema.ObjectSchemaImpl

This class represents the schema of a generic term in an ontology.

Author:
Federico Bergenti - Universita` di Parma
See Also:
Serialized Form

Field Summary
static java.lang.String BASE_NAME
           
 
Fields inherited from class jade.content.schema.ObjectSchema
baseSchema, encodingByOrder, MANDATORY, OPTIONAL, UNLIMITED
 
Constructor Summary
protected TermSchema(java.lang.String typeName)
          Creates a TermSchema with a given type-name.
 
Method Summary
protected  void add(java.lang.String name, ObjectSchema slotSchema)
          Add a mandatory slot to the schema.
protected  void add(java.lang.String name, ObjectSchema slotSchema, int optionality)
          Add a slot to the schema.
protected  void add(java.lang.String name, ObjectSchema elementsSchema, int cardMin, int cardMax)
          Add a slot with cardinality between cardMin and cardMax to this schema.
protected  void add(java.lang.String name, ObjectSchema elementsSchema, int cardMin, int cardMax, java.lang.String aggType)
          Add a slot with cardinality between cardMin and cardMax to this schema and allow specifying the type of Aggregate to be used for this slot.
protected  void addFacet(java.lang.String slotName, Facet f)
          Add a Facet on a slot of this schema
protected  void addSuperSchema(ObjectSchema superSchema)
          Add a super schema tho this schema, i.e. this schema will inherit all characteristics from the super schema
 boolean containsSlot(java.lang.String name)
          Indicate whether a given String is the name of a slot defined in this Schema
protected  boolean descendsFrom(ObjectSchema s)
          Return true if - s is the base schema for the XXXSchema class this schema is an instance of (e.g. s is ConceptSchema.getBaseSchema() and this schema is an instance of ConceptSchema) - s is the base schema for a super-class of the XXXSchema class this schema is an instance of (e.g. s is TermSchema.getBaseSchema() and this schema is an instance of ConceptSchema)
 boolean equals(java.lang.Object o)
           
static ObjectSchema getBaseSchema()
          Retrieve the generic base schema for terms.
 Facet[] getFacets(java.lang.String slotName)
          Get the facets defined upon a slot of the objectschema.
 java.lang.String[] getNames()
          Returns the names of all the slots in this Schema (including slots defined in super schemas).
 ObjectSchema getSchema(java.lang.String name)
          Retrieves the schema of a slot of this Schema.
 java.lang.String getTypeName()
          Retrieves the name of the type of this schema.
 boolean isCompatibleWith(ObjectSchema s)
          Check if this schema is compatible with a given schema s.
 boolean isMandatory(java.lang.String name)
          Indicate whether a slot of this schema is mandatory
 AbsObject newInstance()
          Creates an Abstract descriptor to hold a term of the proper type.
 java.lang.String toString()
           
 void validate(AbsObject abs, Ontology onto)
          Check whether a given abstract descriptor complies with this schema.
protected  void validateSlots(AbsObject abs, Ontology onto)
          For each slot - get the corresponding attribute value from the abstract descriptor abs - Check that it is not null if the slot is mandatory - Check that its schema is compatible with the schema of the slot - Check that it is a correct abstract descriptor by validating it against its schema.
 
Methods inherited from class jade.content.schema.ObjectSchema
getEncodingByOrder, setEncodingByOrder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_NAME

public static final java.lang.String BASE_NAME
See Also:
Constant Field Values
Constructor Detail

TermSchema

protected TermSchema(java.lang.String typeName)
Creates a TermSchema with a given type-name.

Parameters:
typeName - The name of this TermSchema.
Method Detail

getBaseSchema

public static ObjectSchema getBaseSchema()
Retrieve the generic base schema for terms.

Returns:
the generic base schema for terms.

newInstance

public AbsObject newInstance()
                      throws OntologyException
Creates an Abstract descriptor to hold a term of the proper type.

Overrides:
newInstance in class jade.content.schema.ObjectSchemaImpl
OntologyException

descendsFrom

protected boolean descendsFrom(ObjectSchema s)
Return true if - s is the base schema for the XXXSchema class this schema is an instance of (e.g. s is ConceptSchema.getBaseSchema() and this schema is an instance of ConceptSchema) - s is the base schema for a super-class of the XXXSchema class this schema is an instance of (e.g. s is TermSchema.getBaseSchema() and this schema is an instance of ConceptSchema)

Overrides:
descendsFrom in class jade.content.schema.ObjectSchemaImpl

add

protected void add(java.lang.String name,
                   ObjectSchema slotSchema,
                   int optionality)
Add a slot to the schema.

Specified by:
add in class ObjectSchema
Parameters:
name - The name of the slot.
slotSchema - The schema defining the type of the slot.
optionality - The optionality, i.e., OPTIONAL or MANDATORY

add

protected void add(java.lang.String name,
                   ObjectSchema slotSchema)
Add a mandatory slot to the schema.

Specified by:
add in class ObjectSchema
Parameters:
name - name of the slot.
slotSchema - schema of the slot.

add

protected void add(java.lang.String name,
                   ObjectSchema elementsSchema,
                   int cardMin,
                   int cardMax)
Add a slot with cardinality between cardMin and cardMax to this schema. Adding such a slot corresponds to add a slot of type Aggregate and then to add proper facets (constraints) to check that the type of the elements in the aggregate are compatible with elementsSchema and that the aggregate contains at least cardMin elements and at most cardMax elements. By default the Aggregate is of type BasicOntology.SEQUENCE.

Specified by:
add in class ObjectSchema
Parameters:
name - The name of the slot.
elementsSchema - The schema for the elements of this slot.
cardMin - This slot must get at least cardMin values
cardMax - This slot can get at most cardMax values

add

protected void add(java.lang.String name,
                   ObjectSchema elementsSchema,
                   int cardMin,
                   int cardMax,
                   java.lang.String aggType)
Add a slot with cardinality between cardMin and cardMax to this schema and allow specifying the type of Aggregate to be used for this slot.

Specified by:
add in class ObjectSchema
Parameters:
name - The name of the slot.
elementsSchema - The schema for the elements of this slot.
cardMin - This slot must get at least cardMin values
cardMax - This slot can get at most cardMax values
aggType - The type of Aggregate to be used
See Also:
ObjectSchemaImpl.add(String, ObjectSchema, int, int)

addSuperSchema

protected void addSuperSchema(ObjectSchema superSchema)
Add a super schema tho this schema, i.e. this schema will inherit all characteristics from the super schema

Specified by:
addSuperSchema in class ObjectSchema
Parameters:
superSchema - the super schema.

addFacet

protected void addFacet(java.lang.String slotName,
                        Facet f)
                 throws OntologyException
Add a Facet on a slot of this schema

Specified by:
addFacet in class ObjectSchema
Parameters:
slotName - the name of the slot the Facet must be added to.
f - the Facet to be added.
Throws:
OntologyException - if slotName does not identify a valid slot in this schema

getTypeName

public java.lang.String getTypeName()
Retrieves the name of the type of this schema.

Specified by:
getTypeName in class ObjectSchema
Returns:
the name of the type of this schema.

getNames

public java.lang.String[] getNames()
Returns the names of all the slots in this Schema (including slots defined in super schemas).

Specified by:
getNames in class ObjectSchema
Returns:
the names of all slots.

getSchema

public ObjectSchema getSchema(java.lang.String name)
                       throws OntologyException
Retrieves the schema of a slot of this Schema.

Specified by:
getSchema in class ObjectSchema
Parameters:
name - The name of the slot.
Returns:
the Schema of slot name
Throws:
OntologyException - If no slot with this name is present in this schema.

containsSlot

public boolean containsSlot(java.lang.String name)
Indicate whether a given String is the name of a slot defined in this Schema

Specified by:
containsSlot in class ObjectSchema
Parameters:
name - The String to test.
Returns:
true if name is the name of a slot defined in this Schema.

isMandatory

public boolean isMandatory(java.lang.String name)
                    throws OntologyException
Indicate whether a slot of this schema is mandatory

Specified by:
isMandatory in class ObjectSchema
Parameters:
name - The name of the slot.
Returns:
true if the slot is mandatory.
Throws:
OntologyException - If no slot with this name is present in this schema.

validate

public void validate(AbsObject abs,
                     Ontology onto)
              throws OntologyException
Check whether a given abstract descriptor complies with this schema.

Specified by:
validate in class ObjectSchema
Parameters:
abs - The abstract descriptor to be checked
Throws:
OntologyException - If the abstract descriptor does not complies with this schema

validateSlots

protected void validateSlots(AbsObject abs,
                             Ontology onto)
                      throws OntologyException
For each slot - get the corresponding attribute value from the abstract descriptor abs - Check that it is not null if the slot is mandatory - Check that its schema is compatible with the schema of the slot - Check that it is a correct abstract descriptor by validating it against its schema.

OntologyException

isCompatibleWith

public boolean isCompatibleWith(ObjectSchema s)
Check if this schema is compatible with a given schema s. This is the case if 1) This schema is equals to s 2) s is one of the super-schemas of this schema 3) This schema descends from s i.e. - s is the base schema for the XXXSchema class this schema is an instance of (e.g. s is ConceptSchema.getBaseSchema() and this schema is an instance of ConceptSchema) - s is the base schema for a super-class of the XXXSchema class this schema is an instance of (e.g. s is TermSchema.getBaseSchema() and this schema is an instance of ConceptSchema)

Specified by:
isCompatibleWith in class ObjectSchema

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getFacets

public Facet[] getFacets(java.lang.String slotName)
Get the facets defined upon a slot of the objectschema. Return null if there aren't facets on the specified slot.

Specified by:
getFacets in class ObjectSchema
Parameters:
slotName - The name of the slot which the facets are related to.


JADE