Package jade.content.schema
Class ObjectSchema
- java.lang.Object
-
- jade.content.schema.ObjectSchema
-
- All Implemented Interfaces:
Serializable,Serializable
- Direct Known Subclasses:
ContentElementSchema,TermSchema
public abstract class ObjectSchema extends Object implements Serializable
The common ancestor of all ontological schemas.- Author:
- Federico Bergenti - Universita` di Parma, Giovanni Caire - TILAB
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringBASE_NAMEprotected static ObjectSchemabaseSchemaprotected booleanencodingByOrderstatic intMANDATORYCanstant value indicating that a slot in a schema is mandatory, i.e.static intOPTIONALCanstant value indicating that a slot in a schema is optional, i.e.static intUNLIMITEDCanstant value indicating that a slot in a schema has an infinite maximum cardinality
-
Constructor Summary
Constructors Constructor Description ObjectSchema()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidadd(String name, ObjectSchema slotSchema)Add a mandatory slot to the schema.protected abstract voidadd(String name, ObjectSchema slotSchema, int optionality)Add a slot to the schema.protected abstract voidadd(String name, ObjectSchema elementsSchema, int cardMin, int cardMax)Add a slot with cardinality betweencardMinandcardMaxto this schema.protected abstract 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.protected abstract voidaddFacet(String slotName, Facet f)Add aFaceton a slot of this schemaprotected abstract voidaddSuperSchema(ObjectSchema superSchema)Add a super schema tho this schema, i.e.abstract booleancontainsSlot(String name)Indicate whether a givenStringis the name of a slot defined in thisSchemaincluding super-schemasprotected abstract booleandescendsFrom(ObjectSchema s)Return true if - s is the base schema for the XXXSchema class this schema is an instance of (e.g.static ObjectSchemagetBaseSchema()Retrieve the generic base schema for all objects.booleangetEncodingByOrder()Get the indication whether the preferred encoding for the slots of concepts compliant to this schema is by order or by name.abstract Facet[]getFacets(String slotName)Retrieves the facets defined upon a slot.abstract String[]getNames()Returns the names of all the slots in thisSchema(including slots defined in super schemas).abstract String[]getOwnNames()Returns the names of the slots defined in thisSchema(excluding slots defined in super schemas).abstract ObjectSchemagetSchema(String name)Retrieves the schema of a slot of thisSchema.abstract ObjectSchema[]getSuperSchemas()Retrieves an array containing the direct super-schemas of this schema.abstract StringgetTypeName()Retrieves the name of the type of this schema.abstract 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.abstract booleanisCompatibleWith(ObjectSchema s)Check if this schema is compatible with a given schema s.abstract booleanisMandatory(String name)Indicate whether a slot of this schema is mandatoryabstract booleanisOwnSlot(String name)Indicate whether a givenStringis the name of a slot actually defined in thisSchema(excluding super-schemas)abstract AbsObjectnewInstance()Creates an Abstract descriptor to hold an object compliant to thisSchema.voidsetEncodingByOrder(boolean b)Sets an indication about whether the preferred encoding for the slots of concepts compliants to this schema is by oredr or by name.abstract voidvalidate(AbsObject abs, Ontology onto)Check whether a given abstract descriptor complies with this schema.
-
-
-
Field Detail
-
MANDATORY
public static final int MANDATORY
Canstant value indicating that a slot in a schema is mandatory, i.e. its value must not be null- See Also:
- Constant Field Values
-
OPTIONAL
public static final int OPTIONAL
Canstant value indicating that a slot in a schema is optional, i.e. its value can be null- See Also:
- Constant Field Values
-
UNLIMITED
public static final int UNLIMITED
Canstant value indicating that a slot in a schema has an infinite maximum cardinality- See Also:
- Constant Field Values
-
BASE_NAME
public static final String BASE_NAME
- See Also:
- Constant Field Values
-
baseSchema
protected static ObjectSchema baseSchema
-
encodingByOrder
protected boolean encodingByOrder
-
-
Method Detail
-
getBaseSchema
public static ObjectSchema getBaseSchema()
Retrieve the generic base schema for all objects.- Returns:
- the generic base schema for all objects.
-
add
protected abstract void add(String name, ObjectSchema slotSchema, int optionality)
Add a slot to the schema.- Parameters:
name- The name of the slot.slotSchema- The schema defining the type of the slot.optionality- The optionality, i.e.,OPTIONALorMANDATORY
-
add
protected abstract void add(String name, ObjectSchema slotSchema)
Add a mandatory slot to the schema.- Parameters:
name- name of the slot.slotSchema- schema of the slot.
-
add
protected abstract 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.- 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 abstract 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.- 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, ObjectSchema, int, int)
-
addSuperSchema
protected abstract void addSuperSchema(ObjectSchema superSchema)
Add a super schema tho this schema, i.e. this schema will inherit all characteristics from the super schema- Parameters:
superSchema- the super schema.
-
addFacet
protected abstract 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
-
setEncodingByOrder
public void setEncodingByOrder(boolean b)
Sets an indication about whether the preferred encoding for the slots of concepts compliants to this schema is by oredr or by name. It should be noted however that the Content Language encoder is free to use or ignore this indication depending on the CL grammar and actual implementation.
-
getEncodingByOrder
public boolean getEncodingByOrder()
Get the indication whether the preferred encoding for the slots of concepts compliant to this schema is by order or by name.
-
getTypeName
public abstract String getTypeName()
Retrieves the name of the type of this schema.- Returns:
- the name of the type of this schema.
-
getNames
public abstract String[] getNames()
Returns the names of all the slots in thisSchema(including slots defined in super schemas).- Returns:
- the names of all slots.
-
getOwnNames
public abstract String[] getOwnNames()
Returns the names of the slots defined in thisSchema(excluding slots defined in super schemas).- Returns:
- the names of the slots defined in this
Schema.
-
getSchema
public abstract ObjectSchema getSchema(String name) throws OntologyException
Retrieves the schema of a slot of thisSchema.- 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 abstract boolean containsSlot(String name)
Indicate whether a givenStringis the name of a slot defined in thisSchemaincluding super-schemas- Parameters:
name- TheStringto test.- Returns:
trueifnameis the name of a slot defined in thisSchemaincluding super-schemas.
-
isOwnSlot
public abstract boolean isOwnSlot(String name)
Indicate whether a givenStringis the name of a slot actually defined in thisSchema(excluding super-schemas)- Parameters:
name- TheStringto test.- Returns:
trueifnameis the name of a slot actually defined in thisSchema(excluding super-schemas).
-
isMandatory
public abstract boolean isMandatory(String name) throws OntologyException
Indicate whether a slot of this schema is mandatory- 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.
-
newInstance
public abstract AbsObject newInstance() throws OntologyException
Creates an Abstract descriptor to hold an object compliant to thisSchema.- Throws:
OntologyException
-
validate
public abstract 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
-
isCompatibleWith
public abstract 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)
-
descendsFrom
protected abstract 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)
-
isAssignableFrom
public abstract 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. 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.
-
getSuperSchemas
public abstract ObjectSchema[] getSuperSchemas()
Retrieves an array containing the direct super-schemas of this schema. If this schema has no super-schema an empty array is returned- Returns:
- an array containing the direct super-schemas of this schema.
- Since:
- JADE 3.7
-
getFacets
public abstract Facet[] getFacets(String slotName)
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.- Parameters:
slotName- the name of the slot- Returns:
- the facets defined upon a slot or null if the specified slot is not found.
-
-