    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class xa.xa_ChoiceList

    java.lang.Object
       |
       +----xa.xa_ChoiceList

public class xa_ChoiceList
extends Object

A container for a list of String values which define the values allowed for whatever use it is being put to. The list is held internally in two forms: a Hashtable (to allow validation by key), and as a Vector (to allow retrieval of the values in the order they were supplied).

xa_ChoiceList is intended to be restricted in its use to definitions of lists of allowed value strings. Each allowed value (choice) string has an integer associated with it, which may be a constant used programmatically. No checking is performed on these integer values (so they do not have to be unique) - but it is inadvisable to use -1, since -1 is used to indicate an error when failing to find a choice.

##

ChoiceHashtable
  Hashtable used to retrieve an allowed value, given the value.
ChoiceListName
  Allows this choice list to be identified.
ChoiceValueHashtable
  Hashtable of allowed values, to allow retrieval of a choice name given its integer choice value.
ChoiceVector
  Array of allowed values, to allow retrieval in the order they were added.

##

xa_ChoiceList(String)
  Constructor, giving this choice list a name.

##

addChoice(String, int)
  Add an allowed value.
getChoice(int)
  Retrieve the choice whose integer value is InputChoiceIndex.
getChoice(String)
  Retrieve the choice whose name is InputChoiceName.
getChoiceAt(int)
  Retrieve the choice whose index is InputChoiceIndex in the ChoiceVector.
getName()
  Retrieve the name of this choice list.
getNumChoices()
  Find out how many choices there are.
hasChoice(String)
  Return true of InputChoiceName is a valid allowed value; false if not.
toString()
  Return a string representation of the choice list, in the form of a comma- separated list ("A, B, C").

##

ChoiceListName

     protected String ChoiceListName

  Allows this choice list to be identified. By qualifying choice names with the name of the choice list to which they belong, we can derive globally unique names for all choices. Such a global list may be useful for, say, documentation purposes - to allow automatic reference to the relevant section of the XML specification.

ChoiceHashtable

     protected Hashtable ChoiceHashtable

  Hashtable used to retrieve an allowed value, given the value.

ChoiceValueHashtable

     protected Hashtable ChoiceValueHashtable

  Hashtable of allowed values, to allow retrieval of a choice name given its integer choice value.

ChoiceVector

     protected Vector ChoiceVector

  Array of allowed values, to allow retrieval in the order they were added.

##

xa_ChoiceList

     public xa_ChoiceList(String InputChoiceListName)

  Constructor, giving this choice list a name.

##

addChoice

     public void addChoice(String InputChoiceName,
                           int InputChoiceValue)

  Add an allowed value.

  Parameters:
    InputChoiceName - The value which is allowed
    InputChoiceValue - A number associated with this value

hasChoice

     public boolean hasChoice(String InputChoiceName)

  Return true of InputChoiceName is a valid allowed value; false if not.

  Parameters:
    InputChoiceName - The name of the choice to be checked

getChoice

     public int getChoice(String InputChoiceName)

  Retrieve the choice whose name is InputChoiceName.

  Parameters:
    InputChoiceName - The name of the choice to be retrieved

getChoice

     public String getChoice(int InputChoiceValue)

  Retrieve the choice whose integer value is InputChoiceIndex.

  Parameters:
    InputChoiceValue - The integer value of the choice to be retrieved

getChoiceAt

     public String getChoiceAt(int InputChoiceIndex)

  Retrieve the choice whose index is InputChoiceIndex in the ChoiceVector.

  Parameters:
    InputChoiceIndex - The index of the choice to be retrieved

getNumChoices

     public int getNumChoices()

  Find out how many choices there are.

  Returns:
    The number of choices in the list

getName

     public String getName()

  Retrieve the name of this choice list.

  Returns:
    The name of this choice list

toString

     public String toString()

  Return a string representation of the choice list, in the form of a comma- separated list ("A, B, C").

  Returns:
    String represention of the list.
  Overrides:
    toString in class Object

    All Packages  Class Hierarchy  This Package  Previous  Next  Index