voji.utils
Class VChoice

java.lang.Object
  |
  +--voji.utils.VChoice

public class VChoice
extends java.lang.Object

This class facilates implementing a choice for the user. There are methods for mapping between names, values and indices.


Field Summary
protected  java.lang.Object[][] data
          An Array of (name,value) pairs containing the data
protected  int defIndex
          The default index.
 
Constructor Summary
VChoice()
          Creates a new VChoice instance without data
VChoice(java.lang.Object[] initValues)
          Creates a new VChoice instance with initial data
 
Method Summary
 java.lang.Object[] elements()
          Returns an Array for Lists and ComboBoxes
 java.lang.Object i2v(int index)
          Returns the value of an index
 int v2i(java.lang.Object value)
          Returns the index of a value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.lang.Object[][] data
An Array of (name,value) pairs containing the data


defIndex

protected int defIndex
The default index. Usually, it's -1, but it can be overwritten by using a null value.

Constructor Detail

VChoice

public VChoice(java.lang.Object[] initValues)
Creates a new VChoice instance with initial data

Parameters:
initValues - an array of name-value-name-value-...

VChoice

public VChoice()
Creates a new VChoice instance without data

Method Detail

v2i

public int v2i(java.lang.Object value)
Returns the index of a value

Parameters:
value - the value that has to be looked for
Returns:
the corresponding index or the default index if the value wasn't found

i2v

public java.lang.Object i2v(int index)
Returns the value of an index

Parameters:
index - the index where to look at
Returns:
the corresponding value

elements

public java.lang.Object[] elements()
Returns an Array for Lists and ComboBoxes

Returns:
an Array containing all names