ti.chimera.pref
Class ChoiceNodeContract

java.lang.Object
  extended byti.chimera.pref.ChoiceNodeContract
All Implemented Interfaces:
NodeContract

public class ChoiceNodeContract
extends java.lang.Object
implements NodeContract

A NodeContract which constrains the value to be a object matching one of the specified objects.

Version:
0.1
Author:
;Rob Clark;a0873619;San Diego;;

Field Summary
 
Fields inherited from interface ti.chimera.registry.NodeContract
BOOLEAN_CONTRACT, NULL_CONTRACT, NUMBER_CONTRACT, STRING_CONTRACT
 
Constructor Summary
ChoiceNodeContract(java.lang.Object[] choices)
          Class Constructor.
ChoiceNodeContract(java.lang.Object[] choices, java.lang.Object[] displayNames)
          Class Constructor.
 
Method Summary
 boolean accepts(java.lang.Object value)
          Determine if the specified value meets this contract.
 java.lang.Object getChoice(int idx)
          Get the specified value
 int getChoicesCount()
          Get the number of valid choices.
 java.lang.Object getDisplayName(int idx)
          Get the specified display name
 java.lang.String toString()
          The contract implementation should overload toString so the contract can be displayed to the user in a sane format, for use in error messages, etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChoiceNodeContract

public ChoiceNodeContract(java.lang.Object[] choices)
Class Constructor.

Parameters:
choices - the set of acceptible values

ChoiceNodeContract

public ChoiceNodeContract(java.lang.Object[] choices,
                          java.lang.Object[] displayNames)
Class Constructor.

Parameters:
choices - the set of acceptible values
displayNames - the names to display to the user... the index into this array should correspond to the index into choices array for the value corresponding to the display name. The display name is simply used for an user interface constructed based on this contract.
Method Detail

getChoicesCount

public int getChoicesCount()
Get the number of valid choices.

Returns:
the number of valid values

getChoice

public java.lang.Object getChoice(int idx)
Get the specified value


getDisplayName

public java.lang.Object getDisplayName(int idx)
Get the specified display name


accepts

public boolean accepts(java.lang.Object value)
Determine if the specified value meets this contract.

Specified by:
accepts in interface NodeContract
Parameters:
value - the value to check
Returns:
true if meets contract

toString

public java.lang.String toString()
The contract implementation should overload toString so the contract can be displayed to the user in a sane format, for use in error messages, etc.

Specified by:
toString in interface NodeContract