|
|||||||||
| 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.OptionGroup
net.sf.freecol.common.option.OptionMap
public abstract class OptionMap
Used for grouping objects of Option.
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private java.util.HashMap<java.lang.String,Option> |
values
|
private java.lang.String |
xmlTagName
|
| 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 | |
|---|---|
OptionMap(org.w3c.dom.Element element,
java.lang.String xmlTagName)
Creates an OptionMap from an XML representation. |
|
OptionMap(java.lang.String xmlTagName)
Creates a new OptionMap. |
|
OptionMap(javax.xml.stream.XMLStreamReader in,
java.lang.String xmlTagName)
Creates an OptionMap from an XML representation. |
|
| Method Summary | |
|---|---|
protected abstract void |
addDefaultOptions()
Adds the default options to this OptionMap. |
void |
addToMap(OptionGroup og)
Adds the Options from the given OptionGroup
to the Map. |
private static javax.xml.stream.XMLStreamReader |
createXMLStreamReader(java.io.File file)
Creates a XMLStreamReader for reading the given file. |
boolean |
getBoolean(java.lang.String id)
Gets the boolean value of an option. |
java.io.File |
getFile(java.lang.String id)
Gets the File specified by an option. |
int |
getInteger(java.lang.String id)
Gets the integer value of an option. |
Option |
getObject(java.lang.String id)
Gets the object identified by the given id. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
protected abstract boolean |
isCorrectTagName(java.lang.String tagName)
|
void |
load(java.io.File loadFile)
Reads the options from the given file. |
void |
putOption(Option option)
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
save(java.io.File saveFile)
Writes the options to the given file. |
void |
setFile(java.lang.String id,
java.io.File newFileValue)
Allow a File to be set in other ways, as from the user using the Client. |
void |
toXML(javax.xml.stream.XMLStreamWriter out)
This method writes an XML-representation of this object to the given stream. |
private void |
updateFromXML(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
| Methods inherited from class net.sf.freecol.common.option.OptionGroup |
|---|
add, getName, getShortDescription, iterator, removeAll, toXMLImpl |
| Methods inherited from class net.sf.freecol.common.option.AbstractOption |
|---|
getGroup, 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, toXMLElement |
| Field Detail |
|---|
private static java.util.logging.Logger logger
private java.lang.String xmlTagName
private java.util.HashMap<java.lang.String,Option> values
| Constructor Detail |
|---|
public OptionMap(java.lang.String xmlTagName)
OptionMap.
xmlTagName - The tag name that should be used for the parent XML-element
returned by Option.toXMLElement(org.w3c.dom.Document).
public OptionMap(javax.xml.stream.XMLStreamReader in,
java.lang.String xmlTagName)
throws javax.xml.stream.XMLStreamException
OptionMap from an XML representation.
in - The XML stream to read the data from.xmlTagName - The tag name that should be used for the parent XML-element
returned by Option.toXMLElement(org.w3c.dom.Document).
javax.xml.stream.XMLStreamException - if an error occured during parsing.
public OptionMap(org.w3c.dom.Element element,
java.lang.String xmlTagName)
OptionMap from an XML representation.
element - The XML Element from which this object
should be constructed.xmlTagName - The tag name that should be used for the parent XML-element
returned by Option.toXMLElement(org.w3c.dom.Document).| Method Detail |
|---|
protected abstract void addDefaultOptions()
OptionMap.
Needs to be implemented by subclasses.
public Option getObject(java.lang.String id)
id.
id - The ID.
Object with the given ID.public int getInteger(java.lang.String id)
id - The id of the option.
java.lang.IllegalArgumentException - If there is no integer
value associated with the specified option.
java.lang.NullPointerException - if the given Option does not exist.public boolean getBoolean(java.lang.String id)
id - The id of the option.
java.lang.IllegalArgumentException - If there is no boolean
value associated with the specified option.
java.lang.NullPointerException - if the given Option does not exist.public java.io.File getFile(java.lang.String id)
File specified by an option.
id - The id of the option.
java.lang.IllegalArgumentException - If there is no File
associated with the specified option.
java.lang.NullPointerException - if the given Option does not exist.public void addToMap(OptionGroup og)
Options from the given OptionGroup
to the Map. This is done recursively if the specified
group has any sub-groups.
og - The OptionGroup to be added.public void putOption(Option option)
private static javax.xml.stream.XMLStreamReader createXMLStreamReader(java.io.File file)
throws java.io.IOException
XMLStreamReader for reading the given file.
Compression is automatically detected.
file - The file to be read.
XMLStreamReader.
java.io.IOException - if thrown while loading the game or if a
XMLStreamException have been thrown by the
parser.protected abstract boolean isCorrectTagName(java.lang.String tagName)
public void load(java.io.File loadFile)
loadFile - The File to read the
options from.public void save(java.io.File saveFile)
saveFile - The file where the client options should be written.ClientOptions
public void toXML(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXML in interface OptiontoXML in class FreeColObjectout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.FreeColObject.toXML(XMLStreamWriter, Player, boolean, boolean)
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class OptionGroupin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
private void updateFromXML(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
in - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public static java.lang.String getXMLElementTagName()
java.lang.UnsupportedOperationException - at any time, since this
class should get it's XML tag name in the
constructor
public void setFile(java.lang.String id,
java.io.File newFileValue)
id - newFileValue -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||