public class PropertiesMapXML extends PropertiesMap
PropertiesMapXML
is an extension of PropertiesMap
that can transform the map into a valid XML document.
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Modifier and Type | Field and Description |
---|---|
static String |
BOOLEAN_TYPE
Used to denote a boolean property type in the property type attribute of a
property.
|
static String |
DOUBLE_TYPE
Used to denote a double precision floating point property type in the
property type attribute of a property.
|
static String |
FLOAT_TYPE
Used to denote a floating point property type in the property type
attribute of a property.
|
static String |
INTEGER_TYPE
Used to denote an integer property type in the property type attribute of
a property.
|
static String |
LONG_TYPE
Used to denote a long integer property type in the property type attribute
of a property.
|
protected boolean |
modified
Set to
true if the XML has been modified since the latest
read , write , or toString call;
false otherwise. |
private org.jdom.Document |
propertiesXML
The properties stored in their XML format.
|
static String |
PROPERTY_TYPE
Used to denote the property type attribute of a property.
|
static String |
STRING_TYPE
Used to denote a String property type in the property type attribute of a
property.
|
Constructor and Description |
---|
PropertiesMapXML()
Creates a new empty instance of the PropertiesMapXML.
|
PropertiesMapXML(InputStream xMLInputStream)
Creates a new instance of the
PropertiesMapXML from an
InputStream . |
PropertiesMapXML(Map map)
Creates a new instance of the
PropertiesMapXML from a
Map . |
PropertiesMapXML(PropertiesMap map)
Creates a new instance of the
PropertiesMapXML from another
PropertiesMap . |
PropertiesMapXML(Reader xMLReader)
Creates a new instance of the
PropertiesMapXML from a
Reader . |
PropertiesMapXML(String xMLString)
Creates a new instance of the
PropertiesMapXML from a
String . |
Modifier and Type | Method and Description |
---|---|
protected Object |
clone()
Creates a copy of this
PropertiesMapXML . |
boolean |
isModified()
Determines if the XML has been modified since the latest call to
resetModified () . |
void |
read(InputStream xMLInputStream)
Redefines the XML verion of the properties from the given
InputStream , and then modifies the map to match the new
properties. |
void |
read(Reader xMLReader)
Redefines the XML verion of the properties from the given
Reader , and then modifies the map to match the new
properties. |
void |
read(String xMLString)
Redefines the XML verion of the properties from the given
String , and then modifies the map to match the new
properties. |
void |
removeProperty(String propertyName)
Removes the property from the map and removes the corresponding XML
element.
|
void |
resetModified()
Called to reset the watch on the XML, called internally by
read , write , and toString ;
isModified will now return false until the XML
is modified again. |
void |
setAllProperties(Map map)
Redefines all of the properties to the given
Map unless it is
null . |
void |
setBoolean(String propertyName,
boolean propertyValue)
Stores a boolean property in the map and the XML.
|
void |
setDouble(String propertyName,
double propertyValue)
Stores a double precision floating point property in the map and the XML.
|
void |
setFloat(String propertyName,
float propertyValue)
Stores a floating point property in the map and the XML.
|
void |
setInteger(String propertyName,
int propertyValue)
Stores an integer property in the map and the XML.
|
void |
setLong(String propertyName,
long propertyValue)
Stores a long integer property in the map and the XML.
|
protected void |
setModified()
Called when the XML is modified for any reason.
|
void |
setProperty(String propertyName,
Property property)
Stores a property in the map.
|
void |
setString(String propertyName,
String propertyValue)
Stores a String property in the map and the XML.
|
String |
toString()
Writes the XML properties to a
String and returns it. |
private void |
updateMapFromXML()
Updates the map, assuming that the XML is initialized and correct.
|
private void |
updateXMLFromMap()
Updates the XML, asssuming that the map is initialized and correct.
|
void |
write(OutputStream xMLOutputStream)
Writes the XML properties to the given
OutputStream . |
void |
write(Writer xMLWriter)
Writes the XML properties to the given
Writer . |
clearProperties, equals, getBoolean, getByte, getChar, getDouble, getFloat, getInteger, getLong, getProperties, getProperty, getShort, getString, getType, hasProperty, keySet, setByte, setChar, setShort
private org.jdom.Document propertiesXML
protected boolean modified
true
if the XML has been modified since the latest
read
, write
, or toString
call;
false
otherwise.public static final String PROPERTY_TYPE
public static final String BOOLEAN_TYPE
public static final String STRING_TYPE
public static final String INTEGER_TYPE
public static final String LONG_TYPE
public static final String FLOAT_TYPE
public static final String DOUBLE_TYPE
public PropertiesMapXML()
Hashtable
, and initializes the
XML version.public PropertiesMapXML(PropertiesMap map)
PropertiesMapXML
from another
PropertiesMap
. Initializes the map of the properties
to a clone of the map of the given PropertiesMap
unless it
is null
. If it is null
, it initializes the map
of the properties to an empty Hashtable
. Finally, it
initializes the XML version to match.map
- A PropertiesMap
that will be used to initialize
the new object if non-null
.public PropertiesMapXML(Map map)
PropertiesMapXML
from a
Map
. Initializes the map of the properties to the given
Map
unless it is null
. If it is
null
, it initializes the map of the properties to an empty
Hashtable
. Finally, it initializes the XML version to match.map
- A Hashtable
that will be used to initialize the
new object if non-null
.public PropertiesMapXML(String xMLString)
PropertiesMapXML
from a
String
. Initializes the XML verion of the properties from
the given String
, and then initializes the map to match.xMLString
- A String
containing the XML properties that
will be used to initialize the new object.public PropertiesMapXML(Reader xMLReader)
PropertiesMapXML
from a
Reader
. Initializes the XML verion of the properties from
the given Reader
, and then initializes the map to match.xMLReader
- The Reader
that the XML properties will
be read from.public PropertiesMapXML(InputStream xMLInputStream)
PropertiesMapXML
from an
InputStream
. Initializes the XML verion of the properties
from the given InputStream
, and then initializes the map to
match.xMLInputStream
- The InputStream
that the XML
properties will be read from.public String toString()
String
and returns it.public void write(Writer xMLWriter) throws IOException
Writer
.xMLWriter
- The Writer
that the XML properties will be
written to.IOException
- If there is a problem writing the XML to the
Writer
.public void write(OutputStream xMLOutputStream) throws IOException
OutputStream
.xMLOutputStream
- The OutputStream
that the XML
properties will be written to.IOException
- If there is a problem writing the XML to the
OutputStream
.public void setAllProperties(Map map)
Map
unless it is
null
. Finally, it modifies the XML version of the properties
to match the new properties. All current properties will be lost if the
null
.setAllProperties
in class PropertiesMap
map
- The Map
that will be used to set the properties if
non-null
.public void read(String xMLString)
String
, and then modifies the map to match the new
properties. All current properties will be lost.xMLString
- The String
containing the XML properties
that will be used to set the properties.public void read(Reader xMLReader)
Reader
, and then modifies the map to match the new
properties. All current properties will be lost.xMLReader
- The Reader
containing the XML properties
that will be used to set the properties.public void read(InputStream xMLInputStream)
InputStream
, and then modifies the map to match the new
properties. All current properties will be lost.xMLInputStream
- The InputStream
containing the XML
properties that will be used to set the properties.private void updateMapFromXML()
private void updateXMLFromMap()
public void setProperty(String propertyName, Property property)
setProperty
in class PropertiesMap
propertyName
- The name of the property to store.property
- The property that matches the name given.public void setBoolean(String propertyName, boolean propertyValue)
setBoolean
in class PropertiesMap
propertyName
- The name of the property to store.propertyValue
- The value of the property that matches the name
given.public void setString(String propertyName, String propertyValue)
setString
in class PropertiesMap
propertyName
- The name of the property to store.propertyValue
- The value of the property that matches the name
given.public void setInteger(String propertyName, int propertyValue)
setInteger
in class PropertiesMap
propertyName
- The name of the property to store.propertyValue
- The value of the property that matches the name
given.public void setLong(String propertyName, long propertyValue)
setLong
in class PropertiesMap
propertyName
- The name of the property to store.propertyValue
- The value of the property that matches the name
given.public void setFloat(String propertyName, float propertyValue)
setFloat
in class PropertiesMap
propertyName
- The name of the property to store.propertyValue
- The value of the property that matches the name
given.public void setDouble(String propertyName, double propertyValue)
setDouble
in class PropertiesMap
propertyName
- The name of the property to store.propertyValue
- The value of the property that matches the name
given.public void removeProperty(String propertyName)
removeProperty
in class PropertiesMap
propertyName
- The name of the property to be removed.protected void setModified()
public void resetModified()
read
, write
, and toString
;
isModified
will now return false
until the XML
is modified again.public boolean isModified()
resetModified ()
.true
if the XML has been modified since the latest
read
, write
, or toString
call;
false
otherwise.protected Object clone()
PropertiesMapXML
. All of the
properties in the original map are copied into another map, and the XML
version is recreated.clone
in class PropertiesMap
PropertiesMap
.