Class SortOption


  • public class SortOption
    extends Object
    Class to mediate with the sort configuration
    Author:
    Richard Jones
    • Constructor Detail

      • SortOption

        public SortOption​(int number,
                          String name,
                          String md,
                          String type)
                   throws SortException
        Construct a new SortOption object with the given parameters
        Parameters:
        number - the number of the sort option as given in the config file
        name - sort option name
        md - the metadata field to sort on
        type - the type of data we are sorting by
        Throws:
        SortException - if sort error
      • SortOption

        public SortOption​(int number,
                          String definition)
                   throws SortException
        Construct a new SortOption object using the definition from the configuration
        Parameters:
        number - the number of the sort option as given in the config file
        definition - definition from the configuration
        Throws:
        SortException - if sort error
    • Method Detail

      • getMetadata

        public String getMetadata()
        Returns:
        Returns the metadata.
      • setMetadata

        public void setMetadata​(String metadata)
        Parameters:
        metadata - The metadata to set.
      • getName

        public String getName()
        Returns:
        Returns the name.
      • setName

        public void setName​(String name)
        Parameters:
        name - The name to set.
      • getType

        public String getType()
        Returns:
        Returns the type.
      • setType

        public void setType​(String type)
        Parameters:
        type - The type to set.
      • getNumber

        public int getNumber()
        Returns:
        Returns the sort option number (as given in the config file).
      • setNumber

        public void setNumber​(int number)
        Parameters:
        number - The number to set.
      • isVisible

        public boolean isVisible()
        Should this sort option be made visible in the UI
        Returns:
        true if visible, false otherwise
      • getMdBits

        public String[] getMdBits()
        Returns:
        a 3-element array of the metadata bits
      • interpretField

        public final String[] interpretField​(String mfield,
                                             String init)
                                      throws IOException
        Take a string representation of a metadata field, and return it as an array. This is just a convenient utility method to basically break the metadata representation up by its delimiter (.), and stick it in an array, inserting the value of the init parameter when there is no metadata field part.
        Parameters:
        mfield - the string representation of the metadata
        init - the default value of the array elements
        Returns:
        a 3-element array with schema, element and qualifier respectively
        Throws:
        IOException - A general class of exceptions produced by failed or interrupted I/O operations.
      • isDate

        public boolean isDate()
        Is this a date field?
        Returns:
        true if is date
      • isDefault

        public boolean isDefault()
        Is the default sort option?
        Returns:
        true if is default sort option
      • getSortOptions

        public static Set<SortOption> getSortOptions()
                                              throws SortException
        Return all the configured sort options.
        Returns:
        a set of the configured sort options
        Throws:
        SortException - if sort error
      • getSortOption

        public static SortOption getSortOption​(String name)
                                        throws SortException
        Get the defined sort option by name
        Parameters:
        name - the name of the sort option as given in the config file
        Returns:
        the configured sort option with given name
        Throws:
        SortException - if sort error
      • getSortOption

        public static SortOption getSortOption​(int number)
                                        throws SortException
        Get the defined sort option by number (.1, .2, etc).
        Parameters:
        number - the number of the sort option as given in the config file
        Returns:
        the configured sort option with given number
        Throws:
        SortException - if sort error
      • getDefaultSortOption

        public static SortOption getDefaultSortOption()
                                               throws SortException
        Get the default sort option - initially, just the first one defined.
        Returns:
        the first configured sort option
        Throws:
        SortException - if sort error