Package jade.content.schema
Class ConceptSchema
- java.lang.Object
-
- jade.content.schema.ObjectSchema
-
- jade.content.schema.TermSchema
-
- jade.content.schema.ConceptSchema
-
- All Implemented Interfaces:
Serializable,Serializable
- Direct Known Subclasses:
AgentActionSchema,ConceptSlotFunctionSchema
public class ConceptSchema extends TermSchema
The class to be used to define schemas of concepts in an ontology.- Author:
- Federico Bergenti - Universita` di Parma
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringBASE_NAME-
Fields inherited from class jade.content.schema.ObjectSchema
encodingByOrder, MANDATORY, OPTIONAL, UNLIMITED
-
-
Constructor Summary
Constructors Constructor Description ConceptSchema(String typeName)Creates aConceptSchemawith a given type-name, e.g.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(String name, ObjectSchema slotSchema)Add a mandatory slot to the schema.protected voidadd(String name, ObjectSchema slotSchema, int optionality)Add a slot to the schema.protected voidadd(String name, ObjectSchema elementsSchema, int cardMin, int cardMax)Add a slot with cardinality betweencardMinandcardMaxto this schema.protected voidadd(String name, ObjectSchema elementsSchema, int cardMin, int cardMax, String aggType)Add a slot with cardinality betweencardMinandcardMaxto this schema and allow specifying the type of Aggregate to be used for this slot.voidadd(String name, ObjectSchema elementsSchema, int cardMin, int cardMax, String aggType, int optionality)Add a slot with optionality and cardinality betweencardMinandcardMaxto this schema and allow specifying the type of Aggregate to be used for this slot.voidadd(String name, TermSchema slotSchema)Add a mandatory slot to the schema.voidadd(String name, TermSchema slotSchema, int optionality)Add a slot to the schema.voidadd(String name, TermSchema elementsSchema, int cardMin, int cardMax)Add a slot with cardinality betweencardMinandcardMaxto this schema.voidadd(String name, TermSchema elementsSchema, int cardMin, int cardMax, String aggType)Add a slot with cardinality betweencardMinandcardMaxto this schema and allow specifying the type of Aggregate to be used for this slot.voidaddFacet(String slotName, Facet f)Add aFaceton a slot of this schemavoidaddSuperSchema(ConceptSchema superClassSchema)Adds a super-schema to this schema.protected voidaddSuperSchema(ObjectSchema superSchema)Add a super schema to this schema, i.e.booleancontainsSlot(String name)Indicate whether a givenStringis the name of a slot defined in thisSchemaprotected booleandescendsFrom(ObjectSchema s)Return true if - s is the base schema for the XXXSchema class this schema is an instance of (e.g.booleanequals(Object o)static ObjectSchemagetBaseSchema()Retrieve the generic base schema for all concepts.Facet[]getFacets(String slotName)Retrieves the facets defined upon a slot.String[]getNames()Returns the names of all the slots in thisSchema(including slots defined in super schemas).String[]getOwnNames()Returns the names of the slots defined in thisSchema(excluding slots defined in super schemas).ObjectSchemagetSchema(String name)Retrieves the schema of a slot of thisSchema.ObjectSchema[]getSuperSchemas()Retrieves an array containing the direct super-schemas of this schema.StringgetTypeName()Retrieves the name of the type of this schema.booleanisAssignableFrom(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.booleanisCompatibleWith(ObjectSchema s)Check if this schema is compatible with a given schema s.booleanisMandatory(String name)Indicate whether a slot of this schema is mandatorybooleanisOwnSlot(String name)Indicate whether a givenStringis the name of a slot actually defined in thisSchema(excluding super-schemas)AbsObjectnewInstance()Creates an Abstract descriptor to hold a concept of the proper type.StringtoString()voidvalidate(AbsObject abs, Ontology onto)Check whether a given abstract descriptor complies with this schema.protected voidvalidateSlots(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
-
-
-
-
Field Detail
-
BASE_NAME
public static final String BASE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConceptSchema
public ConceptSchema(String typeName)
Creates aConceptSchemawith a given type-name, e.g. PERSON, ADDRESS...- Parameters:
typeName- The name of thisConceptSchema.
-
-
Method Detail
-
getBaseSchema
public static ObjectSchema getBaseSchema()
Retrieve the generic base schema for all concepts.- Returns:
- the generic base schema for all concepts.
-
add
public void add(String name, TermSchema slotSchema)
Add a mandatory slot to the schema. The schema for this slot must be aTermSchema.- Parameters:
name- The name of the slot.slotSchema- The schema of the slot.
-
add
public void add(String name, TermSchema slotSchema, int optionality)
Add a slot to the schema. The schema for this slot must be aTermSchema.- Parameters:
name- The name of the slot.slotSchema- The schema of the slot.optionality- The optionality, i.e.,OPTIONALorMANDATORY
-
add
public void add(String name, TermSchema elementsSchema, int cardMin, int cardMax)
Add a slot with cardinality betweencardMinandcardMaxto 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 withelementsSchemaand that the aggregate contains at leastcardMinelements and at mostcardMaxelements. By default the Aggregate is of typeBasicOntology.SEQUENCE.- Parameters:
name- The name of the slot.elementsSchema- The schema for the elements of this slot.cardMin- This slot must get at leastcardMinvaluescardMax- This slot can get at mostcardMaxvalues
-
add
public void add(String name, TermSchema elementsSchema, int cardMin, int cardMax, String aggType)
Add a slot with cardinality betweencardMinandcardMaxto 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 leastcardMinvaluescardMax- This slot can get at mostcardMaxvaluesaggType- The type of Aggregate to be used- See Also:
add(String, TermSchema, int, int)
-
add
public void add(String name, ObjectSchema elementsSchema, int cardMin, int cardMax, String aggType, int optionality)
Add a slot with optionality and cardinality betweencardMinandcardMaxto 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 leastcardMinvaluescardMax- This slot can get at mostcardMaxvaluesaggType- The type of Aggregate to be usedoptionality- The optionality, i.e.,OPTIONAL- See Also:
ObjectSchema.add(String, ObjectSchema, int, int)
-
addSuperSchema
public void addSuperSchema(ConceptSchema superClassSchema)
Adds a super-schema to this schema. This allows defining inheritance relationships between ontological concepts. It must be noted that a concept always inherits from another concept --> A super-schema of aConceptSchemamust be aConceptSchematoo.- Parameters:
superClassSchema- The super-schema to be added.
-
addFacet
public void addFacet(String slotName, Facet f) throws OntologyException
Add aFaceton a slot of this schema- Parameters:
slotName- the name of the slot theFacetmust be added to.f- theFacetto 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 concept of the proper type.- Overrides:
newInstancein classTermSchema- 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:
descendsFromin classTermSchema
-
add
protected void add(String name, ObjectSchema slotSchema, int optionality)
Add a slot to the schema.- Specified by:
addin classObjectSchema- Parameters:
name- The name of the slot.slotSchema- The schema defining the type of the slot.optionality- The optionality, i.e.,OPTIONALorMANDATORY
-
add
protected void add(String name, ObjectSchema slotSchema)
Add a mandatory slot to the schema.- Specified by:
addin classObjectSchema- Parameters:
name- name of the slot.slotSchema- schema of the slot.
-
add
protected void add(String name, ObjectSchema elementsSchema, int cardMin, int cardMax)
Add a slot with cardinality betweencardMinandcardMaxto 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 withelementsSchemaand that the aggregate contains at leastcardMinelements and at mostcardMaxelements. By default the Aggregate is of typeBasicOntology.SEQUENCE.- Specified by:
addin classObjectSchema- Parameters:
name- The name of the slot.elementsSchema- The schema for the elements of this slot.cardMin- This slot must get at leastcardMinvaluescardMax- This slot can get at mostcardMaxvalues
-
add
protected void add(String name, ObjectSchema elementsSchema, int cardMin, int cardMax, String aggType)
Add a slot with cardinality betweencardMinandcardMaxto this schema and allow specifying the type of Aggregate to be used for this slot.- Specified by:
addin classObjectSchema- Parameters:
name- The name of the slot.elementsSchema- The schema for the elements of this slot.cardMin- This slot must get at leastcardMinvaluescardMax- This slot can get at mostcardMaxvaluesaggType- The type of Aggregate to be used- See Also:
ObjectSchema.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:
addSuperSchemain classObjectSchema- Parameters:
superSchema- the super schema.
-
getTypeName
public String getTypeName()
Retrieves the name of the type of this schema.- Specified by:
getTypeNamein classObjectSchema- Returns:
- the name of the type of this schema.
-
getNames
public String[] getNames()
Returns the names of all the slots in thisSchema(including slots defined in super schemas).- Specified by:
getNamesin classObjectSchema- Returns:
- the names of all slots.
-
getOwnNames
public String[] getOwnNames()
Returns the names of the slots defined in thisSchema(excluding slots defined in super schemas).- Specified by:
getOwnNamesin classObjectSchema- Returns:
- the names of the slots defined in this
Schema.
-
getSchema
public ObjectSchema getSchema(String name) throws OntologyException
Retrieves the schema of a slot of thisSchema.- Specified by:
getSchemain classObjectSchema- Parameters:
name- The name of the slot.- Returns:
- the
Schemaof slotname - Throws:
OntologyException- If no slot with this name is present in this schema.
-
containsSlot
public boolean containsSlot(String name)
Indicate whether a givenStringis the name of a slot defined in thisSchema- Specified by:
containsSlotin classObjectSchema- Parameters:
name- TheStringto test.- Returns:
trueifnameis the name of a slot defined in thisSchema.
-
isOwnSlot
public boolean isOwnSlot(String name)
Indicate whether a givenStringis the name of a slot actually defined in thisSchema(excluding super-schemas)- Specified by:
isOwnSlotin classObjectSchema- Parameters:
name- TheStringto test.- Returns:
trueifnameis the name of a slot actually defined in thisSchema(excluding super-schemas).
-
isMandatory
public boolean isMandatory(String name) throws OntologyException
Indicate whether a slot of this schema is mandatory- Specified by:
isMandatoryin classObjectSchema- Parameters:
name- The name of the slot.- Returns:
trueif 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:
isCompatibleWithin classObjectSchema
-
getSuperSchemas
public ObjectSchema[] getSuperSchemas()
Description copied from class:ObjectSchemaRetrieves an array containing the direct super-schemas of this schema. If this schema has no super-schema an empty array is returned- Specified by:
getSuperSchemasin classObjectSchema- Returns:
- an array containing the direct super-schemas of this schema.
-
getFacets
public Facet[] getFacets(String slotName)
Description copied from class:ObjectSchemaRetrieves 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:
getFacetsin classObjectSchema- 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:ObjectSchemaThis 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:
isAssignableFromin classObjectSchema
-
-