org.dspace.content.authority
Class Choices

java.lang.Object
  extended by org.dspace.content.authority.Choices

public class Choices
extends Object

Record class to hold a set of Choices returned by an authority in response to a search.

Author:
Larry Stone
See Also:
Choice

Field Summary
static int CF_ACCEPTED
          This authority value has been confirmed as accurate by an interactive user or authoritative policy
static int CF_AMBIGUOUS
          There are multiple matching authority values of equal validity.
static int CF_FAILED
          The authority encountered an internal failure - this preserves a record in the metadata of why there is no value.
static int CF_NOTFOUND
          There are no matching answers from the authority.
static int CF_NOVALUE
          No reasonable confidence value is available
static int CF_REJECTED
          The authority recommends this submission be rejected.
static int CF_UNCERTAIN
          Value is singular and valid but has not been seen and accepted by a human, so its provenance is uncertain.
static int CF_UNSET
          Value has not been set (DB default).
 int confidence
          The confidence level that applies to all values in this result set
 int defaultSelected
          Index of value to be selected by default, if any.
 boolean more
          true when there are more values to be sent after this result.
 int start
          Index of start of this result wrt.
 int total
          Count of total results available
 Choice[] values
          The set of values returned by the authority
 
Constructor Summary
Choices(boolean isError)
          Constructor for simple empty or error results
Choices(Choice[] values, int start, int total, int confidence, boolean more)
          Constructor for general purpose
Choices(Choice[] values, int start, int total, int confidence, boolean more, int defaultSelected)
          Constructor for general purpose
Choices(int confidence)
          Constructor for error results
 
Method Summary
static String getConfidenceText(int cv)
          Get the symbolic name corresponding to a confidence value, or CF_NOVALUE's name if the value is unknown.
static int getConfidenceValue(String ct)
          Get the value corresponding to a symbolic name of a confidence value, or CF_NOVALUE if the symbol is unknown.
static int getConfidenceValue(String ct, int dflt)
          Get the value corresponding to a symbolic name of a confidence value, or the given default if the symbol is unknown.
 boolean isError()
          Predicate, did this result encounter an error?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CF_ACCEPTED

public static final int CF_ACCEPTED
This authority value has been confirmed as accurate by an interactive user or authoritative policy

See Also:
Constant Field Values

CF_UNCERTAIN

public static final int CF_UNCERTAIN
Value is singular and valid but has not been seen and accepted by a human, so its provenance is uncertain.

See Also:
Constant Field Values

CF_AMBIGUOUS

public static final int CF_AMBIGUOUS
There are multiple matching authority values of equal validity.

See Also:
Constant Field Values

CF_NOTFOUND

public static final int CF_NOTFOUND
There are no matching answers from the authority.

See Also:
Constant Field Values

CF_FAILED

public static final int CF_FAILED
The authority encountered an internal failure - this preserves a record in the metadata of why there is no value.

See Also:
Constant Field Values

CF_REJECTED

public static final int CF_REJECTED
The authority recommends this submission be rejected.

See Also:
Constant Field Values

CF_NOVALUE

public static final int CF_NOVALUE
No reasonable confidence value is available

See Also:
Constant Field Values

CF_UNSET

public static final int CF_UNSET
Value has not been set (DB default).

See Also:
Constant Field Values

values

public Choice[] values
The set of values returned by the authority


confidence

public int confidence
The confidence level that applies to all values in this result set


start

public int start
Index of start of this result wrt. all results; 0 is start of complete result. Note that length is implicit in values.length.


total

public int total
Count of total results available


defaultSelected

public int defaultSelected
Index of value to be selected by default, if any. -1 means none selected.


more

public boolean more
true when there are more values to be sent after this result.

Constructor Detail

Choices

public Choices(Choice[] values,
               int start,
               int total,
               int confidence,
               boolean more)
Constructor for general purpose


Choices

public Choices(Choice[] values,
               int start,
               int total,
               int confidence,
               boolean more,
               int defaultSelected)
Constructor for general purpose


Choices

public Choices(int confidence)
Constructor for error results


Choices

public Choices(boolean isError)
Constructor for simple empty or error results

Method Detail

isError

public boolean isError()
Predicate, did this result encounter an error?

Returns:
true if this Choices result encountered an error

getConfidenceText

public static String getConfidenceText(int cv)
Get the symbolic name corresponding to a confidence value, or CF_NOVALUE's name if the value is unknown.

Parameters:
cv - confidence value
Returns:
String with symbolic name corresponding to value (never null)

getConfidenceValue

public static int getConfidenceValue(String ct)
Get the value corresponding to a symbolic name of a confidence value, or CF_NOVALUE if the symbol is unknown.

Parameters:
ct - symbolic name in String
Returns:
corresponding value or CF_NOVALUE if not found

getConfidenceValue

public static int getConfidenceValue(String ct,
                                     int dflt)
Get the value corresponding to a symbolic name of a confidence value, or the given default if the symbol is unknown. This lets an application detect invalid data, e.g. in a configuration file.

Parameters:
ct - symbolic name in String
dflt - the default value to return
Returns:
corresponding value or CF_NOVALUE if not found


Copyright © 2010 DuraSpace. All Rights Reserved.