Class ObjectSchema

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String BASE_NAME  
      protected static ObjectSchema baseSchema  
      protected boolean encodingByOrder  
      static int MANDATORY
      Canstant value indicating that a slot in a schema is mandatory, i.e.
      static int OPTIONAL
      Canstant value indicating that a slot in a schema is optional, i.e.
      static int UNLIMITED
      Canstant 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 void add​(String name, ObjectSchema slotSchema)
      Add a mandatory slot to the schema.
      protected abstract void add​(String name, ObjectSchema slotSchema, int optionality)
      Add a slot to the schema.
      protected abstract void add​(String name, ObjectSchema elementsSchema, int cardMin, int cardMax)
      Add a slot with cardinality between cardMin and cardMax to this schema.
      protected abstract 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.
      protected abstract void addFacet​(String slotName, Facet f)
      Add a Facet on a slot of this schema
      protected abstract void addSuperSchema​(ObjectSchema superSchema)
      Add a super schema tho this schema, i.e.
      abstract boolean containsSlot​(String name)
      Indicate whether a given String is the name of a slot defined in this Schema including super-schemas
      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.
      static ObjectSchema getBaseSchema()
      Retrieve the generic base schema for all objects.
      boolean getEncodingByOrder()
      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 this Schema (including slots defined in super schemas).
      abstract String[] getOwnNames()
      Returns the names of the slots defined in this Schema (excluding slots defined in super schemas).
      abstract ObjectSchema getSchema​(String name)
      Retrieves the schema of a slot of this Schema.
      abstract ObjectSchema[] getSuperSchemas()
      Retrieves an array containing the direct super-schemas of this schema.
      abstract String getTypeName()
      Retrieves the name of the type of this schema.
      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.
      abstract boolean isCompatibleWith​(ObjectSchema s)
      Check if this schema is compatible with a given schema s.
      abstract boolean isMandatory​(String name)
      Indicate whether a slot of this schema is mandatory
      abstract boolean isOwnSlot​(String name)
      Indicate whether a given String is the name of a slot actually defined in this Schema (excluding super-schemas)
      abstract AbsObject newInstance()
      Creates an Abstract descriptor to hold an object compliant to this Schema.
      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.
      abstract void validate​(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
      • encodingByOrder

        protected boolean encodingByOrder
    • Constructor Detail

      • ObjectSchema

        public 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 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., OPTIONAL or MANDATORY
      • 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 between 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.
        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
      • add

        protected abstract 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.
        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
        aggType - 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 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
      • 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 this Schema (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 this Schema (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 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 abstract boolean containsSlot​(String name)
        Indicate whether a given String is the name of a slot defined in this Schema including super-schemas
        Parameters:
        name - The String to test.
        Returns:
        true if name is the name of a slot defined in this Schema including super-schemas.
      • isOwnSlot

        public abstract boolean isOwnSlot​(String name)
        Indicate whether a given String is the name of a slot actually defined in this Schema (excluding super-schemas)
        Parameters:
        name - The String to test.
        Returns:
        true if name is the name of a slot actually defined in this Schema (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:
        true if the slot is mandatory.
        Throws:
        OntologyException - If no slot with this name is present in this schema.
      • 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.