public abstract class PrimitiveXMLEncodeDecode extends Object implements XMLEncodeDecode
It contains the XMLEncodeDecode
interface (with an
unimplemented encode() method) and a number of support methods for
encoding and decoding primitive values.
This implementation also provides default implementations of
ChangeListener
methods that allow an extending class to
provide services for registering, responding and issuing
ChangeEvent
s.
Modifier and Type | Field and Description |
---|---|
protected EventListenerList |
listeners |
Constructor and Description |
---|
PrimitiveXMLEncodeDecode() |
Modifier and Type | Method and Description |
---|---|
static CDATASection |
addCDATASection(Element rootElement,
String value)
Create a new CDATA section with the given content and add it as
a child of a given element.
|
void |
addChangeListener(ChangeListener l)
Registers a listener who wants to be informed about changes.
|
static Element |
addChildElement(Element rootElement,
String name)
Create a child element with no content and add it to the given
element.
|
static Element |
addChildElement(Element rootElement,
String name,
boolean value)
Add an element with boolean value as a child of another element.
|
static Element |
addChildElement(Element rootElement,
String name,
double value)
Add an element with double value as a child of another element.
|
static Element |
addChildElement(Element rootElement,
String name,
int value)
Add an element with integer value as a child of another element.
|
static Element |
addChildElement(Element rootElement,
String name,
String value)
Add an element with String value as a child of another element.
|
static boolean |
booleanFromString(String value)
Convert a String back to a boolean.
|
static String |
booleanToString(boolean value)
Convert a boolean to a String.
|
void |
decode(Element rootElement)
Decode (ie, restore) the internal state of this object from an
Element.
|
static double |
doubleFromString(String value)
Convert a String back to a double.
|
static String |
doubleToString(double value)
Convert a double to a String.
|
abstract void |
encode(Element rootElement)
Encode the internal state of this object so that it is rooted
in the given Element.
|
protected void |
fireChanged()
Send ChangeEvent event to all listeners.
|
static List<Element> |
getChildElements(Element element)
Return all the Elements that are children of another Element.
|
static NodeList |
getChildren(Element rootElement)
Return a List of all children.
|
static String |
getElementName(Element element)
Get the name of an element.
|
static String |
getElementValue(Element element)
Get the "value" of an element (really the content).
|
static int |
intFromString(String value)
Convert a String back to an integer.
|
static String |
intToString(int value)
Convert an integer to a String.
|
static long |
longFromString(String value)
Convert a String back to a long.
|
static String |
longToString(long value)
Convert a long to a String.
|
void |
removeChangeListener(ChangeListener l)
De-registers a listener for changes.
|
abstract void |
setFromString(String name,
String value)
Set the value of a object field using string representation of
the field name and its value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTagName
protected EventListenerList listeners
public void addChangeListener(ChangeListener l)
l
- the ChangeListener listener.public void removeChangeListener(ChangeListener l)
l
- the ChangeListener listener.protected void fireChanged()
public abstract void encode(Element rootElement)
XMLEncodeDecode
encode
in interface XMLEncodeDecode
rootElement
- the Element within which the object should
store its configuration.public void decode(Element rootElement)
XMLEncodeDecode
decode
in interface XMLEncodeDecode
rootElement
- the element to which a previous object this
this type has attached its configuration.public static List<Element> getChildElements(Element element)
public abstract void setFromString(String name, String value)
public static Element addChildElement(Element rootElement, String name)
public static CDATASection addCDATASection(Element rootElement, String value)
public static Element addChildElement(Element rootElement, String name, String value)
public static Element addChildElement(Element rootElement, String name, boolean value)
public static Element addChildElement(Element rootElement, String name, int value)
public static Element addChildElement(Element rootElement, String name, double value)
public static NodeList getChildren(Element rootElement)
public static String getElementValue(Element element)
public static String doubleToString(double value)
public static double doubleFromString(String value)
public static String booleanToString(boolean value)
public static boolean booleanFromString(String value)
public static String intToString(int value)
public static int intFromString(String value)
public static String longToString(long value)
public static long longFromString(String value)
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.