Package net.sf.freecol.common.option
Class ModOption
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.option.AbstractOption<FreeColModFile>
-
- net.sf.freecol.common.option.ModOption
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<FreeColObject>,ObjectWithId,Option<FreeColModFile>
public class ModOption extends AbstractOption<FreeColModFile>
Represents an option that can be an arbitrary string.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerloggerstatic java.lang.StringTAGprivate FreeColModFilevalueThe value of this option.-
Fields inherited from class net.sf.freecol.common.option.AbstractOption
ACTION_TAG, DEFAULT_VALUE_TAG, isDefined
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description ModOption(Specification specification)Creates a newModOption.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModOptioncloneOption()Clone this option.booleanequals(java.lang.Object o)java.util.List<FreeColModFile>getChoices()Get the choices available for this option.FreeColModFilegetValue()Gets the current value of thisModOption.java.lang.StringgetXMLTagName()Get the serialization tag for this object.inthashCode()booleanisNullValueOK()Is null an acceptable value for this option? Override this in subclasses where necessary.protected voidsetValue(java.lang.String valueString, java.lang.String defaultValueString)Sets the value of this option from the given string representation.voidsetValue(FreeColModFile value)Sets the current value of this option.java.lang.StringtoString()protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.option.AbstractOption
generateChoices, getEnabledBy, getGroup, readAttributes, readOption, setGroup, setValues
-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObject
copyIn, getSpecification, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.freecol.common.ObjectWithId
getId
-
Methods inherited from interface net.sf.freecol.common.option.Option
readFromXML, toXML
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
value
private FreeColModFile value
The value of this option.
-
-
Constructor Detail
-
ModOption
public ModOption(Specification specification)
Creates a newModOption.- Parameters:
specification- TheSpecificationto refer to.
-
-
Method Detail
-
getChoices
public final java.util.List<FreeColModFile> getChoices()
Get the choices available for this option.- Returns:
- A list of
FreeColModFiles.
-
cloneOption
public ModOption cloneOption()
Clone this option.- Specified by:
cloneOptionin interfaceOption<FreeColModFile>- Specified by:
cloneOptionin classAbstractOption<FreeColModFile>- Returns:
- A clone of this option.
-
getValue
public FreeColModFile getValue()
Gets the current value of thisModOption.- Specified by:
getValuein interfaceOption<FreeColModFile>- Specified by:
getValuein classAbstractOption<FreeColModFile>- Returns:
- The value.
-
setValue
public void setValue(FreeColModFile value)
Sets the current value of this option.- Specified by:
setValuein interfaceOption<FreeColModFile>- Specified by:
setValuein classAbstractOption<FreeColModFile>- Parameters:
value- The new value.
-
setValue
protected void setValue(java.lang.String valueString, java.lang.String defaultValueString) throws javax.xml.stream.XMLStreamExceptionSets the value of this option from the given string representation. Both parameters must not be null at the same time. This method does nothing. Override it if the option has a suitable string representation.- Overrides:
setValuein classAbstractOption<FreeColModFile>- Parameters:
valueString- The string representation of the value of thisOption.defaultValueString- The string representation of the default value of thisOption.- Throws:
javax.xml.stream.XMLStreamException- if the value is invalid.
-
isNullValueOK
public boolean isNullValueOK()
Is null an acceptable value for this option? Override this in subclasses where necessary.- Overrides:
isNullValueOKin classAbstractOption<FreeColModFile>- Returns:
- False.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributesin classAbstractOption<FreeColModFile>- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classFreeColObject
-
hashCode
public int hashCode()
- Overrides:
hashCodein classFreeColObject
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfaceOption<FreeColModFile>- Overrides:
toStringin classFreeColObject
-
-