Class JiBXUtil
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
readObject
(Class<T> targetClass, InputStream input) Read in an object encoded as XML.static <T> T
readObject
(Class<T> targetClass, Reader input) Read in an object encoded as XML.static <T> T
readObject
(Class<T> targetClass, String bindingName, InputStream input) Read in an object encoded as XML.static <T> T
readObject
(Class<T> targetClass, String bindingName, Reader input) Read in an object encoded as XML.static <T> T
readObject
(Class<T> targetClass, String bindingName, URL url) Read in an object encoded as XML from anURL
.static <T> T
readObject
(Class<T> targetClass, URL url) Read in an object encoded as XML from anURL
.static String
Encode the given instance as an XML document and return it as aString
.static String
Encode the given instance as an XML document and return it as aString
.static void
writeObject
(Object obj, String bindingName, Writer writer) Write out the given instance encoded as an XML document with "UTF-8" as the declared encoding.static <T> void
writeObject
(T obj, OutputStream output) Write out the given instance encoded as a UTF-8 encoded XML document.static <T> void
writeObject
(T obj, Writer writer) Write out the given instance encoded as an XML document with "UTF-8" as the declared encoding.static <T> void
writeObject
(T obj, String bindingName, OutputStream output) Write out the given instance encoded as a UTF-8 encoded XML document.
-
Field Details
-
XML_ENCODING
- See Also:
-
-
Method Details
-
readObject
public static <T> T readObject(Class<T> targetClass, InputStream input) throws JiBXException, IOException Read in an object encoded as XML. This method assumes there is exactly one binding for the given class.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).The
input
is not closed by this method.- Type Parameters:
T
- type of object to read- Parameters:
targetClass
- target classinput
- source for the XML document- Returns:
- decoded object
- Throws:
JiBXException
- if there is a JiBX parse errorIOException
- if an error occurs reading frominput
-
readObject
public static <T> T readObject(Class<T> targetClass, String bindingName, InputStream input) throws JiBXException, IOException Read in an object encoded as XML.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).The
input
is not closed by this method.- Type Parameters:
T
- type of object to read- Parameters:
targetClass
- target classbindingName
- binding name, or null to choose the only oneinput
- source for the XML document- Returns:
- decoded object
- Throws:
JiBXException
- if there is a JiBX parse errorIOException
- if an error occurs reading frominput
-
readObject
public static <T> T readObject(Class<T> targetClass, Reader input) throws JiBXException, IOException Read in an object encoded as XML. This method assumes there is exactly one binding for the given class.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).The
input
is not closed by this method.- Type Parameters:
T
- type of object to read- Parameters:
targetClass
- target classinput
- source for the XML document- Returns:
- decoded object
- Throws:
JiBXException
- if there is a JiBX parse errorIOException
- if an error occurs reading frominput
-
readObject
public static <T> T readObject(Class<T> targetClass, String bindingName, Reader input) throws JiBXException, IOException Read in an object encoded as XML.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).The
input
is not closed by this method.- Type Parameters:
T
- type of object to read- Parameters:
targetClass
- target classbindingName
- binding name, or null to choose the only oneinput
- source for the XML document- Returns:
- decoded object
- Throws:
JiBXException
- if there is a JiBX parse errorIOException
- if an error occurs reading frominput
-
readObject
Read in an object encoded as XML from anURL
. This method assumes there is exactly one binding for the given class.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Type Parameters:
T
- type of object to read- Parameters:
targetClass
- target classurl
- source for the XML document- Returns:
- decoded object
- Throws:
JiBXException
- if there is a JiBX parse errorIOException
- if an error occurs reading the referenced document
-
readObject
public static <T> T readObject(Class<T> targetClass, String bindingName, URL url) throws JiBXException, IOException Read in an object encoded as XML from anURL
.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Type Parameters:
T
- type of object to read- Parameters:
targetClass
- target classurl
- source for the XML documentbindingName
- binding name, or null to choose the only one- Returns:
- decoded object
- Throws:
JiBXException
- if there is a JiBX parse errorIOException
- if an error occurs reading the referenced document
-
writeObject
Write out the given instance encoded as a UTF-8 encoded XML document. This method assumes there is exactly one binding for the given class.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Type Parameters:
T
- object type- Parameters:
obj
- object to writeoutput
- output destination; will not be closed by this method- Throws:
JiBXException
- if there is a JiBX encoding errorIOException
- if an error occurs writing tooutput
-
writeObject
public static <T> void writeObject(T obj, String bindingName, OutputStream output) throws JiBXException, IOException Write out the given instance encoded as a UTF-8 encoded XML document.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Type Parameters:
T
- object type- Parameters:
obj
- object to writebindingName
- binding name, or null to choose the only oneoutput
- output destination; will not be closed by this method- Throws:
JiBXException
- if there is a JiBX encoding errorIOException
- if an error occurs writing tooutput
-
writeObject
Write out the given instance encoded as an XML document with "UTF-8" as the declared encoding. This method assumes there is exactly one binding for the given class.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Type Parameters:
T
- object type- Parameters:
obj
- object to writewriter
- output destination; will not be closed by this method- Throws:
JiBXException
- if there is a JiBX encoding errorIOException
- if an error occurs writing towriter
-
writeObject
public static void writeObject(Object obj, String bindingName, Writer writer) throws JiBXException, IOException Write out the given instance encoded as an XML document with "UTF-8" as the declared encoding.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Parameters:
obj
- object to writebindingName
- binding name, or null to choose the only onewriter
- output destination; will not be closed by this method- Throws:
JiBXException
- if there is a JiBX encoding errorIOException
- if an error occurs writing towriter
-
toString
Encode the given instance as an XML document and return it as aString
. This method assumes there is exactly one binding for the given class.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Parameters:
obj
- object to encode- Returns:
- XML encoding of
obj
- Throws:
JiBXException
- if there is a JiBX encoding error
-
toString
Encode the given instance as an XML document and return it as aString
.This method runs within a new invocation of
IdGenerator.run()
to support object references (seeIdMapper
).- Parameters:
obj
- object to encodebindingName
- binding name, or null to choose the only one- Returns:
- XML encoding of
obj
- Throws:
JiBXException
- if there is a JiBX encoding error
-