Class IndexImpl

  • All Implemented Interfaces:
    Index, ModelElement

    public class IndexImpl
    extends Object
    implements Index
    Index descriptor.

    An index line is of the form:

       [unique] index <name> := part1[ part2 ...]
     
    where part is:
       [+|-]<column> | <function>(<column>) [asc|desc]
     
    where:
    • name: is the index name (the table-name will be prepended, separated by an underscore)
    • column: is either the database column-name of the entity attribute name
    • function: is a function name
    • ASC or + for ascending order (default)
    • DESC or - for descending order
    Examples:
       unique index udk := code
       index locid := location_id desc name
       index ucmt := -upper(comment)
     
    Author:
    harald
    • Constructor Detail

      • IndexImpl

        public IndexImpl​(EntityFactoryImpl factory,
                         Entity entity,
                         SourceInfo sourceInfo)
        Creates an index.
        Parameters:
        factory - the factory to create indexes
        entity - the entity this index belongs to
        sourceInfo - the source info
    • Method Detail

      • getEntity

        public Entity getEntity()
        Description copied from interface: Index
        Gets the entity this index belongs to.
        Specified by:
        getEntity in interface Index
        Returns:
        the entity
      • getSourceInfo

        public SourceInfo getSourceInfo()
        Description copied from interface: ModelElement
        Gets the information about the source where this element is defined.
        Specified by:
        getSourceInfo in interface ModelElement
        Returns:
        the source info
      • getOrdinal

        public int getOrdinal()
        Description copied from interface: ModelElement
        Gets the ordinal along the inheritance path.
        Specified by:
        getOrdinal in interface ModelElement
        Returns:
        the ordinal, starting at 0
      • setOrdinal

        public void setOrdinal​(int ordinal)
      • parse

        public void parse​(Entity entity)
                   throws ModelException
        Parses a configuration line.
        Parameters:
        entity - the entity
        Throws:
        ModelException - if parsing the model failed
      • createDatabaseIndexName

        public String createDatabaseIndexName​(Entity entity)
        Description copied from interface: Index
        Creates the database index name for given entity.
        Specified by:
        createDatabaseIndexName in interface Index
        Parameters:
        entity - the entity
        Returns:
        the effective sql name
      • getComment

        public String getComment()
        Description copied from interface: Index
        Gets the comment.
        Specified by:
        getComment in interface Index
        Returns:
        the comment
      • isUnique

        public boolean isUnique()
        Description copied from interface: Index
        Returns whether the index is unique.
        Specified by:
        isUnique in interface Index
        Returns:
        true if unique, else non-unique
      • getFilterCondition

        public String getFilterCondition()
        Description copied from interface: Index
        Gets the optional filter condition.
        Specified by:
        getFilterCondition in interface Index
        Returns:
        the condition, null if none
      • setName

        public void setName​(String name)
      • setComment

        public void setComment​(String comment)
      • setUnique

        public void setUnique​(boolean unique)
      • setFilterCondition

        public void setFilterCondition​(String filterCondition)
      • setParsed

        public void setParsed​(boolean parsed)
        Sets the index to be parsed.
        Only necessary for model converters if the properties are set explicitly to prevent parsing.
        Parameters:
        parsed - true if don't parse anymore
      • isParsed

        public boolean isParsed()
        Returns whether index is already parsed.
        Indexes are parsed delayed because some attributes may be added later when the whole model is known.
        Returns:
        true if parsed
      • getSourceLine

        public ConfigurationLine getSourceLine()
        Gets the source line.
        Returns:
        the line
      • setSourceLine

        public void setSourceLine​(ConfigurationLine sourceLine)
        Sets the source line.
        Parameters:
        sourceLine - the line
      • createModelException

        public ModelException createModelException​(String message)
        Creates a model exception.

        Refers to the source line if set, otherwise just the message.

        Parameters:
        message - the message
        Returns:
        the exception
      • sqlCreateIndex

        public String sqlCreateIndex​(Backend backend,
                                     Entity entity)
        Description copied from interface: Index
        Creates the index creation sql code.
        Specified by:
        sqlCreateIndex in interface Index
        Parameters:
        backend - the backend to create sql code for
        entity - the entity to create the index for
        Returns:
        the SQL code
      • isLogicallyEqualTo

        public boolean isLogicallyEqualTo​(Index otherIndex)
        Checks whether other index is logically equal to this index.
        Parameters:
        otherIndex - the other index
        Returns:
        true if equal