Class VariableSchema

    • Method Detail

      • getBaseSchema

        public static ObjectSchema getBaseSchema()
        Retrieve the generic base schema for all variables.
        Returns:
        the generic base schema for all variables.
      • 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
      • isCompatibleWith

        public boolean isCompatibleWith​(ObjectSchema s)
        A variable can be put wherever a term of whatever type is required --> A VariableSchema is compatible with s if s descends from TermSchema.getBaseSchema()
      • 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)
        Overrides:
        descendsFrom in class TermSchema
      • add

        protected void add​(String name,
                           ObjectSchema slotSchema,
                           int optionality)
        Add a slot to the schema.
        Specified by:
        add in class ObjectSchema
        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​(String name,
                           ObjectSchema slotSchema)
        Add a mandatory slot to the schema.
        Specified by:
        add in class ObjectSchema
        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 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.
        Specified by:
        add in class ObjectSchema
        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 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.
        Specified by:
        add in class ObjectSchema
        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:
        ObjectSchema.add(String, ObjectSchema, int, int)
      • add

        protected void add​(String name,
                           ObjectSchema elementsSchema,
                           int cardMin,
                           int cardMax,
                           String aggType,
                           int optionality)
        Add a slot with optionality and 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
        optionality - The optionality, i.e., OPTIONAL
        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:
        addSuperSchema in class ObjectSchema
        Parameters:
        superSchema - the super schema.
      • addFacet

        protected void addFacet​(String slotName,
                                Facet f)
                         throws OntologyException
        Add a Facet on a slot of this schema
        Specified by:
        addFacet in class ObjectSchema
        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 String getTypeName()
        Retrieves the name of the type of this schema.
        Specified by:
        getTypeName in class ObjectSchema
        Returns:
        the name of the type of this schema.
      • getNames

        public String[] getNames()
        Returns the names of all the slots in this Schema (including slots defined in super schemas).
        Specified by:
        getNames in class ObjectSchema
        Returns:
        the names of all slots.
      • getOwnNames

        public String[] getOwnNames()
        Returns the names of the slots defined in this Schema (excluding slots defined in super schemas).
        Specified by:
        getOwnNames in class ObjectSchema
        Returns:
        the names of the slots defined in this Schema.
      • containsSlot

        public boolean containsSlot​(String name)
        Indicate whether a given String is the name of a slot defined in this Schema
        Specified by:
        containsSlot in class ObjectSchema
        Parameters:
        name - The String to test.
        Returns:
        true if name is the name of a slot defined in this Schema.
      • isOwnSlot

        public boolean isOwnSlot​(String name)
        Indicate whether a given String is the name of a slot actually defined in this Schema (excluding super-schemas)
        Specified by:
        isOwnSlot in class ObjectSchema
        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 boolean isMandatory​(String name)
                            throws OntologyException
        Indicate whether a slot of this schema is mandatory
        Specified by:
        isMandatory in class ObjectSchema
        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.
      • 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
      • getSuperSchemas

        public ObjectSchema[] getSuperSchemas()
        Description copied from class: ObjectSchema
        Retrieves an array containing the direct super-schemas of this schema. If this schema has no super-schema an empty array is returned
        Specified by:
        getSuperSchemas in class ObjectSchema
        Returns:
        an array containing the direct super-schemas of this schema.
      • getFacets

        public Facet[] getFacets​(String slotName)
        Description copied from class: ObjectSchema
        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.
        Specified by:
        getFacets in class ObjectSchema
        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: ObjectSchema
        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.
        Specified by:
        isAssignableFrom in class ObjectSchema