Package jade.content.schema
Class AgentActionSchema
- java.lang.Object
-
- jade.content.schema.ObjectSchema
-
- jade.content.schema.TermSchema
-
- jade.content.schema.ConceptSchema
-
- jade.content.schema.AgentActionSchema
-
- All Implemented Interfaces:
Serializable,Serializable
public class AgentActionSchema extends ConceptSchema
The class to be used to define schemas of agent actions in an ontology. Note that an AgentActionSchema should also be a ConceptSchema, but this inheritance relation is cut as Java does not support multiple inheritance. As a consequence in practice it will not be possible to define e.g. a ConceptSchema with a slot whose value must be instances of a certain type of agent-action even if in theory this should be possible as a ConceptSchema can have slots of type term and an agent-action is a concept and therefore a term.- 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 AgentActionSchema(String typeName)Creates anAgentActionSchemawith a given type-name.
-
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, PredicateSchema slotSchema)Add a mandatory slot of type PredicateSchema to this schema.voidadd(String name, PredicateSchema slotSchema, int optionality)Add a slot of type PredicateSchema 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 agent actions.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).Facet[]getResultFacets()TermSchemagetResultSchema()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 an agent action of the proper type.voidsetResult(TermSchema resultSchema)Define that the result produced by the execution of an action described by this schema has a structure conforming to a given term schema.voidsetResult(TermSchema elementsSchema, int cardMin, int cardMax)Define that the result produced by the execution of an action described by this schema is an aggregate of n (with n between cardMin and cardMax) elements each one having a structure conforming to a given term schema.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.ConceptSchema
add, add, add, add, add, addFacet, addSuperSchema
-
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
-
AgentActionSchema
public AgentActionSchema(String typeName)
Creates anAgentActionSchemawith a given type-name.- Parameters:
typeName- The name of thisAgentActionSchema.
-
-
Method Detail
-
getBaseSchema
public static ObjectSchema getBaseSchema()
Retrieve the generic base schema for all agent actions.- Returns:
- the generic base schema for all agent actions.
-
add
public void add(String name, PredicateSchema slotSchema)
Add a mandatory slot of type PredicateSchema to this schema.- Parameters:
name- The name of the slot.slotSchema- The schema of the slot.
-
add
public void add(String name, PredicateSchema slotSchema, int optionality)
Add a slot of type PredicateSchema to this schema.- Parameters:
name- The name of the slot.slotSchema- The schema of the slot.optionality- The optionality, i.e.OPTIONALorMANDATORY
-
newInstance
public AbsObject newInstance() throws OntologyException
Creates an Abstract descriptor to hold an agent action of the proper type.- Overrides:
newInstancein classConceptSchema- Throws:
OntologyException
-
validate
public void validate(AbsObject abs, Ontology onto) throws OntologyException
Check whether a given abstract descriptor complies with this schema.- Overrides:
validatein classConceptSchema- 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. Moreover, as AgentActionSchema extends GenericActionSchema, but should also extend ConceptSchema (this is not possible in practice as Java does not support multiple inheritance), this method returns true also in the case that s is equals to, or is an ancestor of, ConceptSchema.getBaseSchema() (i.e. TermSchema.getBaseSchema() descends from s)- Overrides:
descendsFromin classConceptSchema
-
setResult
public void setResult(TermSchema resultSchema)
Define that the result produced by the execution of an action described by this schema has a structure conforming to a given term schema.- Parameters:
resultSchema- the schema of the result
-
setResult
public void setResult(TermSchema elementsSchema, int cardMin, int cardMax)
Define that the result produced by the execution of an action described by this schema is an aggregate of n (with n between cardMin and cardMax) elements each one having a structure conforming to a given term schema.- Parameters:
elementsSchema- the schema of the elements in the result aggregatecardMin- the result must include at leastcardMinelementscardMax- the result must include at mostcardMaxelements
-
getResultSchema
public TermSchema getResultSchema()
-
getResultFacets
public Facet[] getResultFacets()
-
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
-
-