elge.engine
Class ComboInteger

java.lang.Object
  |
  +--java.lang.Number
        |
        +--elge.engine.ComboInteger
All Implemented Interfaces:
Serializable

public class ComboInteger
extends Number

This class is a simple integer with a list of values, from which it can be preselected. It is used together with the ComboIntegerEditor which enables the user in gui select it value only from the predefined values.

Author:
Pavol Žibrita
See Also:
Serialized Form

Constructor Summary
ComboInteger(Integer i, String[] list)
          like ComboInteger but also defines the initial value.
ComboInteger(String[] list)
          Constructs a new ComboInteger instance with predefined values from an array string where to each string is defined its index as its value starting at 0.
 
Method Summary
 void add(String name)
          Adds a name -> list size + 1.
 void add(String name, Integer value)
          Adds a name -> value pair to the set.
 double doubleValue()
          Returns the value of the specified number as a double.
 float floatValue()
          Returns the value of the specified number as a float.
 Hashtable getList()
          Returns the paris as hastable of name -> value.
 String[] getTags()
          This is for the propertyEditor support.
 Integer getValue()
          Returns the actual value.
 Integer getValueForName(String name)
          Gets the value for a predefined name
 int intValue()
          Returns the value of the specified number as an int.
 long longValue()
          Returns the value of the specified number as a long.
 void setList(Hashtable list)
          Sets the list from a hashtable
 void setValue(Integer i)
          Sets the value.
 void setValueForName(String name)
          Sets acutal value to the value of the name if it is predefined in this instance.
 String toString()
          returns the actual value name
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComboInteger

public ComboInteger(String[] list)
Constructs a new ComboInteger instance with predefined values from an array string where to each string is defined its index as its value starting at 0. The initial value is set to 0.

Parameters:
list - list of value names.

ComboInteger

public ComboInteger(Integer i,
                    String[] list)
like ComboInteger but also defines the initial value. The value is not tested and can be beoynd the defined values.

Parameters:
i - the initial value
list - the predefined value names.
Method Detail

add

public void add(String name,
                Integer value)
Adds a name -> value pair to the set.

Parameters:
name - value name
value - value

add

public void add(String name)
Adds a name -> list size + 1.

Parameters:
name - value name

setList

public void setList(Hashtable list)
Sets the list from a hashtable

Parameters:
list - the hashtable of name -> value pairs

getList

public Hashtable getList()
Returns the paris as hastable of name -> value.

Returns:
Returns the Hashtable. Could be empty.

getTags

public String[] getTags()
This is for the propertyEditor support.

Returns:
returns the name of values as string array.

getValue

public Integer getValue()
Returns the actual value.

Returns:
The actual value.

setValue

public void setValue(Integer i)
Sets the value. It can be beyond the predefined values, it is not checked.

Parameters:
i - to what to set the value.

getValueForName

public Integer getValueForName(String name)
Gets the value for a predefined name

Parameters:
name - the name to get the value for
Returns:
returns the value or null if the name has no value in this instance.

setValueForName

public void setValueForName(String name)
Sets acutal value to the value of the name if it is predefined in this instance.

Parameters:
name - name of predefined pairs to set the value for.

doubleValue

public double doubleValue()
Returns the value of the specified number as a double. This may involve rounding.

Specified by:
doubleValue in class Number
Returns:
the numeric value represented by this object after conversion to type double.

floatValue

public float floatValue()
Returns the value of the specified number as a float. This may involve rounding.

Specified by:
floatValue in class Number
Returns:
the numeric value represented by this object after conversion to type float.

intValue

public int intValue()
Returns the value of the specified number as an int. This may involve rounding or truncation.

Specified by:
intValue in class Number
Returns:
the numeric value represented by this object after conversion to type int.

longValue

public long longValue()
Returns the value of the specified number as a long. This may involve rounding or truncation.

Specified by:
longValue in class Number
Returns:
the numeric value represented by this object after conversion to type long.

toString

public String toString()
returns the actual value name

Overrides:
toString in class Object
Returns:
Name of the actual setted value.