Package adams.core

Class AbstractDataBackedIndex<T>

    • Field Detail

      • m_Data

        protected T m_Data
        the underlying data.
      • m_Names

        protected List<String> m_Names
        the names to replace.
    • Constructor Detail

      • AbstractDataBackedIndex

        public AbstractDataBackedIndex()
        Initializes with no index.
      • AbstractDataBackedIndex

        public AbstractDataBackedIndex​(String index)
        Initializes with the given index, but no maximum.
        Parameters:
        index - the index to use
      • AbstractDataBackedIndex

        public AbstractDataBackedIndex​(String index,
                                       int max)
        Initializes with the given index and maximum.
        Parameters:
        index - the index to use
        max - the maximum of the 1-based index (e.g., use "10" to allow "1-10" or -1 for uninitialized)
    • Method Detail

      • initialize

        protected void initialize()
        For initializing the object.
        Overrides:
        initialize in class Index
      • setData

        public void setData​(T value)
        Sets the dataset to use for interpreting the name.
        Parameters:
        value - the dataset to use, can be null
      • getData

        public T getData()
        Returns the underlying dataset.
        Returns:
        the underlying dataset, null if none set
      • getIntIndex

        public int getIntIndex​(T data)
        Returns the integer representation of the index. Uses on a clone of itself as not to keep a reference to the data.
        Parameters:
        data - the data to use for determining the index
        Returns:
        the integer index, -1 if not possible
      • getNumNames

        protected abstract int getNumNames​(T data)
        Returns the number of names the data has.
        Parameters:
        data - the data to retrieve the number of names
      • getName

        protected abstract String getName​(T data,
                                          int colIndex)
        Returns the name at the specified index.
        Parameters:
        data - the data to use
        colIndex - the name index
        Returns:
        the name
      • getNames

        protected List<String> getNames()
        Returns the names.
        Returns:
        the names
      • getIndices

        public HashMap<String,​Integer> getIndices()
        Returns the indices in use.
        Returns:
        the indices
      • replaceName

        protected String replaceName​(String s)
        Replaces any name in the string with the actual 1-based index.
        Parameters:
        s - the string to process
        Returns:
        the (potentially) updated string
      • isName

        protected boolean isName​(String s)
        Checks whether the strings represents a name.
        Parameters:
        s - the string to process
        Returns:
        true if string is a name
      • clean

        protected String clean​(String s)
        Cleanses the given string. Only allows "first", "last" and numbers.
        Overrides:
        clean in class Index
        Parameters:
        s - the string to clean
        Returns:
        the cleansed string, "" if invalid one provided; if no spreadsheet provided, all input is considered valid
      • parse

        protected int parse​(String s,
                            int max)
        Parses the string and checks it against the maximum.
        Overrides:
        parse in class Index
        Parameters:
        s - the string to parse
        max - the maximum to allow
        Returns:
        the parsed value, -1 if invalid