Package net.sf.freecol.common.option
Class FileOption
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.option.AbstractOption<java.io.File>
-
- net.sf.freecol.common.option.FileOption
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<FreeColObject>
,ObjectWithId
,Option<java.io.File>
public class FileOption extends AbstractOption<java.io.File>
Represents an option for specifying aFile
.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
static java.lang.String
TAG
private java.lang.String
type
Extra optional qualifier for what the file is to be used for.private static java.lang.String
TYPE_TAG
private java.io.File
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 FileOption(Specification specification)
Creates a newFileOption
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileOption
cloneOption()
Clone this option.java.lang.String
getType()
Trivial type accessor.java.io.File
getValue()
Gets the value of this option.java.lang.String
getXMLTagName()
Get the serialization tag for this object.boolean
isNullValueOK()
Is null an acceptable value for this option? Override this in subclasses where necessary.protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.void
setType(java.lang.String type)
Trivial type mutator.void
setValue(java.io.File value)
Sets the value of this option.protected void
setValue(java.lang.String valueString, java.lang.String defaultValueString)
Sets the value of this option from the given string representation.java.lang.String
toString()
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, 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, 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, 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
-
value
private java.io.File value
The value of this option.
-
type
private java.lang.String type
Extra optional qualifier for what the file is to be used for.
-
TYPE_TAG
private static final java.lang.String TYPE_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileOption
public FileOption(Specification specification)
Creates a newFileOption
.- Parameters:
specification
- TheSpecification
to refer to.
-
-
Method Detail
-
getType
public java.lang.String getType()
Trivial type accessor.- Returns:
- The type.
-
setType
public void setType(java.lang.String type)
Trivial type mutator.- Parameters:
type
- The new type.
-
cloneOption
public FileOption cloneOption()
Clone this option.- Specified by:
cloneOption
in interfaceOption<java.io.File>
- Specified by:
cloneOption
in classAbstractOption<java.io.File>
- Returns:
- A clone of this option.
-
getValue
public java.io.File getValue()
Gets the value of this option.- Specified by:
getValue
in interfaceOption<java.io.File>
- Specified by:
getValue
in classAbstractOption<java.io.File>
- Returns:
- The value of this
Option
.
-
setValue
public void setValue(java.io.File value)
Sets the value of this option.- Specified by:
setValue
in interfaceOption<java.io.File>
- Specified by:
setValue
in classAbstractOption<java.io.File>
- Parameters:
value
- The new value of thisOption
.
-
isNullValueOK
public boolean isNullValueOK()
Is null an acceptable value for this option? Override this in subclasses where necessary.- Overrides:
isNullValueOK
in classAbstractOption<java.io.File>
- Returns:
- False.
-
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<java.io.File>
- 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<java.io.File>
- Parameters:
xw
- TheFreeColXMLWriter
to write to.- Throws:
javax.xml.stream.XMLStreamException
- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributes
in classAbstractOption<java.io.File>
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceOption<java.io.File>
- Overrides:
toString
in classFreeColObject
-
-