Package adams.core

Class Index

    • Constructor Detail

      • Index

        public Index()
        Initializes with no index.
      • Index

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

        public Index​(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.
      • reset

        protected void reset()
        Resets the parsed data.
      • setIndex

        public void setIndex​(String value)
        Sets the index.
        Parameters:
        value - the index to use
      • getIndex

        public String getIndex()
        Returns the currently set index.
        Returns:
        the index in use
      • setMax

        public void setMax​(int value)
        Sets the maximum (1-max will be allowed).
        Parameters:
        value - the maximum for the 1-based index
      • getMax

        public int getMax()
        Returns the maximum.
        Returns:
        the maximum for the 1-based index
      • hasIndex

        public boolean hasIndex()
        Checks whether a valid index has been supplied.
        Returns:
        true if a valid index is available
      • isEmpty

        public boolean isEmpty()
        Returns whether the index is empty.
        Returns:
        true if empty
      • isPlaceholder

        protected boolean isPlaceholder​(String s)
        Checks whether the string represents a placeholder.
        Parameters:
        s - the string to check
        Returns:
        true if a placeholder
      • clean

        protected String clean​(String s)
        Cleanses the given string. Only allows "first", "last" and numbers.
        Parameters:
        s - the string to clean
        Returns:
        the cleansed string, "" if invalid one provided
      • parsePlaceholder

        protected int parsePlaceholder​(String s,
                                       int max)
        Parses the placeholder.
        Parameters:
        s - the placeholder to parse
        max - the max to use
        Returns:
        the placeholder's integer equivalent, -1 if not a placeholder
      • parse

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

        public int getIntIndex()
        Returns the integer representation of the index.
        Returns:
        the integer index, -1 if not possible
      • compareTo

        public int compareTo​(Index o)
        Compares this index with the specified index for order. Returns a negative integer, zero, or a positive integer as this index is less than, equal to, or greater than the specified index.
        Specified by:
        compareTo in interface Comparable<Index>
        Parameters:
        o - the subrange to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
      • equals

        public boolean equals​(Object obj)
        Indicates whether some other object is "equal to" this one.
        Overrides:
        equals in class Object
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • hashCode

        public int hashCode()
        Hashcode so can be used as hashtable key. Returns the hashcode of the index string.
        Overrides:
        hashCode in class Object
        Returns:
        the hashcode
      • toString

        public String toString()
        Returns a string representation of the index object.
        Overrides:
        toString in class Object
        Returns:
        the representation
      • getHelpURL

        public String getHelpURL()
        Returns a URL with additional information.
        Specified by:
        getHelpURL in interface HelpProvider
        Returns:
        the URL, null if not available
      • getHelpDescription

        public String getHelpDescription()
        Returns a long help description, e.g., used in tiptexts.
        Specified by:
        getHelpDescription in interface HelpProvider
        Returns:
        the help text, null if not available
      • getHelpTitle

        public String getHelpTitle()
        Returns a short title for the help, e.g., used for buttons.
        Specified by:
        getHelpTitle in interface HelpProvider
        Returns:
        the short title, null if not available
      • getHelpIcon

        public String getHelpIcon()
        Returns the name of a help icon, e.g., used for buttons.
        Specified by:
        getHelpIcon in interface HelpProvider
        Returns:
        the icon name, null if not available