|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.option.AbstractOption
net.sf.freecol.common.option.SelectOption
public class SelectOption
Represents an option where the valid choice is an integer and the choices are represented by strings. In general, these strings are localized by looking up the key of the choice, which consists of the id of the AbstractObject followed by a "." followed by the value of the option string. The automatic localization can be suppressed with the doNotLocalize parameter, however. There are two reasons to do this: either the option strings should not be localized at all (because they are language names, for example), or the option strings have already been localized (because they do not use the default keys, for example).
| Field Summary | |
|---|---|
private java.util.Map<java.lang.Integer,java.lang.String> |
itemValues
|
protected boolean |
localizedLabels
|
private static java.util.logging.Logger |
logger
|
private int |
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 | |
|---|---|
SelectOption(javax.xml.stream.XMLStreamReader in)
Creates a new SelectOption. |
|
| Method Summary | |
|---|---|
java.util.Map<java.lang.Integer,java.lang.String> |
getItemValues()
Gets the range values of this RangeOption. |
protected java.lang.String |
getStringValue()
Gets a String representation of the current value. |
int |
getValue()
Gets the current value of this SelectOption. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
java.lang.String |
getXMLItemElementTagName()
Gets the tag name of the item element This method is not static to ensure proper overriding in readFromXMLImpl. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
setValue(int value)
Sets the value of this SelectOption. |
protected void |
setValue(java.lang.String value)
Converts the given String to an Integer and calls
setValue(int). |
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 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 |
|---|
private static java.util.logging.Logger logger
private int value
protected boolean localizedLabels
private java.util.Map<java.lang.Integer,java.lang.String> itemValues
| Constructor Detail |
|---|
public SelectOption(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
SelectOption.
in - The XMSStreamReader to read the data from
javax.xml.stream.XMLStreamException| Method Detail |
|---|
public int getValue()
SelectOption.
public void setValue(int value)
SelectOption.
value - The value to be set.public java.util.Map<java.lang.Integer,java.lang.String> getItemValues()
RangeOption.
protected java.lang.String getStringValue()
String representation of the current value.
This method can be overwritten by subclasses to allow a custom save
value, since this method is used by FreeColObject.toXML(XMLStreamWriter).
setValue(String)protected void setValue(java.lang.String value)
String to an Integer and calls
setValue(int).
FreeColObject.readFromXML(XMLStreamReader).
value - The String value of the Integer.getStringValue()
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class FreeColObjectout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to the
stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.public static java.lang.String getXMLElementTagName()
public java.lang.String getXMLItemElementTagName()
readFromXMLImpl.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||