net.sf.freecol.common.option
Class IntegerOption

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.IntegerOption
All Implemented Interfaces:
Option
Direct Known Subclasses:
PercentageOption

public class IntegerOption
extends AbstractOption

Represents an option where the valid choice is an integer.


Field Summary
private static java.util.logging.Logger logger
           
private  int maximumValue
           
private  int minimumValue
           
private  int 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
IntegerOption(java.lang.String id, OptionGroup optionGroup, int minimumValue, int maximumValue, int defaultValue)
          Deprecated.  
IntegerOption(javax.xml.stream.XMLStreamReader in)
          Creates a new IntegerOption.
 
Method Summary
 int getMaximumValue()
          Returns the maximum allowed value.
 int getMinimumValue()
          Returns the minimum allowed value.
 int getValue()
          Gets the current value of this IntegerOption.
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(int value)
          Sets the value of this IntegerOption.
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

value

private int value

minimumValue

private int minimumValue

maximumValue

private int maximumValue
Constructor Detail

IntegerOption

public IntegerOption(java.lang.String id,
                     OptionGroup optionGroup,
                     int minimumValue,
                     int maximumValue,
                     int defaultValue)
Deprecated. 

Creates a new IntegerOption.

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.
minimumValue - The minimum allowed value.
maximumValue - The maximum allowed value.
defaultValue - The default value of this option.

IntegerOption

public IntegerOption(javax.xml.stream.XMLStreamReader in)
              throws javax.xml.stream.XMLStreamException
Creates a new IntegerOption.

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

getMinimumValue

public int getMinimumValue()
Returns the minimum allowed value.

Returns:
The minimum value allowed by this option.

getMaximumValue

public int getMaximumValue()
Returns the maximum allowed value.

Returns:
The maximum value allowed by this option.

getValue

public int getValue()
Gets the current value of this IntegerOption.

Returns:
The value.

setValue

public void setValue(int value)
Sets the value of this IntegerOption.

Parameters:
value - The value to be set.

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:
"integerOption".