Package org.dspace.sort
Class SortOption
java.lang.Object
org.dspace.sort.SortOption
Class to mediate with the sort configuration
- Author:
- Richard Jones
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSortOption(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
Modifier and TypeMethodDescriptionstatic SortOptionGet the default sort option - initially, just the first one defined.String[]getName()intstatic 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>Return all the configured sort options.getType()final 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?booleanIs the default sort option?booleanShould this sort option be made visible in the UIvoidsetMetadata(String metadata) voidvoidsetNumber(int number) void
-
Field Details
-
ASCENDING
- See Also:
-
DESCENDING
- See Also:
-
-
Constructor Details
-
SortOption
Construct 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
Construct 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 Details
-
getMetadata
- Returns:
- Returns the metadata.
-
setMetadata
- Parameters:
metadata- The metadata to set.
-
getName
- Returns:
- Returns the name.
-
setName
- Parameters:
name- The name to set.
-
getType
- Returns:
- Returns the type.
-
setType
- 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
- Returns:
- a 3-element array of the metadata bits
-
interpretField
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
Return all the configured sort options.- Returns:
- a set of the configured sort options
- Throws:
SortException- if sort error
-
getSortOption
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
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
Get the default sort option - initially, just the first one defined.- Returns:
- the first configured sort option
- Throws:
SortException- if sort error
-