class ObjectSchemaImpl extends ObjectSchema
Modifier and Type | Class and Description |
---|---|
private class |
ObjectSchemaImpl.SlotDescriptor |
Modifier and Type | Field and Description |
---|---|
private Hashtable |
facets |
private Logger |
logger |
(package private) static String |
RESULT_SLOT_NAME |
private Vector |
slotNames |
private Hashtable |
slots |
private Vector |
superSchemas |
private String |
typeName |
BASE_NAME, baseSchema, encodingByOrder, MANDATORY, OPTIONAL, UNLIMITED
Modifier | Constructor and Description |
---|---|
private |
ObjectSchemaImpl()
Construct a schema that vinculates an entity to be a generic
object (i.e.
|
protected |
ObjectSchemaImpl(String typeName)
Creates an
ObjectSchema with a given type-name. |
Modifier and Type | Method and Description |
---|---|
protected void |
add(String name,
ObjectSchema slotSchema)
Add a mandatory slot to the schema.
|
protected void |
add(String name,
ObjectSchema slotSchema,
int optionality)
Add a slot to the schema.
|
protected void |
add(String name,
ObjectSchema elementsSchema,
int cardMin,
int cardMax)
Add a slot with cardinality between
cardMin
and cardMax to this schema. |
protected void |
add(String name,
ObjectSchema elementsSchema,
int cardMin,
int cardMax,
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. |
private void |
addAll(Vector v1,
Vector v2) |
protected void |
addFacet(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.
|
boolean |
containsSlot(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.
|
boolean |
equals(Object o) |
private void |
fillAllSlotNames(Vector v) |
(package private) Vector |
getAllFacets(String slotName)
Get the facets defined upon a slot.
|
Facet[] |
getFacets(String slotName)
Retrieves the facets defined upon a slot.
|
String[] |
getNames()
Returns the names of all the slots in this
Schema
(including slots defined in super schemas). |
String[] |
getOwnNames()
Returns the names of the slots defined in this
Schema
(excluding slots defined in super schemas). |
private ObjectSchemaImpl.SlotDescriptor |
getOwnSlot(CaseInsensitiveString ciName) |
ObjectSchema |
getSchema(String name)
Retrieves the schema of a slot of this
Schema . |
private ObjectSchemaImpl.SlotDescriptor |
getSlot(CaseInsensitiveString ciName) |
ObjectSchema[] |
getSuperSchemas()
Retrieves an array containing the direct super-schemas of this schema.
|
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(String name)
Indicate whether a slot of this schema is mandatory
|
boolean |
isOwnSlot(String name)
Indicate whether a given
String is the name of a
slot actually defined in this Schema (excluding super-schemas) |
private boolean |
isSubSchemaOf(ObjectSchema s)
Return true if s is a super-schema (directly or indirectly)
of this schema
|
AbsObject |
newInstance()
Creates an Abstract descriptor to hold an object compliant to
this
Schema . |
String |
toString() |
void |
validate(AbsObject abs,
Ontology onto)
Check whether a given abstract descriptor complies with this
schema.
|
private boolean |
validate(CaseInsensitiveString slotName,
AbsObject value,
Ontology onto)
Validate a given abstract descriptor as a value for a slot
defined in 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.
|
getBaseSchema, getEncodingByOrder, setEncodingByOrder
private Logger logger
static final String RESULT_SLOT_NAME
private String typeName
private Hashtable slots
private Vector slotNames
private Vector superSchemas
private Hashtable facets
private ObjectSchemaImpl()
protected ObjectSchemaImpl(String typeName)
ObjectSchema
with a given type-name.typeName
- The name of this ObjectSchema
.protected void add(String name, ObjectSchema slotSchema, int optionality)
add
in class ObjectSchema
name
- The name of the slot.slotSchema
- The schema defining the type of the slot.optionality
- The optionality, i.e., OPTIONAL
or MANDATORY
protected void add(String name, ObjectSchema slotSchema)
add
in class ObjectSchema
name
- name of the slot.slotSchema
- schema of the slot.protected void add(String name, ObjectSchema elementsSchema, int cardMin, int cardMax)
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
.add
in class ObjectSchema
name
- The name of the slot.elementsSchema
- The schema for the elements of this slot.cardMin
- This slot must get at least cardMin
valuescardMax
- This slot can get at most cardMax
valuesprotected void add(String name, ObjectSchema elementsSchema, int cardMin, int cardMax, String aggType)
cardMin
and cardMax
to this schema and allow specifying the type
of Aggregate to be used for this slot.add
in class ObjectSchema
name
- The name of the slot.elementsSchema
- The schema for the elements of this slot.cardMin
- This slot must get at least cardMin
valuescardMax
- This slot can get at most cardMax
valuesaggType
- The type of Aggregate to be usedadd(String, ObjectSchema, int, int)
protected void addSuperSchema(ObjectSchema superSchema)
addSuperSchema
in class ObjectSchema
superSchema
- the super schema.protected void addFacet(String slotName, Facet f) throws OntologyException
Facet
on a slot of this schemaaddFacet
in class ObjectSchema
slotName
- the name of the slot the Facet
must be added to.f
- the Facet
to be added.OntologyException
- if slotName does not identify
a valid slot in this schemapublic String getTypeName()
getTypeName
in class ObjectSchema
public String[] getNames()
Schema
(including slots defined in super schemas).getNames
in class ObjectSchema
public String[] getOwnNames()
Schema
(excluding slots defined in super schemas).getOwnNames
in class ObjectSchema
Schema
.public ObjectSchema getSchema(String name) throws OntologyException
Schema
.getSchema
in class ObjectSchema
name
- The name of the slot.Schema
of slot name
OntologyException
- If no slot with this name is present
in this schema.public boolean containsSlot(String name)
String
is the name of a
slot defined in this Schema
containsSlot
in class ObjectSchema
name
- The String
to test.true
if name
is the name of a
slot defined in this Schema
.public boolean isOwnSlot(String name)
String
is the name of a
slot actually defined in this Schema
(excluding super-schemas)isOwnSlot
in class ObjectSchema
name
- The String
to test.true
if name
is the name of a
slot actually defined in this Schema
(excluding super-schemas).public boolean isMandatory(String name) throws OntologyException
isMandatory
in class ObjectSchema
name
- The name of the slot.true
if the slot is mandatory.OntologyException
- If no slot with this name is present
in this schema.public AbsObject newInstance() throws OntologyException
Schema
.newInstance
in class ObjectSchema
OntologyException
private final void fillAllSlotNames(Vector v)
public void validate(AbsObject abs, Ontology onto) throws OntologyException
validate
in class ObjectSchema
abs
- The abstract descriptor to be checkedOntologyException
- If the abstract descriptor does not
complies with this schemaprotected void validateSlots(AbsObject abs, Ontology onto) throws OntologyException
OntologyException
private boolean validate(CaseInsensitiveString slotName, AbsObject value, Ontology onto) throws OntologyException
slotName
- The name of the slotvalue
- The abstract descriptor to be validatedOntologyException
- If the abstract descriptor is not a
valid valuepublic boolean isCompatibleWith(ObjectSchema s)
isCompatibleWith
in class ObjectSchema
protected boolean descendsFrom(ObjectSchema s)
descendsFrom
in class ObjectSchema
private boolean isSubSchemaOf(ObjectSchema s)
public ObjectSchema[] getSuperSchemas()
ObjectSchema
getSuperSchemas
in class ObjectSchema
public Facet[] getFacets(String slotName)
ObjectSchema
getFacets
in class ObjectSchema
slotName
- the name of the slotVector getAllFacets(String slotName)
private final ObjectSchemaImpl.SlotDescriptor getOwnSlot(CaseInsensitiveString ciName)
private final ObjectSchemaImpl.SlotDescriptor getSlot(CaseInsensitiveString ciName)
public boolean isAssignableFrom(ObjectSchema s)
ObjectSchema
isAssignableFrom
in class ObjectSchema