org.nakedobjects.object.value
Class Option

java.lang.Object
  extended byorg.nakedobjects.object.value.AbstractNakedValue
      extended byorg.nakedobjects.object.value.Option
All Implemented Interfaces:
Naked, NakedValue, java.io.Serializable
Direct Known Subclasses:
SelectionObject

public class Option
extends AbstractNakedValue

Value object representing one of a number of choices. The options are specified as strings.

NOTE: this class currently does not support about listeners.

See Also:
Serialized Form

Constructor Summary
Option(java.lang.String[] options)
           
Option(java.lang.String[] options, int selected)
           
 
Method Summary
 void clear()
          Clears the value so that it is empty, i.e.
 void copyObject(Naked object)
          Copies the specified object's contained data to this instance.
 java.lang.String getObjectHelpText()
          Returns a textual desctiption of the object - its contents and possible uses.
 java.lang.String getOption(int index)
           
 java.lang.String getOptionAt(int index)
           
 java.lang.String[] getOptions()
           
 java.lang.String getSelection()
           
 int getSelectionIndex()
           
 boolean hasOption(java.lang.String expectedTitle)
           
 boolean isEmpty()
          Returns true if the object contains no data, eg when new
 boolean isSameAs(Naked object)
          Compares the selected options if the specified object is a Option object else returns false.
 int noOptions()
           
 void parse(java.lang.String text)
          Takes a user entry string which is parsed to set up the object.
 void reset()
          Reset this option so it has the first option selected.
 void restoreString(java.lang.String data)
          Takes a storage string and uses it reinstate this value object to its previous state/
 java.lang.String saveString()
          Returns a basic string representation of this value for storage purposes.
 void setSelection(java.lang.String selection)
           
 void setSelectionIndex(int selection)
           
 java.lang.String stringValue()
           
 Title title()
          Returns a Title object describing the object.
 void update(NakedValue object)
           
 
Methods inherited from class org.nakedobjects.object.value.AbstractNakedValue
about, addNakedValueListener, checkCanOperate, contextualTitle, deepCopy, dumpObject, fireValueChanged, fireValueChanged, getClassName, getFullClassName, getLogger, isNull, isValid, nakedValueListeners, removeNakedValueListener, setAbout, setNull, setValidity, summary, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Option

public Option(java.lang.String[] options)

Option

public Option(java.lang.String[] options,
              int selected)
Method Detail

clear

public void clear()
Description copied from interface: NakedValue
Clears the value so that it is empty, i.e. isEmpty returns true.


copyObject

public void copyObject(Naked object)
Copies the specified object's contained data to this instance. param object the object to copy the data from


getObjectHelpText

public java.lang.String getObjectHelpText()
Description copied from interface: Naked
Returns a textual desctiption of the object - its contents and possible uses.

Specified by:
getObjectHelpText in interface Naked
Overrides:
getObjectHelpText in class AbstractNakedValue

getOption

public java.lang.String getOption(int index)

getOptionAt

public java.lang.String getOptionAt(int index)

getOptions

public java.lang.String[] getOptions()

getSelection

public java.lang.String getSelection()

getSelectionIndex

public int getSelectionIndex()

isEmpty

public boolean isEmpty()
Description copied from interface: Naked
Returns true if the object contains no data, eg when new


isSameAs

public boolean isSameAs(Naked object)
Compares the selected options if the specified object is a Option object else returns false.

Parameters:
object - the object to compare
Returns:
boolean returns true if the objects have the same content, and false if the objects are of different types or their contents are deemed to be different.
See Also:
Naked.isSameAs(Naked)

noOptions

public int noOptions()

parse

public void parse(java.lang.String text)
           throws ValueParseException
Description copied from interface: NakedValue
Takes a user entry string which is parsed to set up the object. This needs to accomodate punctuation and adornments such as currency signs.

Throws:
ValueParseException
See Also:
NakedValue.restoreString(String)

reset

public void reset()
Reset this option so it has the first option selected.

See Also:
NakedValue.reset()

setSelection

public void setSelection(java.lang.String selection)

setSelectionIndex

public void setSelectionIndex(int selection)

stringValue

public java.lang.String stringValue()

title

public Title title()
Description copied from interface: Naked
Returns a Title object describing the object.


update

public void update(NakedValue object)

hasOption

public boolean hasOption(java.lang.String expectedTitle)

restoreString

public void restoreString(java.lang.String data)
Description copied from interface: NakedValue
Takes a storage string and uses it reinstate this value object to its previous state/

Parameters:
data -
See Also:
NakedValue.parse(String)

saveString

public java.lang.String saveString()
Description copied from interface: NakedValue
Returns a basic string representation of this value for storage purposes.