jade.content.schema
Class PredicateSchema

java.lang.Object
  extended by jade.content.schema.ObjectSchema
      extended by jade.content.schema.ContentElementSchema
          extended by jade.content.schema.PredicateSchema
All Implemented Interfaces:
java.io.Serializable

public class PredicateSchema
extends ContentElementSchema

The class to be used to define schemas of predicates 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
encodingByOrder, MANDATORY, OPTIONAL, UNLIMITED
 
Constructor Summary
PredicateSchema(java.lang.String typeName)
          Creates a PredicateSchema with a given type-name, e.g.
 
Method Summary
 void add(java.lang.String name, ObjectSchema slotSchema)
          Add a mandatory slot to this schema.
 void add(java.lang.String name, ObjectSchema slotSchema, int optionality)
          Add a slot to this 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.
 void add(java.lang.String name, TermSchema elementsSchema, int cardMin, int cardMax)
          Add a slot with cardinality between cardMin and cardMax to this schema.
 void add(java.lang.String name, TermSchema 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.
 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 to this schema, i.e. this schema will inherit all characteristics from the super schema
 void addSuperSchema(PredicateSchema superClassSchema)
          Adds a super-schema to this 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 all predicates.
 Facet[] getFacets(java.lang.String slotName)
          Retrieves the facets defined upon a slot.
 java.lang.String[] getNames()
          Returns the names of all the slots in this Schema (including slots defined in super schemas).
 java.lang.String[] getOwnNames()
          Returns the names of the slots defined in this Schema (excluding slots defined in super schemas).
 ObjectSchema getSchema(java.lang.String name)
          Retrieves the schema of a slot of this Schema.
 ObjectSchema[] getSuperSchemas()
          Retrieves an array containing the direct super-schemas of this schema.
 java.lang.String getTypeName()
          Retrieves the name of the type of this schema.
 boolean isAssignableFrom(ObjectSchema s)
          This method checks whether or not an abstract object that is an instance of schema s can be used in place of an abstract object that is an instance 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
 boolean isOwnSlot(java.lang.String name)
          Indicate whether a given String is the name of a slot actually defined in this Schema (excluding super-schemas)
 AbsObject newInstance()
          Creates an Abstract descriptor to hold a predicate 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

PredicateSchema

public PredicateSchema(java.lang.String typeName)
Creates a PredicateSchema with a given type-name, e.g. FATHER_OF, WORKS_FOR...

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

getBaseSchema

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

Returns:
the generic base schema for all predicates.

add

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

Parameters:
name - The name of the slot.
slotSchema - The schema of the slot.

add

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

Parameters:
name - The name of the slot.
slotSchema - The schema of the slot.
optionality - The optionality, i.e. OPTIONAL or MANDATORY

add

public void add(java.lang.String name,
                TermSchema 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.

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

public void add(java.lang.String name,
                TermSchema 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.

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:
add(String, TermSchema, int, int)

addSuperSchema

public void addSuperSchema(PredicateSchema superClassSchema)
Adds a super-schema to this schema. This allows defining inheritance relationships between ontological predicates. It must be noted that a predicate always inherits from another predicate --> A super-schema of a PredicateSchema must be a PredicateSchema too.

Parameters:
superClassSchema - The super-schema to be added.

addFacet

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

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

newInstance

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

Overrides:
newInstance in class ContentElementSchema
Throws:
OntologyException

validate

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

Parameters:
abs - The abstract descriptor to be checked
Throws:
OntologyException - If the abstract descriptor does not complies with this schema

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 ContentElementSchema

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:
add(String, ObjectSchema, int, int)

addSuperSchema

protected void addSuperSchema(ObjectSchema superSchema)
Add a super schema to 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.

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.

getOwnNames

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

Specified by:
getOwnNames in class ObjectSchema
Returns:
the names of the slots defined in this Schema.

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.

isOwnSlot

public boolean isOwnSlot(java.lang.String name)
Indicate whether a given String is the name of a slot actually defined in this Schema (excluding super-schemas)

Specified by:
isOwnSlot in class ObjectSchema
Parameters:
name - The String to test.
Returns:
true if name is the name of a slot actually defined in this Schema (excluding super-schemas).

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.

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.

Throws:
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

getSuperSchemas

public ObjectSchema[] getSuperSchemas()
Description copied from class: ObjectSchema
Retrieves an array containing the direct super-schemas of this schema. If this schema has no super-schema an empty array is returned

Specified by:
getSuperSchemas in class ObjectSchema
Returns:
an array containing the direct super-schemas of this schema.

getFacets

public Facet[] getFacets(java.lang.String slotName)
Description copied from class: ObjectSchema
Retrieves the facets defined upon a slot. More in details this method returns all facets defined in this schema plus all facets defined in super-schemas up to the schema actually declaring the given slot.

Specified by:
getFacets in class ObjectSchema
Parameters:
slotName - the name of the slot
Returns:
the facets defined upon a slot or null if the specified slot is not found.

isAssignableFrom

public boolean isAssignableFrom(ObjectSchema s)
Description copied from class: ObjectSchema
This method checks whether or not an abstract object that is an instance of schema s can be used in place of an abstract object that is an instance of this schema. Note that unlike the method isCompatibleWith() that perform "ontological" checks (i.e. they are related to the reference ontology), this method only performs a structural check on the slots regardless of the fact that the two schemas belong to the same ontology or not.

Specified by:
isAssignableFrom in class ObjectSchema


These are the official JADE API. For these API backward compatibility is guaranteed accross JADE versions