org.dspace.sort
Class SortOption

java.lang.Object
  extended by org.dspace.sort.SortOption

public class SortOption
extends Object

Class to mediate with the sort configuration

Author:
Richard Jones

Field Summary
static String ASCENDING
           
static String DESCENDING
           
 
Constructor Summary
SortOption(int number, String definition)
          Construct a new SortOption object using the definition from the configuration
SortOption(int number, String name, String md, String type)
          Construct a new SortOption object with the given parameters
 
Method Summary
 void generateMdBits()
          Tell the class to generate the metadata bits
static SortOption getDefaultSortOption()
          Get the default sort option - initially, just the first one defined
 String[] getMdBits()
           
 String getMetadata()
           
 String getName()
           
 int getNumber()
           
static SortOption getSortOption(int number)
          Get the defined sort option by number (.1, .2, etc)
static Set<SortOption> getSortOptions()
          Return all the configured sort options
static Map<Integer,SortOption> getSortOptionsMap()
           
 String getType()
           
 String[] interpretField(String mfield, String init)
          Take a string representation of a metadata field, and return it as an array.
 boolean isDate()
          Is this a date field
 boolean isDefault()
          Is the default sort option
 boolean isVisible()
          Should this sort option be made visible in the UI
 void setMetadata(String metadata)
           
 void setName(String name)
           
 void setNumber(int number)
           
 void setType(String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 SortException
Construct a new SortOption object with the given parameters

Parameters:
number -
name -
md -
type -
Throws:
SortException

SortOption

public SortOption(int number,
                  String definition)
           throws SortException
Construct a new SortOption object using the definition from the configuration

Parameters:
number -
definition -
Throws:
SortException
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 number.

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

generateMdBits

public void generateMdBits()
                    throws SortException
Tell the class to generate the metadata bits

Throws:
SortException

interpretField

public 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 three element array with schema, element and qualifier respectively
Throws:
IOException

isDate

public boolean isDate()
Is this a date field

Returns:

isDefault

public boolean isDefault()
Is the default sort option

Returns:

getSortOptionsMap

public static Map<Integer,SortOption> getSortOptionsMap()
                                                 throws SortException
Returns:
a map of the configured sort options
Throws:
SortException

getSortOptions

public static Set<SortOption> getSortOptions()
                                      throws SortException
Return all the configured sort options

Returns:
Throws:
SortException

getSortOption

public static SortOption getSortOption(int number)
                                throws SortException
Get the defined sort option by number (.1, .2, etc)

Parameters:
number -
Returns:
Throws:
SortException

getDefaultSortOption

public static SortOption getDefaultSortOption()
                                       throws SortException
Get the default sort option - initially, just the first one defined

Returns:
Throws:
SortException


Copyright © 2010 DuraSpace. All Rights Reserved.