Package org.dspace.sort
Class SortOption
- java.lang.Object
-
- org.dspace.sort.SortOption
-
public class SortOption extends Object
Class to mediate with the sort configuration- Author:
- Richard Jones
-
-
Field Summary
Fields Modifier and Type Field Description static StringASCENDINGstatic StringDESCENDING
-
Constructor Summary
Constructors Constructor Description SortOption(int number, String definition)Construct a new SortOption object using the definition from the configurationSortOption(int number, String name, String md, String type)Construct a new SortOption object with the given parameters
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SortOptiongetDefaultSortOption()Get the default sort option - initially, just the first one defined.String[]getMdBits()StringgetMetadata()StringgetName()intgetNumber()static SortOptiongetSortOption(int number)Get the defined sort option by number (.1, .2, etc).static SortOptiongetSortOption(String name)Get the defined sort option by namestatic Set<SortOption>getSortOptions()Return all the configured sort options.StringgetType()String[]interpretField(String mfield, String init)Take a string representation of a metadata field, and return it as an array.booleanisDate()Is this a date field?booleanisDefault()Is the default sort option?booleanisVisible()Should this sort option be made visible in the UIvoidsetMetadata(String metadata)voidsetName(String name)voidsetNumber(int number)voidsetType(String type)
-
-
-
Field Detail
-
ASCENDING
public static final String ASCENDING
- See Also:
- Constant Field Values
-
DESCENDING
public static final String DESCENDING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SortOption
public SortOption(int number, String name, String md, String type) throws SortExceptionConstruct a new SortOption object with the given parameters- Parameters:
number- the number of the sort option as given in the config filename- sort option namemd- the metadata field to sort ontype- the type of data we are sorting by- Throws:
SortException- if sort error
-
SortOption
public SortOption(int number, String definition) throws SortExceptionConstruct a new SortOption object using the definition from the configuration- Parameters:
number- the number of the sort option as given in the config filedefinition- 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 metadatainit- 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
-
-