Package org.openjdk.jmc.common.util
Class StateElementWriter
- java.lang.Object
-
- org.openjdk.jmc.common.util.StateElementWriter
-
- All Implemented Interfaces:
IWritableState
class StateElementWriter extends java.lang.Object implements IWritableState
A wrapper class used to write to an XML document using theIWritableState
interface.
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
StateElementWriter(java.lang.String rootName)
Create a writer with a new XML document.(package private)
StateElementWriter(org.w3c.dom.Document document)
Create a writer with an existing XML document.private
StateElementWriter(org.w3c.dom.Document document, org.w3c.dom.Element element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IWritableState
createChild(java.lang.String type)
Creates a new child node.void
putString(java.lang.String key, java.lang.String value)
Stores a named attribute value.java.lang.String
toString()
Get the XML document as a string.void
write(java.io.Writer writer)
Print the XML document to a writer.
-
-
-
Constructor Detail
-
StateElementWriter
StateElementWriter(java.lang.String rootName) throws java.io.IOException
Create a writer with a new XML document.- Parameters:
rootName
- the name of the XML root element- Throws:
java.io.IOException
- if there is a problem creating the XML document
-
StateElementWriter
StateElementWriter(org.w3c.dom.Document document)
Create a writer with an existing XML document.- Parameters:
document
- XML document to write to
-
StateElementWriter
private StateElementWriter(org.w3c.dom.Document document, org.w3c.dom.Element element)
-
-
Method Detail
-
createChild
public IWritableState createChild(java.lang.String type)
Description copied from interface:IWritableState
Creates a new child node. Multiple nodes of the same type are permitted.- Specified by:
createChild
in interfaceIWritableState
- Parameters:
type
- node type- Returns:
- a new child node
-
putString
public void putString(java.lang.String key, java.lang.String value)
Description copied from interface:IWritableState
Stores a named attribute value. Multiple values with the same key is not supported. If called multiple times with the same key then only the latest value should be kept.- Specified by:
putString
in interfaceIWritableState
- Parameters:
key
- attribute keyvalue
- attribute value
-
write
public void write(java.io.Writer writer)
Print the XML document to a writer.- Parameters:
writer
- writer to print the XML document to
-
toString
public java.lang.String toString()
Get the XML document as a string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the XML document as a string
-
-