Package adams.core

Class UnorderedRange

    • Constructor Detail

      • UnorderedRange

        public UnorderedRange()
        Initializes with no range.
      • UnorderedRange

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

        public UnorderedRange​(String range,
                              int max)
        Initializes with the given range and maximum.
        Parameters:
        range - the range 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()
        The initializes the members.
      • reset

        protected void reset()
        Resets the state.
      • setRange

        public void setRange​(String value)
        Sets the range.
        Parameters:
        value - the range to use
      • getRange

        public String getRange()
        Returns the currently set range.
        Returns:
        the range in use
      • hasRange

        public boolean hasRange()
        Checks whether a valid range has been supplied.
        Returns:
        true if a valid range is available
      • isAllRange

        public boolean isAllRange()
        Returns whether the range encompasses all.
        Returns:
        true if ALL
        See Also:
        ALL
      • isEmpty

        public boolean isEmpty()
        Returns whether the range is empty.
        Returns:
        true if empty
      • 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
      • splitRange

        protected String[] splitRange​(String range)
        Splits the range into subranges.
        Parameters:
        range - the range to split
        Returns:
        the subranges
      • parseSubRange

        protected int[] parseSubRange​(String subrange)
        Parses the subrange.
        Parameters:
        subrange - the subrange
        Returns:
        the indices
      • parse

        protected void parse()
        Parses the range.
      • getIntIndices

        public int[] getIntIndices()
        Returns the integer indices. Gets always generated on-the-fly!
        Returns:
        the indices, 0-length array if not possible
      • setIndices

        public void setIndices​(Integer[] indices)
        Sets the selected indices. Generates a range string out of the array.
        Parameters:
        indices - the indices (0-based)
      • setIndices

        public void setIndices​(int[] indices)
        Sets the selected indices. Generates a range string out of the array.
        Parameters:
        indices - the indices (0-based)
      • isInRange

        public boolean isInRange​(int index)
        Checks whether the provided 0-based index is within the range.
        Parameters:
        index - the index to check
        Returns:
        true if in range
      • 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
      • compareTo

        public int compareTo​(UnorderedRange o)
        Compares this range with the specified range for order. Returns a negative integer, zero, or a positive integer as this subrange is less than, equal to, or greater than the specified subrange. Uses the "from" as point of comparison and if those are equal, then the "to" (if available).
        Specified by:
        compareTo in interface Comparable<UnorderedRange>
        Parameters:
        o - the range 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.
      • toExplicitRange

        public String toExplicitRange()
        Returns the explicit range, i.e., just comma-separated (1-based) indices.
        Returns:
        the string
      • toString

        public String toString()
        Returns a string representation of the range.
        Overrides:
        toString in class Object
        Returns:
        the representation
      • toRange

        public static UnorderedRange toRange​(int[] indices)
        Turns the integer indices into a unordered range object.
        Parameters:
        indices - the 0-based indices
        Returns:
        the generated range
      • isValid

        public static boolean isValid​(String s,
                                      int max)
        Returns whether the range string is valid.
        Parameters:
        s - the range to check
        max - the maximum (-1 for uninitialized)
        Returns:
        true if a valid range string