Package org.openjdk.jmc.common.util
Class StateToolkit
- java.lang.Object
- 
- org.openjdk.jmc.common.util.StateToolkit
 
- 
 public class StateToolkit extends Object 
- 
- 
Constructor SummaryConstructors Constructor Description StateToolkit()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static IWritableStatecreateWriter(String rootName)Create a new writable state.static IStatefromXMLFile(File document)Read an XML document from a file and return its structure as astate.static IStatefromXMLString(String document)Read an XML document from a string and return its structure as astate.static BooleanreadBoolean(IState state, String attribute, Boolean defaultValue)Read a boolean value from a state.static <T extends Enum<T>>
 TreadEnum(IState state, String attribute, T defaultValue, Class<T> klass)Read an enum value from a state.static FloatreadFloat(IState state, String attribute, Float defaultValue)Read a float value from a state.static IntegerreadInt(IState state, String attribute, Integer defaultValue)Read an integer value from a state.static voidsaveXMLDocumentTo(Reader reader, IWritableState state)Read an XML document from a reader and write its structure to awritable state.static IStatefulstatefulFromXMLFile(File document, Charset charset)Read an XML document from a file and return its structure as astateful object.static IStatefulstatefulFromXMLString(String document)Read an XML document from a string and return its structure as astateful object.static StringtoXMLString(IStateful state)Write a stateful state as an XML string.static voidwriteAsXml(IStateful state, Writer writer)Write a stateful state to a reader as an XML string.static voidwriteBoolean(IWritableState state, String attribute, Boolean value)Write a boolean value to a state.static <T extends Enum<T>>
 voidwriteEnum(IWritableState state, String attribute, T value)Write an enum value to a state.static voidwriteFloat(IWritableState state, String attribute, Float value)Write a float value to a state.static voidwriteInt(IWritableState state, String attribute, Integer value)Write an integer value to a state.
 
- 
- 
- 
Method Detail- 
saveXMLDocumentTopublic static void saveXMLDocumentTo(Reader reader, IWritableState state) throws SAXException, IOException, ParserConfigurationException Read an XML document from a reader and write its structure to awritable state.- Parameters:
- reader- reader to read XML from
- state- writable state to write data to
- Throws:
- SAXException
- IOException
- ParserConfigurationException
 
 - 
fromXMLStringpublic static IState fromXMLString(String document) throws SAXException Read an XML document from a string and return its structure as astate.- Parameters:
- document- string to read XML from
- Returns:
- state reflecting the XML document
- Throws:
- SAXException
 
 - 
statefulFromXMLStringpublic static IStateful statefulFromXMLString(String document) Read an XML document from a string and return its structure as astateful object.- Parameters:
- document- string to read XML from
- Returns:
- stateful object reflecting the XML document
 
 - 
statefulFromXMLFilepublic static IStateful statefulFromXMLFile(File document, Charset charset) Read an XML document from a file and return its structure as astateful object.- Parameters:
- document- file to read XML from
- Returns:
- stateful object reflecting the XML document
 
 - 
fromXMLFilepublic static IState fromXMLFile(File document) throws SAXException, IOException Read an XML document from a file and return its structure as astate.- Parameters:
- document- file to read XML from
- Returns:
- state reflecting the XML document
- Throws:
- SAXException
- IOException
 
 - 
createWriterpublic static IWritableState createWriter(String rootName) throws IOException Create a new writable state.- Parameters:
- rootName- root name of the writable state
- Returns:
- a new writable state
- Throws:
- IOException
 
 - 
toXMLStringpublic static String toXMLString(IStateful state) Write a stateful state as an XML string.- Parameters:
- state- state to write as XML
- Returns:
- an XML string reflecting the state
 
 - 
writeAsXmlpublic static void writeAsXml(IStateful state, Writer writer) throws IOException Write a stateful state to a reader as an XML string.- Parameters:
- state- state to write as XML
- writer- write to write the XML to
- Throws:
- IOException
 
 - 
writeBooleanpublic static void writeBoolean(IWritableState state, String attribute, Boolean value) Write a boolean value to a state.- Parameters:
- state- state to write to
- attribute- attribute name
- value- attribute value
- See Also:
- readBoolean(IState, String, Boolean)
 
 - 
readBooleanpublic static Boolean readBoolean(IState state, String attribute, Boolean defaultValue) Read a boolean value from a state.- Parameters:
- state- state to read from
- attribute- attribute name
- defaultValue- default attribute value
- Returns:
- attribute value if it is set in the state, defaultValueif not
- See Also:
- writeBoolean(IWritableState, String, Boolean)
 
 - 
writeFloatpublic static void writeFloat(IWritableState state, String attribute, Float value) Write a float value to a state.- Parameters:
- state- state to write to
- attribute- attribute name
- value- attribute value
- See Also:
- readFloat(IState, String, Float)
 
 - 
readFloatpublic static Float readFloat(IState state, String attribute, Float defaultValue) Read a float value from a state.- Parameters:
- state- state to read from
- attribute- attribute name
- defaultValue- default attribute value
- Returns:
- attribute value if it is set in the state, defaultValueif not
- See Also:
- writeFloat(IWritableState, String, Float)
 
 - 
writeIntpublic static void writeInt(IWritableState state, String attribute, Integer value) Write an integer value to a state.- Parameters:
- state- state to write to
- attribute- attribute name
- value- attribute value
- See Also:
- readInt(IState, String, Integer)
 
 - 
readIntpublic static Integer readInt(IState state, String attribute, Integer defaultValue) Read an integer value from a state.- Parameters:
- state- state to read from
- attribute- attribute name
- defaultValue- default attribute value
- Returns:
- attribute value if it is set in the state, defaultValueif not
- See Also:
- writeInt(IWritableState, String, Integer)
 
 - 
writeEnumpublic static <T extends Enum<T>> void writeEnum(IWritableState state, String attribute, T value) Write an enum value to a state.- Parameters:
- state- state to write to
- attribute- attribute name
- value- attribute value
- See Also:
- readEnum(IState, String, Enum, Class)
 
 - 
readEnumpublic static <T extends Enum<T>> T readEnum(IState state, String attribute, T defaultValue, Class<T> klass) Read an enum value from a state.- Parameters:
- state- state to read from
- attribute- attribute name
- defaultValue- default attribute value
- klass- enum class of the attribute value
- Returns:
- attribute value if it is set in the state, defaultValueif not
- See Also:
- writeEnum(IWritableState, String, Enum)
 
 
- 
 
-