net.sf.freecol.common.option
Class LanguageOption

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.option.AbstractOption<LanguageOption.Language>
          extended by net.sf.freecol.common.option.LanguageOption
All Implemented Interfaces:
java.lang.Cloneable, 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 "data/strings".


Nested Class Summary
static class LanguageOption.Language
           
 
Field Summary
static java.lang.String AUTO
           
private  LanguageOption.Language DEFAULT
           
private static java.util.Comparator<LanguageOption.Language> languageComparator
           
private static java.util.Map<java.lang.String,java.lang.String> languageNames
           
private static java.util.Map<java.lang.String,LanguageOption.Language> languages
           
private static java.util.logging.Logger logger
           
private  LanguageOption.Language 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
LanguageOption(Specification specification)
          Creates a new LanguageOption.
 
Method Summary
 LanguageOption clone()
           
private static void findLanguages()
          Finds the languages available in the default directory.
static java.util.Locale getLocale(java.lang.String languageID)
          Returns the Locale decided by the given name.
 LanguageOption.Language[] getOptions()
          Returns a list of the available languages.
 LanguageOption.Language getValue()
          Get the Value value.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 void setValue(LanguageOption.Language newValue)
          Set the Value value.
protected  void setValue(java.lang.String valueString, java.lang.String defaultValueString)
          Sets the value of this Option from the given string representation.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.option.AbstractOption
generateChoices, getGroup, isNullValueOK, readAttributes, readFromXMLImpl, readOption, setGroup, 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, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeChildren
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.common.option.Option
getId, readFromXML, toString, toXML
 

Field Detail

AUTO

public static final java.lang.String AUTO
See Also:
Constant Field Values

logger

private static final java.util.logging.Logger logger

languages

private static final java.util.Map<java.lang.String,LanguageOption.Language> languages

languageNames

private static final java.util.Map<java.lang.String,java.lang.String> languageNames

DEFAULT

private LanguageOption.Language DEFAULT

value

private LanguageOption.Language value

languageComparator

private static java.util.Comparator<LanguageOption.Language> languageComparator
Constructor Detail

LanguageOption

public LanguageOption(Specification specification)
Creates a new LanguageOption.

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

clone

public LanguageOption clone()
                     throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Option<LanguageOption.Language>
Specified by:
clone in class AbstractOption<LanguageOption.Language>
Throws:
java.lang.CloneNotSupportedException

getValue

public final LanguageOption.Language getValue()
Get the Value value.

Specified by:
getValue in interface Option<LanguageOption.Language>
Specified by:
getValue in class AbstractOption<LanguageOption.Language>
Returns:
a String value

setValue

public final void setValue(LanguageOption.Language newValue)
Set the Value value.

Specified by:
setValue in interface Option<LanguageOption.Language>
Specified by:
setValue in class AbstractOption<LanguageOption.Language>
Parameters:
newValue - The new Value value.

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.

Overrides:
setValue in class AbstractOption<LanguageOption.Language>
Parameters:
valueString - the string representation of the value of this Option
defaultValueString - the string representation of the default value of this Option

getOptions

public LanguageOption.Language[] getOptions()
Returns a list of the available languages.

Returns:
The available languages in a human readable format.

findLanguages

private static void findLanguages()
Finds the languages available in the default directory.


getLocale

public static java.util.Locale getLocale(java.lang.String languageID)
Returns the Locale decided by the given name.

Parameters:
languageID - A String using the same format as getValue().
Returns:
The Locale.

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.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream.

Overrides:
writeAttributes in class FreeColObject
Parameters:
out - The target stream.
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:
"languageOption".