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
          extended by net.sf.freecol.common.option.LanguageOption
All Implemented Interfaces:
Option

public class LanguageOption
extends AbstractOption

Option for selecting a language. The possible choices are determined using the available language files in "data/strings".


Nested Class Summary
 class LanguageOption.Language
           
 
Field Summary
static java.lang.String AUTO
           
private  LanguageOption.Language DEFAULT
           
private static java.util.Comparator<LanguageOption.Language> languageComparator
           
private  java.util.Map<java.lang.String,java.lang.String> languageNames
           
private static java.lang.String[][] languageNamesHelper
           
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, NO_ID, previewEnabled
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE
 
Constructor Summary
LanguageOption(java.lang.String id)
          Creates a new LanguageOption.
LanguageOption(java.lang.String id, OptionGroup optionGroup)
           
LanguageOption(javax.xml.stream.XMLStreamReader in)
          Creates a new IntegerOption.
 
Method Summary
private  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.
private  void prepareLanguages()
           
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setValue(LanguageOption.Language newValue)
          Set the Value value.
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

languages

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

AUTO

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

DEFAULT

private LanguageOption.Language DEFAULT

languageNames

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

languageNamesHelper

private static final java.lang.String[][] languageNamesHelper

languageComparator

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

value

private LanguageOption.Language value
Constructor Detail

LanguageOption

public LanguageOption(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

LanguageOption

public LanguageOption(java.lang.String id)
Creates a new LanguageOption.

Parameters:
id - The identifier for this option. This is used when the object should be found in an OptionGroup.

LanguageOption

public LanguageOption(java.lang.String id,
                      OptionGroup optionGroup)
Method Detail

prepareLanguages

private void prepareLanguages()

getValue

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

Returns:
a String value

setValue

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

Parameters:
newValue - The new Value value.

getOptions

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

Returns:
The available languages in a human readable format.

findLanguages

private 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 #getStringValue().
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.

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