net.sf.freecol.common.option
Class AbstractUnitOption

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.option.AbstractOption<AbstractUnit>
          extended by net.sf.freecol.common.option.AbstractUnitOption
All Implemented Interfaces:
java.lang.Cloneable, Option<AbstractUnit>

public class AbstractUnitOption
extends AbstractOption<AbstractUnit>

Represents an option where the valid choice is an AbstractUnit.


Field Summary
private static UnitTypeOption.TypeSelector DEFAULT_SELECTOR
           
private static java.util.logging.Logger logger
           
private  IntegerOption number
          An Option to determine the number of the AbstractUnit.
private  StringOption role
          An Option to determine the Role of the AbstractUnit.
private  UnitTypeOption unitType
          An Option to determine the UnitType of the AbstractUnit.
private  AbstractUnit value
           
 
Fields inherited from class net.sf.freecol.common.option.AbstractOption
isDefined
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
AbstractUnitOption(Specification specification)
          Creates a new AbstractUnitOption.
AbstractUnitOption(java.lang.String id)
          Creates a new AbstractUnitOption.
AbstractUnitOption(java.lang.String id, Specification specification)
           
 
Method Summary
 AbstractUnitOption clone()
           
 void generateChoices()
          Generate the choices to provide to the UI based on the generateChoices value.
 IntegerOption getNumber()
          Get the Number value.
 StringOption getRole()
          Get the Role value.
 UnitTypeOption getUnitType()
          Get the UnitType value.
 AbstractUnit getValue()
          Gets the current value of this AbstractUnitOption.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 boolean isNullValueOK()
          Returns whether null is an acceptable value for this Option.
 void readFromXML(javax.xml.stream.XMLStreamReader in)
          Initializes this object from an XML-representation of this object, unless the PARTIAL_ATTRIBUTE tag is present which indicates a partial update of an existing object.
 void setNumber(IntegerOption newNumber)
          Set the Number value.
 void setRole(StringOption newRole)
          Set the Role value.
 void setUnitType(UnitTypeOption newUnitType)
          Set the UnitType value.
 void setValue(AbstractUnit value)
          Sets the value of this AbstractUnitOption.
 java.lang.String toString()
          Returns a textual representation of this object.
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, readAttributes, readFromXMLImpl, readOption, setGroup, setValue, setValues
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, hasAbility, hasAttribute, hasListeners, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.common.option.Option
getId, toXML
 

Field Detail

logger

private static java.util.logging.Logger logger

DEFAULT_SELECTOR

private static final UnitTypeOption.TypeSelector DEFAULT_SELECTOR

value

private AbstractUnit value

unitType

private UnitTypeOption unitType
An Option to determine the UnitType of the AbstractUnit.


role

private StringOption role
An Option to determine the Role of the AbstractUnit.


number

private IntegerOption number
An Option to determine the number of the AbstractUnit.

Constructor Detail

AbstractUnitOption

public AbstractUnitOption(java.lang.String id)
Creates a new AbstractUnitOption. Get the UnitType value.

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

AbstractUnitOption

public AbstractUnitOption(Specification specification)
Creates a new AbstractUnitOption.

Parameters:
specification - The specification this option belongs to. May be null.

AbstractUnitOption

public AbstractUnitOption(java.lang.String id,
                          Specification specification)
Method Detail

clone

public AbstractUnitOption clone()
Specified by:
clone in interface Option<AbstractUnit>
Specified by:
clone in class AbstractOption<AbstractUnit>

getValue

public AbstractUnit getValue()
Gets the current value of this AbstractUnitOption.

Specified by:
getValue in interface Option<AbstractUnit>
Specified by:
getValue in class AbstractOption<AbstractUnit>
Returns:
The value.

setValue

public void setValue(AbstractUnit value)
Sets the value of this AbstractUnitOption.

Specified by:
setValue in interface Option<AbstractUnit>
Specified by:
setValue in class AbstractOption<AbstractUnit>
Parameters:
value - The value to be set.

getUnitType

public final UnitTypeOption getUnitType()
Get the UnitType value.

Returns:
a UnitTypeOption value

setUnitType

public final void setUnitType(UnitTypeOption newUnitType)
Set the UnitType value.

Parameters:
newUnitType - The new UnitType value.

getRole

public final StringOption getRole()
Get the Role value.

Returns:
a StringOption value

setRole

public final void setRole(StringOption newRole)
Set the Role value.

Parameters:
newRole - The new Role value.

getNumber

public final IntegerOption getNumber()
Get the Number value.

Returns:
an IntegerOption value

setNumber

public final void setNumber(IntegerOption newNumber)
Set the Number value.

Parameters:
newNumber - The new Number value.

generateChoices

public void generateChoices()
Generate the choices to provide to the UI based on the generateChoices value.

Overrides:
generateChoices in class AbstractOption<AbstractUnit>

isNullValueOK

public boolean isNullValueOK()
Returns whether null is an acceptable value for this Option. This method always returns true.

Overrides:
isNullValueOK in class AbstractOption<AbstractUnit>
Returns:
true

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.

readFromXML

public void readFromXML(javax.xml.stream.XMLStreamReader in)
                 throws javax.xml.stream.XMLStreamException
Description copied from class: FreeColObject
Initializes this object from an XML-representation of this object, unless the PARTIAL_ATTRIBUTE tag is present which indicates a partial update of an existing object.

Specified by:
readFromXML in interface Option<AbstractUnit>
Overrides:
readFromXML in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

getXMLElementTagName

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

Returns:
"unitOption".

toString

public java.lang.String toString()
Description copied from interface: Option
Returns a textual representation of this object.

Specified by:
toString in interface Option<AbstractUnit>
Overrides:
toString in class java.lang.Object
Returns:
The name of this Option.