JADE_SL.schema
Class ObjectSchema

java.lang.Object
  extended byJADE_SL.schema.ObjectSchema
Direct Known Subclasses:
ContentElementSchema, TermSchema

public class ObjectSchema
extends java.lang.Object

Author:
Federico Bergenti - Universita` di Parma, Giovanni Caire - TILAB

Nested Class Summary
private  class ObjectSchema.SlotDescriptor
           
 
Field Summary
static java.lang.String BASE_NAME
           
private static ObjectSchema baseSchema
           
private  java.util.Hashtable facets
           
static int MANDATORY
          Canstant value indicating that a slot in a schema is mandatory, i.e. its value must not be null
static int OPTIONAL
          Canstant value indicating that a slot in a schema is optional, i.e. its value can be null
private  java.util.Hashtable slots
           
private  java.util.Vector superSchemas
           
private  java.lang.String typeName
           
static int UNLIMITED
          Canstant value indicating that a slot in a schema has an infinite maximum cardinality
 
Constructor Summary
private ObjectSchema()
          Construct a schema that vinculates an entity to be a generic object (i.e. no constraints at all)
protected ObjectSchema(java.lang.String typeName)
          Creates an ObjectSchema with a given type-name.
 
Method Summary
protected  void add(java.lang.String name, ObjectSchema slotSchema)
          Add a mandatory slot to the schema.
protected  void add(java.lang.String name, ObjectSchema slotSchema, int optionality)
          Add a slot to the 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 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 tho this schema, i.e. this schema will inherit all characteristics from the super 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)
           
private  void getAllSlotDescriptors(java.util.Vector v)
           
static ObjectSchema getBaseSchema()
          Retrieve the generic base schema for all objects.
 java.lang.String[] getNames()
          Returns the names of all the slots in this Schema (including slots defined in super schemas).
 ObjectSchema getSchema(java.lang.String name)
          Retrieves the schema of a slot of this Schema.
 java.lang.String getTypeName()
          Retrieves the name of the type of this schema.
 boolean isCompatibleWith(ObjectSchema s)
          Check if this schema is compatible with a given schema s.
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.
 java.lang.String toString()
           
 void validate(AbsObject abs, Ontology onto)
          Check whether a given abstract descriptor complies with this schema.
private  boolean validate(java.lang.String 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

slots

private java.util.Hashtable slots

superSchemas

private java.util.Vector superSchemas

typeName

private java.lang.String typeName

facets

private java.util.Hashtable facets

BASE_NAME

public static final java.lang.String BASE_NAME
See Also:
Constant Field Values

baseSchema

private static ObjectSchema baseSchema
Constructor Detail

ObjectSchema

private ObjectSchema()
Construct a schema that vinculates an entity to be a generic object (i.e. no constraints at all)


ObjectSchema

protected ObjectSchema(java.lang.String typeName)
Creates an ObjectSchema with a given type-name.

Parameters:
typeName - The name of this ObjectSchema.
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 void add(java.lang.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., OPTIONAL or MANDATORY

add

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

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

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 is equivalent 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.

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

addSuperSchema

protected 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 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

getTypeName

public java.lang.String getTypeName()
Retrieves the name of the type of this schema.

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).

Returns:
the names of all slots.

getSchema

public ObjectSchema getSchema(java.lang.String name)
                       throws OntologyException
Retrieves the schema of a slot of this Schema.

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

Parameters:
name - The String to test.
Returns:
true if name is the name of a slot defined in this Schema.

newInstance

public AbsObject newInstance()
                      throws OntologyException
Creates an Abstract descriptor to hold an object compliant to this Schema.

Throws:
OntologyException

getAllSlotDescriptors

private void getAllSlotDescriptors(java.util.Vector v)

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

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

validate

private boolean validate(java.lang.String slotName,
                         AbsObject value,
                         Ontology onto)
                  throws OntologyException
Validate a given abstract descriptor as a value for a slot defined in this schema

Parameters:
slotName - The name of the slot
value - The abstract descriptor to be validated
Returns:
true if the slot is defined in this schema (or in one of its super schemas). false otherwise
Throws:
OntologyException - If the abstract descriptor is not a valid value

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)


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)


isSubSchemaOf

private boolean isSubSchemaOf(ObjectSchema s)
Return true if s is a super-schema (directly or indirectly) of this schema


toString

public java.lang.String toString()

equals

public boolean equals(java.lang.Object o)


Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.