net.sf.freecol.common.option
Class AbstractOption

java.lang.Object
  extended by net.sf.freecol.common.option.AbstractOption
All Implemented Interfaces:
Option
Direct Known Subclasses:
BooleanOption, IntegerOption, OptionGroup, SelectOption

public abstract class AbstractOption
extends java.lang.Object
implements Option

The super class of all options.


Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String LICENSE
           
static java.lang.String NO_ID
           
static java.lang.String REVISION
           
 
Constructor Summary
AbstractOption(java.lang.String id, java.lang.String name, java.lang.String shortDescription)
          Creates a new AbstractOption.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Adds a new PropertyChangeListener for monitoring state changes.
protected  void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Fires a PropertyChangeEvent to all listeners.
 java.lang.String getId()
          Returns the id of this Option.
 java.lang.String getName()
          Returns the name of this Option.
 java.lang.String getShortDescription()
          Gives a short description of this Option.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 void readFromXML(javax.xml.stream.XMLStreamReader in)
          Initializes this object from an XML-representation of this object.
 void readFromXMLElement(org.w3c.dom.Element element)
          Initialize this object from an XML-representation of this object.
protected abstract  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initializes this object from an XML-representation of this object.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Remove the given PropertyChangeListener.
 java.lang.String toString()
          Returns a textual representation of this object.
 void toXML(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
 org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
          This method writes an XML-representation of this object to the given stream.
protected abstract  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

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

LICENSE

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

REVISION

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

NO_ID

public static final java.lang.String NO_ID
See Also:
Constant Field Values
Constructor Detail

AbstractOption

public AbstractOption(java.lang.String id,
                      java.lang.String name,
                      java.lang.String shortDescription)
Creates a new AbstractOption.

Parameters:
id - The identifier for this option. This is used when the object should be found in an OptionGroup.
name - The name of the AbstractOption. This text is used for identifying the option for a user. Example: The text related to a checkbox.
shortDescription - Should give a short description of the Option. This might be used as a tooltip text.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds a new PropertyChangeListener for monitoring state changes. Events are generated when variables are changed.

Parameters:
pcl - The PropertyChangeListener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Remove the given PropertyChangeListener.

Parameters:
pcl - The PropertyChangeListener to be removed.

firePropertyChange

protected void firePropertyChange(java.lang.String name,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Fires a PropertyChangeEvent to all listeners.

Parameters:
name - The name of the changed variable.
oldValue - The old value.
newValue - The new value.

getShortDescription

public java.lang.String getShortDescription()
Gives a short description of this Option. Can for instance be used as a tooltip text.

Specified by:
getShortDescription in interface Option
Returns:
A short description of this Option.

toString

public java.lang.String toString()
Returns a textual representation of this object.

Specified by:
toString in interface Option
Overrides:
toString in class java.lang.Object
Returns:
The name of this Option.
See Also:
getName()

getId

public java.lang.String getId()
Returns the id of this Option.

Specified by:
getId in interface Option
Returns:
The unique identifier as provided in the constructor.

getName

public java.lang.String getName()
Returns the name of this Option.

Specified by:
getName in interface Option
Returns:
The name as provided in the constructor.

toXML

public void toXML(javax.xml.stream.XMLStreamWriter out)
           throws javax.xml.stream.XMLStreamException
Makes an XML-representation of this object.

Specified by:
toXML in interface Option
Parameters:
out - The output stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXML

public void readFromXML(javax.xml.stream.XMLStreamReader in)
                 throws javax.xml.stream.XMLStreamException
Initializes this object from an XML-representation of this object.

Specified by:
readFromXML in interface Option
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

toXMLImpl

protected abstract void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                           throws javax.xml.stream.XMLStreamException
Makes an XML-representation of this object.

Parameters:
out - The output stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected abstract void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                                 throws javax.xml.stream.XMLStreamException
Initializes this object from an XML-representation of this object.

Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

toXMLElement

public org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
This method writes an XML-representation of this object to the given stream.

Specified by:
toXMLElement in interface Option
Parameters:
document - The Document.
Returns:
An XML-representation of this object.

readFromXMLElement

public void readFromXMLElement(org.w3c.dom.Element element)
Initialize this object from an XML-representation of this object.

Specified by:
readFromXMLElement in interface Option
Parameters:
element - The DOM-element ("Document Object Model") made to represent this "Option".

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Gets the tag name of the root element representing this object.

Returns:
"option".