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 theIWritableStateinterface.
-
-
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.privateStateElementWriter(org.w3c.dom.Document document, org.w3c.dom.Element element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IWritableStatecreateChild(java.lang.String type)Creates a new child node.voidputString(java.lang.String key, java.lang.String value)Stores a named attribute value.java.lang.StringtoString()Get the XML document as a string.voidwrite(java.io.Writer writer)Print the XML document to a writer.
-
-
-
Constructor Detail
-
StateElementWriter
StateElementWriter(java.lang.String rootName) throws java.io.IOExceptionCreate 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:IWritableStateCreates a new child node. Multiple nodes of the same type are permitted.- Specified by:
createChildin 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:IWritableStateStores 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:
putStringin 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:
toStringin classjava.lang.Object- Returns:
- the XML document as a string
-
-