public class StateToolkit extends Object
Constructor and Description |
---|
StateToolkit() |
Modifier and Type | Method and Description |
---|---|
static IWritableState |
createWriter(String rootName)
Create a new writable state.
|
static IState |
fromXMLFile(File document)
Read an XML document from a file and return its structure as a
state . |
static IState |
fromXMLString(String document)
Read an XML document from a string and return its structure as a
state . |
static Boolean |
readBoolean(IState state,
String attribute,
Boolean defaultValue)
Read a boolean value from a state.
|
static <T extends Enum<T>> |
readEnum(IState state,
String attribute,
T defaultValue,
Class<T> klass)
Read an enum value from a state.
|
static Float |
readFloat(IState state,
String attribute,
Float defaultValue)
Read a float value from a state.
|
static Integer |
readInt(IState state,
String attribute,
Integer defaultValue)
Read an integer value from a state.
|
static void |
saveXMLDocumentTo(Reader reader,
IWritableState state)
Read an XML document from a reader and write its structure to a
writable state . |
static IStateful |
statefulFromXMLFile(File document,
Charset charset)
Read an XML document from a file and return its structure as a
stateful
object . |
static IStateful |
statefulFromXMLString(String document)
Read an XML document from a string and return its structure as a
stateful
object . |
static String |
toXMLString(IStateful state)
Write a stateful state as an XML string.
|
static void |
writeAsXml(IStateful state,
Writer writer)
Write a stateful state to a reader as an XML string.
|
static void |
writeBoolean(IWritableState state,
String attribute,
Boolean value)
Write a boolean value to a state.
|
static <T extends Enum<T>> |
writeEnum(IWritableState state,
String attribute,
T value)
Write an enum value to a state.
|
static void |
writeFloat(IWritableState state,
String attribute,
Float value)
Write a float value to a state.
|
static void |
writeInt(IWritableState state,
String attribute,
Integer value)
Write an integer value to a state.
|
public static void saveXMLDocumentTo(Reader reader, IWritableState state) throws SAXException, IOException, ParserConfigurationException
writable state
.reader
- reader to read XML fromstate
- writable state to write data toSAXException
IOException
ParserConfigurationException
public static IState fromXMLString(String document) throws SAXException
state
.document
- string to read XML fromSAXException
public static IStateful statefulFromXMLString(String document)
stateful
object
.document
- string to read XML frompublic static IStateful statefulFromXMLFile(File document, Charset charset)
stateful
object
.document
- file to read XML frompublic static IState fromXMLFile(File document) throws SAXException, IOException
state
.document
- file to read XML fromSAXException
IOException
public static IWritableState createWriter(String rootName) throws IOException
rootName
- root name of the writable stateIOException
public static String toXMLString(IStateful state)
state
- state to write as XMLpublic static void writeAsXml(IStateful state, Writer writer) throws IOException
state
- state to write as XMLwriter
- write to write the XML toIOException
public static void writeBoolean(IWritableState state, String attribute, Boolean value)
state
- state to write toattribute
- attribute namevalue
- attribute valuereadBoolean(IState, String, Boolean)
public static Boolean readBoolean(IState state, String attribute, Boolean defaultValue)
state
- state to read fromattribute
- attribute namedefaultValue
- default attribute valuedefaultValue
if notwriteBoolean(IWritableState, String, Boolean)
public static void writeFloat(IWritableState state, String attribute, Float value)
state
- state to write toattribute
- attribute namevalue
- attribute valuereadFloat(IState, String, Float)
public static Float readFloat(IState state, String attribute, Float defaultValue)
state
- state to read fromattribute
- attribute namedefaultValue
- default attribute valuedefaultValue
if notwriteFloat(IWritableState, String, Float)
public static void writeInt(IWritableState state, String attribute, Integer value)
state
- state to write toattribute
- attribute namevalue
- attribute valuereadInt(IState, String, Integer)
public static Integer readInt(IState state, String attribute, Integer defaultValue)
state
- state to read fromattribute
- attribute namedefaultValue
- default attribute valuedefaultValue
if notwriteInt(IWritableState, String, Integer)
public static <T extends Enum<T>> void writeEnum(IWritableState state, String attribute, T value)
state
- state to write toattribute
- attribute namevalue
- attribute valuereadEnum(IState, String, Enum, Class)
public static <T extends Enum<T>> T readEnum(IState state, String attribute, T defaultValue, Class<T> klass)
state
- state to read fromattribute
- attribute namedefaultValue
- default attribute valueklass
- enum class of the attribute valuedefaultValue
if notwriteEnum(IWritableState, String, Enum)
Copyright © 2019. All rights reserved.