Package net.sf.freecol.common.option
Class AbstractOption<T>
- java.lang.Object
- 
- net.sf.freecol.common.model.FreeColObject
- 
- net.sf.freecol.common.model.FreeColSpecObject
- 
- net.sf.freecol.common.option.AbstractOption<T>
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- java.lang.Comparable<FreeColObject>,- ObjectWithId,- Option<T>
 - Direct Known Subclasses:
- AbstractUnitOption,- AudioMixerOption,- BooleanOption,- FileOption,- IntegerOption,- LanguageOption,- ListOption,- ModOption,- OptionGroup,- StringOption,- TextOption,- UnitTypeOption
 
 public abstract class AbstractOption<T> extends FreeColSpecObject implements Option<T> The super class of all options. GUI components making use of this class can refer to its name and shortDescription properties. The complete keys of these properties consist of the identifier of the option group (if any), followed by a "." unless the option group is null, followed by the identifier of the option object, followed by a ".", followed by "name" or "shortDescription".
- 
- 
Field SummaryFields Modifier and Type Field Description protected static java.lang.StringACTION_TAGprotected static java.lang.StringDEFAULT_VALUE_TAGprivate static java.lang.StringENABLED_BY_TAGprivate java.lang.StringenabledByprotected booleanisDefinedDetermine if the option has been defined.private static java.util.logging.Loggerloggerprivate java.lang.StringoptionGroupIdThe option group prefix.- 
Fields inherited from class net.sf.freecol.common.model.FreeColObjectARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractOption(java.lang.String id)Creates a newAbstractOption.protectedAbstractOption(java.lang.String id, Specification specification)Creates a newAbstractOption.AbstractOption(Specification specification)Creates a newAbstractOption.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AbstractOption<T>cloneOption()Clone this option.voidgenerateChoices()Generate the choices to provide to the UI.java.lang.StringgetEnabledBy()Gets the key of anBooleanOptionthat must be true for this option to be enabled.java.lang.StringgetGroup()Gets the option group identifier for this option.abstract TgetValue()Gets the value of this option.booleanisNullValueOK()Is null an acceptable value for this option? Override this in subclasses where necessary.protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.protected AbstractOptionreadOption(FreeColXMLReader xr)General option reader routine.voidsetGroup(java.lang.String group)Set the option group for this option.protected voidsetValue(java.lang.String valueString, java.lang.String defaultValueString)Sets the value of this option from the given string representation.abstract voidsetValue(T value)Sets the value of this option.protected voidsetValues(AbstractOption<T> source)Sets the values from another option.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.- 
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObjectcopyIn, getSpecification, setSpecification
 - 
Methods inherited from class net.sf.freecol.common.model.FreeColObjectaddAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, 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, getXMLTagName, hasAbility, hasAbility, hasAbility, hashCode, 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, toString, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface net.sf.freecol.common.ObjectWithIdgetId
 - 
Methods inherited from interface net.sf.freecol.common.option.OptionreadFromXML, toString, toXML
 
- 
 
- 
- 
- 
Field Detail- 
loggerprivate static final java.util.logging.Logger logger 
 - 
ENABLED_BY_TAGprivate static final java.lang.String ENABLED_BY_TAG - See Also:
- Constant Field Values
 
 - 
optionGroupIdprivate java.lang.String optionGroupId The option group prefix.
 - 
isDefinedprotected boolean isDefined Determine if the option has been defined. When defined an option won't change when a default value is read from an XML file.
 - 
enabledByprivate java.lang.String enabledBy 
 - 
ACTION_TAGprotected static final java.lang.String ACTION_TAG - See Also:
- Constant Field Values
 
 - 
DEFAULT_VALUE_TAGprotected static final java.lang.String DEFAULT_VALUE_TAG - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
AbstractOptionprotected AbstractOption(java.lang.String id, Specification specification)Creates a newAbstractOption.- Parameters:
- id- The object identifier.
- specification- The- Specificationto refer to.
 
 - 
AbstractOptionprotected AbstractOption(java.lang.String id) Creates a newAbstractOption.- Parameters:
- id- The object identifier.
 
 - 
AbstractOptionpublic AbstractOption(Specification specification) Creates a newAbstractOption.- Parameters:
- specification- The- Specificationto refer to.
 
 
- 
 - 
Method Detail- 
setValuesprotected void setValues(AbstractOption<T> source) Sets the values from another option.- Parameters:
- source- The other- AbstractOption.
 
 - 
setValueprotected 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.- Parameters:
- valueString- The string representation of the value of this- Option.
- defaultValueString- The string representation of the default value of this- Option.
- Throws:
- javax.xml.stream.XMLStreamException- if the value is invalid.
 
 - 
generateChoicespublic void generateChoices() Generate the choices to provide to the UI. Override if the subclass needs to determine its choices dynamically.
 - 
isNullValueOKpublic boolean isNullValueOK() Is null an acceptable value for this option? Override this in subclasses where necessary.- Returns:
- False.
 
 - 
cloneOptionpublic abstract AbstractOption<T> cloneOption() throws java.lang.CloneNotSupportedException Clone this option.- Specified by:
- cloneOptionin interface- Option<T>
- Returns:
- A clone of this option.
- Throws:
- java.lang.CloneNotSupportedException- if we can not clone.
 
 - 
getGrouppublic java.lang.String getGroup() Gets the option group identifier for this option.
 - 
setGrouppublic void setGroup(java.lang.String group) Set the option group for this option.
 - 
getValuepublic abstract T getValue() Gets the value of this option.
 - 
setValuepublic abstract void setValue(T value) Sets the value of this option.
 - 
getEnabledBypublic java.lang.String getEnabledBy() Gets the key of anBooleanOptionthat must be true for this option to be enabled.- Specified by:
- getEnabledByin interface- Option<T>
- Returns:
- The key of the BooleanOptionthat needs to be enabled.
 
 - 
readAttributesprotected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException Reads the attributes of this object from an XML stream.- Overrides:
- readAttributesin class- FreeColObject
- Parameters:
- xr- The- FreeColXMLReaderto read from.
- Throws:
- javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
 
 - 
writeAttributesprotected 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 class- FreeColObject
- Parameters:
- xw- The- FreeColXMLWriterto write to.
- Throws:
- javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
 
 - 
readOptionprotected AbstractOption readOption(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException General option reader routine.- Parameters:
- xr- The- FreeColXMLReaderto read from.
- Returns:
- An option.
- Throws:
- javax.xml.stream.XMLStreamException- on stream errors.
 
 
- 
 
-