public class UserMapXML extends UserMap
Title: KnownUsersMapXML
Description: Extension of KnownUsersMap. Can transform a map to a proper 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 |
---|---|
private org.jdom.Document |
knownUsersXML
The properties stored in their XML format.
|
protected boolean |
modified
Set to
true if the XML has been modified since the latest
read , write , or toString call;
false otherwise. |
static String |
PROPERTY_TYPE
Used to denote the property type attribute of a property.
|
static String |
STRING_TYPE
Used to denote a boolean property type in the property type attribute of a
property.
|
Constructor and Description |
---|
UserMapXML()
Creates a new empty instance of the KnownUsersMapXML.
|
UserMapXML(Hashtable map)
Creates a new instance of the
KnownUsersMapXML from a
Hashtable . |
UserMapXML(InputStream xMLInputStream)
Creates a new instance of the
KnownUsersMapXML from an
InputStream . |
UserMapXML(Reader xMLReader)
Creates a new instance of the
KnownUsersMapXML from a
Reader . |
UserMapXML(String xMLString)
Creates a new instance of the
KnownUsersMapXML from a
String . |
UserMapXML(UserMap map)
Creates a new instance of the
KnownUsersMapXML from another
KnownUsersMap . |
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 userName)
Removes the knownUser 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(Hashtable map)
Redefines all of the properties to the given
Hashtable unless
it is null . |
protected void |
setModified()
Called when the XML is modified for any reason.
|
void |
setProperty(String userName,
Property property)
Stores a kownUser in the map.
|
void |
setString(String userName,
String userValue)
Stores a String knownUser in the map and the XML.
|
String |
toString()
Writes the XML properties to a
String and returns it. |
private void |
updateMapFromXML()
Updates the map, usssuming 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 knownUsers to the given
OutputStream . |
void |
write(Writer xMLWriter)
Writes the XML properties to the given
Writer . |
clearProperties, equals, getProperties, getProperty, getString, getType, hasProperty
private org.jdom.Document knownUsersXML
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 STRING_TYPE
public UserMapXML()
Hashtable
, and initializes the
XML version.public UserMapXML(UserMap map)
KnownUsersMapXML
from another
KnownUsersMap
. Initializes the map of the properties
to a clone of the map of the given KnownUsersMap
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 KnownUsersMap
that will be used to initialize
the new object if non-null
.public UserMapXML(Hashtable map)
KnownUsersMapXML
from a
Hashtable
. Initializes the map of the properties to the
given Hashtable
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 UserMapXML(String xMLString)
KnownUsersMapXML
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 UserMapXML(Reader xMLReader)
KnownUsersMapXML
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 UserMapXML(InputStream xMLInputStream)
KnownUsersMapXML
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(Hashtable map)
Hashtable
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 setAllProperties
in class UserMap
map
- The Hashtable
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 userName, Property property)
setProperty
in class UserMap
userName
- The name of the property to store.property
- The property that matches the name given.public void setString(String userName, String userValue)
public void removeProperty(String userName)
removeProperty
in class UserMap
userName
- 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.