Package net.sf.freecol.common.option
Class LanguageOption
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.option.AbstractOption<LanguageOption.Language>
-
- net.sf.freecol.common.option.LanguageOption
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<FreeColObject>
,ObjectWithId
,Option<LanguageOption.Language>
public class LanguageOption extends AbstractOption<LanguageOption.Language>
Option for selecting a language. The possible choices are determined using the available language files in the i18n directory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LanguageOption.Language
-
Field Summary
Fields Modifier and Type Field Description private static LanguageOption.Language
DEFAULT_LANGUAGE
The default language.private static java.util.Map<java.lang.String,java.lang.String>
languageNames
Extra languages with alternate names.private static java.util.List<LanguageOption.Language>
languages
A list of know languages.private static java.util.logging.Logger
logger
static java.lang.String
TAG
private LanguageOption.Language
value
The 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 LanguageOption(Specification specification)
Creates a newLanguageOption
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LanguageOption
cloneOption()
Clone this option.java.util.List<LanguageOption.Language>
getChoices()
Gets a list of the available languages.private LanguageOption.Language
getLanguage(java.lang.String key)
Find the language with the given key.LanguageOption.Language
getValue()
Gets the value of this option.java.lang.String
getXMLTagName()
Get the serialization tag for this object.private static void
initializeLanguages()
Initialize the languages list.protected void
setValue(java.lang.String valueString, java.lang.String defaultValueString)
Sets the value of this option from the given string representation.void
setValue(LanguageOption.Language newValue)
Sets the value of this option.protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.option.AbstractOption
generateChoices, getEnabledBy, getGroup, isNullValueOK, 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, 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, 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.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, toString, 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
-
languageNames
private static final java.util.Map<java.lang.String,java.lang.String> languageNames
Extra languages with alternate names.
-
languages
private static final java.util.List<LanguageOption.Language> languages
A list of know languages. Initialized on demand with initializeLanguages(), as it depends on the location of the i18n directory having stabilized.
-
DEFAULT_LANGUAGE
private static final LanguageOption.Language DEFAULT_LANGUAGE
The default language.
-
value
private LanguageOption.Language value
The value of this option.
-
-
Constructor Detail
-
LanguageOption
public LanguageOption(Specification specification)
Creates a newLanguageOption
.- Parameters:
specification
- TheSpecification
to refer to.
-
-
Method Detail
-
initializeLanguages
private static void initializeLanguages()
Initialize the languages list.
-
getLanguage
private LanguageOption.Language getLanguage(java.lang.String key)
Find the language with the given key.- Parameters:
key
- The key to search for.- Returns:
- The corresponding language, or null if none found.
-
getChoices
public java.util.List<LanguageOption.Language> getChoices()
Gets a list of the available languages.- Returns:
- A list of the available languages.
-
cloneOption
public LanguageOption cloneOption()
Clone this option.- Specified by:
cloneOption
in interfaceOption<LanguageOption.Language>
- Specified by:
cloneOption
in classAbstractOption<LanguageOption.Language>
- Returns:
- A clone of this option.
-
getValue
public final LanguageOption.Language getValue()
Gets the value of this option.- Specified by:
getValue
in interfaceOption<LanguageOption.Language>
- Specified by:
getValue
in classAbstractOption<LanguageOption.Language>
- Returns:
- The value of this
Option
.
-
setValue
public final void setValue(LanguageOption.Language newValue)
Sets the value of this option.- Specified by:
setValue
in interfaceOption<LanguageOption.Language>
- Specified by:
setValue
in classAbstractOption<LanguageOption.Language>
- Parameters:
newValue
- The new value of thisOption
.
-
setValue
protected void setValue(java.lang.String valueString, java.lang.String defaultValueString)
Sets 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:
setValue
in classAbstractOption<LanguageOption.Language>
- Parameters:
valueString
- The string representation of the value of thisOption
.defaultValueString
- The string representation of the default value of thisOption
.
-
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:
writeAttributes
in classAbstractOption<LanguageOption.Language>
- Parameters:
xw
- TheFreeColXMLWriter
to 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:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
-