Class SpreadsheetColumn

  • Direct Known Subclasses:
    ConcreteColumn, ExcelColumn, GSColumn

    public abstract class SpreadsheetColumn
    extends java.lang.Object
    This class represents a column of a worksheet. Each column must belong to a worksheet and have a known, valid index. A valid index is greater than returned by SpreadsheetWorksheet#getColumnStartingIndex().
    Author:
    Martins Francis
    • Field Detail

      • index

        protected int index
      • name

        protected java.lang.String name
      • alias

        protected java.lang.String alias
      • many

        protected boolean many
      • delimiter

        protected java.lang.String delimiter
    • Constructor Detail

    • Method Detail

      • validateConstructorArguments

        protected void validateConstructorArguments​(SpreadsheetWorksheet worksheet,
                                                    int index)
        This method ensures 1) given worksheet is not null 2) index is less than value returned by SpreadsheetWorksheet#getColumnStartingIndex() - otherwise an IllegalArgumentException is thrown.
        Parameters:
        worksheet -
        index -
      • getWorksheet

        public SpreadsheetWorksheet getWorksheet()
        Returns:
        the worksheet this column belongs to
      • getIndex

        public int getIndex()
        Returns:
        the index of the column
      • getName

        public java.lang.String getName()
        Returns:
        the name of the column
      • getAlias

        public java.lang.String getAlias()
        Returns:
        the alias of the column
      • isMany

        public boolean isMany()
        Returns:
        the multiplicity of the column i.e. whether it may contain multiple delimiter-separated values
      • isNotMany

        public boolean isNotMany()
        Returns:
        true if this column may not store multiple values in a single cell
      • getDelimiter

        public java.lang.String getDelimiter()
        Returns:
        the delimiter used for separating the individual cell values. This is useful if a column may contain multiple values
      • setName

        public void setName​(java.lang.String name)
        Parameters:
        name - the name of the column
      • setAlias

        public void setAlias​(java.lang.String alias)
        Parameters:
        alias - the alias of the column
      • setDataType

        public void setDataType​(SpreadsheetDataType dataType)
        Parameters:
        dataType - the data type of the column
      • setMany

        public void setMany​(boolean many)
        Parameters:
        many - the multiplicity of the column
      • setDelimiter

        public void setDelimiter​(java.lang.String delimiter)
        Parameters:
        delimiter - the delimiter used for separating the values stored in individual cells of the column
      • isIdentifiableBy

        public boolean isIdentifiableBy​(java.lang.String identifier)
        Column can be identified either by its name, alias or prefixed column index
        Parameters:
        identifier -
        Returns:
        true if column can be identified by the identifier, false otherwise
      • getPrefixedIndex

        public java.lang.String getPrefixedIndex()
        This method returns the index of this column prefixed by SpreadsheetConstants.PREFIX_COLUMN.
        Returns:
        prefixed index
      • isValidIndex

        public boolean isValidIndex​(java.lang.String identifier)
        This method checks if the index embedded within the provided prefixed column index is equal to the index of this column i.e. it will always return true if identifier is equal to the output of getPrefixedIndex().
        Parameters:
        identifier -
        Returns:
        true if index of the column equals the embedded index
      • getIdentifier

        public java.lang.String getIdentifier()
        Returns:
        an identifier of the column. If name is set then it is returned, otherwise if alias is set then it is returned. If neither is set then prefixed column index is returned
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object