Class Model

  • All Implemented Interfaces:
    IModel

    public abstract class Model
    extends java.lang.Object
    implements IModel
    Basic implementation for the readable model.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • Model

        protected Model​(Project project)
        Creates a model backed by project.
        Parameters:
        project - the IVML project instance
    • Method Detail

      • createModelContent

        private void createModelContent​(Project project)
        Creates the model content based on the given project.
        Parameters:
        project - the IVML project instance
      • collect

        private void collect​(ContainableModelElement elt)
        Collects cached information for elt.
        Parameters:
        elt - the element to cache information for
      • resolveImports

        private void resolveImports​(ProjectImport pImport)
        Resolves project import in terms of collecting type and variable definitions.
        Parameters:
        pImport - the project import from which additional cache information will be stored
      • getName

        public java.lang.String getName()
        Description copied from interface: IModel
        Returns the name of the model.
        Specified by:
        getName in interface IModel
        Returns:
        the name of the model
      • getVersion

        public java.lang.String getVersion()
        Description copied from interface: IModel
        Returns the name of the version.
        Specified by:
        getVersion in interface IModel
        Returns:
        the name of the version (may be null)
      • getVariablesCount

        public int getVariablesCount()
        Description copied from interface: IModel
        Returns the number of decision variables stored in this model.
        Specified by:
        getVariablesCount in interface IModel
        Returns:
        the number of decision variables
      • getVariable

        public IDecisionVariable getVariable​(int index)
        Description copied from interface: IModel
        Returns a particular decision variable.
        Specified by:
        getVariable in interface IModel
        Parameters:
        index - the 0-based index of the variable to be returned
        Returns:
        the specified variable
      • getVariable

        public IDecisionVariable getVariable​(java.lang.String name)
                                      throws ModelException
        Returns a decision variable by it's (valid IVML) name.
        Specified by:
        getVariable in interface IModel
        Parameters:
        name - the name of the variable
        Returns:
        the decision variable (or null if not found)
        Throws:
        ModelException - in case of any semantic problem
      • getTypesCount

        public int getTypesCount()
        Description copied from interface: IModel
        Returns the number of types known to this model.
        Specified by:
        getTypesCount in interface IModel
        Returns:
        the number of types
      • getType

        public java.lang.String getType​(int index)
        Description copied from interface: IModel
        Returns a particular known type.
        Specified by:
        getType in interface IModel
        Parameters:
        index - the 0-based index of the type to be returned
        Returns:
        the specified type
      • add

        protected void add​(CustomDatatype type)
                    throws ModelException
        Adds a decision custom type to this model and updates the cached information.
        Parameters:
        type - the type to add
        Throws:
        ModelException - in case that the same variable is about to be defined multiple times
      • add

        protected void add​(DecisionVariable variable)
                    throws ModelException
        Adds a decision variable to this model and updates the cached information.
        Parameters:
        variable - the variable to add
        Throws:
        ModelException - in case that the same variable is about to be defined multiple times
      • getProject

        protected Project getProject()
        Returns the project instance.
        Returns:
        the project instance
      • toString

        public java.lang.String toString()
        Returns the textual representation of this model.
        Specified by:
        toString in interface IModel
        Overrides:
        toString in class java.lang.Object
        Returns:
        the textual representation in IVML syntax
      • createConstraint

        public IConstraint createConstraint​(java.lang.String constraint)
                                     throws ModelException
        Description copied from interface: IModel
        Creates a constraint from the given string. This method does not modify the model.
        Specified by:
        createConstraint in interface IModel
        Parameters:
        constraint - the string to be turned into a constraint (in IVML notation)
        Returns:
        the constraint
        Throws:
        ModelException - in case of syntactical or semantical problems