net.sf.freecol.common.option
Class ListOption<T>

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.option.AbstractOption
          extended by net.sf.freecol.common.option.ListOption<T>
Type Parameters:
T - The type of objects to store in the list.
All Implemented Interfaces:
Option

public class ListOption<T>
extends AbstractOption

An option for a list of something.


Field Summary
private static java.util.logging.Logger logger
           
private  ListOptionSelector<T> selector
           
private  java.util.List<T> value
           
 
Fields inherited from class net.sf.freecol.common.option.AbstractOption
isDefined, NO_ID, previewEnabled
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE
 
Constructor Summary
ListOption(ListOptionSelector<T> selector, java.lang.String id, OptionGroup optionGroup, T... defaultValues)
          Creates a new ListOption.
ListOption(ListOptionSelector<T> selector, java.lang.String id, T... defaultValues)
          Creates a new ListOption.
ListOption(ListOptionSelector<T> selector, javax.xml.stream.XMLStreamReader in)
          Creates a new ListOption.
 
Method Summary
 ListOptionSelector<T> getListOptionSelector()
          Gets the delegate responsible for getting a list of objects that can be selected by this option.
 java.util.List<T> getValue()
          Gets the current value of this Option.
private  java.util.List<java.lang.String> getValueIds()
           
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setValue(java.util.List<T> value)
          Sets the current value of this Option.
private  void setValueIds(java.util.List<java.lang.String> ids)
           
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
 
Methods inherited from class net.sf.freecol.common.option.AbstractOption
getGroup, getName, getShortDescription, isPreviewEnabled, setGroup, setPreviewEnabled, toString
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readAttributes, readChildren, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, setId, toArrayElement, toArrayElement, toListElement, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.common.option.Option
addPropertyChangeListener, getId, readFromXML, readFromXMLElement, removePropertyChangeListener, toXML, toXMLElement
 

Field Detail

logger

private static java.util.logging.Logger logger

selector

private ListOptionSelector<T> selector

value

private java.util.List<T> value
Constructor Detail

ListOption

public ListOption(ListOptionSelector<T> selector,
                  javax.xml.stream.XMLStreamReader in)
           throws javax.xml.stream.XMLStreamException
Creates a new ListOption.

Parameters:
in - The XMLStreamReader containing the data.
Throws:
javax.xml.stream.XMLStreamException

ListOption

public ListOption(ListOptionSelector<T> selector,
                  java.lang.String id,
                  T... defaultValues)
Creates a new ListOption.

Parameters:
id - The identifier for this option. This is used when the object should be found in an OptionGroup.
defaultValues - The default values of this option.

ListOption

public ListOption(ListOptionSelector<T> selector,
                  java.lang.String id,
                  OptionGroup optionGroup,
                  T... defaultValues)
Creates a new ListOption.

Parameters:
id - The identifier for this option. This is used when the object should be found in an OptionGroup.
optionGroup - the OptionGroup this option belongs to.
defaultValues - The default values of this option.
Method Detail

getListOptionSelector

public ListOptionSelector<T> getListOptionSelector()
Gets the delegate responsible for getting a list of objects that can be selected by this option.

Returns:
The ListOptionSelector for this option.

getValue

public java.util.List<T> getValue()
Gets the current value of this Option.

Returns:
The value.

setValue

public void setValue(java.util.List<T> value)
Sets the current value of this Option.

Parameters:
value - The value.

getValueIds

private java.util.List<java.lang.String> getValueIds()

setValueIds

private void setValueIds(java.util.List<java.lang.String> ids)

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Specified by:
toXMLImpl in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Gets the tag name of the root element representing this object.

Returns:
"listOption".