public class Persister extends Object implements Serializer
Persister
object is used to provide an implementation
of a serializer. This implements the Serializer
interface
and enables objects to be persisted and loaded from various sources.
This implementation makes use of Filter
objects to
replace template variables within the source XML document. It is fully
thread safe and can be shared by multiple threads without concerns.
Deserialization is performed by passing an XML schema class into one
of the read
methods along with the source of an XML stream.
The read method then reads the contents of the XML stream and builds
the object using annotations within the XML schema class.
Serialization is performed by passing an object and an XML stream into
one of the write
methods. The serialization process will
use the class of the provided object as the schema class. The object
is traversed and all fields are marshalled to the result stream.
Serializer
Constructor and Description |
---|
Persister()
Constructor for the
Persister object. |
Persister(Filter filter)
Constructor for the
Persister object. |
Persister(Filter filter,
Format format)
Constructor for the
Persister object. |
Persister(Filter filter,
Matcher matcher)
Constructor for the
Persister object. |
Persister(Filter filter,
Matcher matcher,
Format format)
Constructor for the
Persister object. |
Persister(Format format)
Constructor for the
Persister object. |
Persister(Map filter)
Constructor for the
Persister object. |
Persister(Map filter,
Format format)
Constructor for the
Persister object. |
Persister(Matcher matcher)
Constructor for the
Persister object. |
Persister(Matcher matcher,
Format format)
Constructor for the
Persister object. |
Persister(Strategy strategy)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Filter filter)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Filter filter,
Format format)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Filter filter,
Matcher matcher)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Filter filter,
Matcher matcher,
Format format)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Format format)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Map data)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Map data,
Format format)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Matcher matcher)
Constructor for the
Persister object. |
Persister(Strategy strategy,
Matcher matcher,
Format format)
Constructor for the
Persister object. |
Modifier and Type | Method and Description |
---|---|
<T> T |
read(Class<? extends T> type,
File source)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
File source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
InputNode source)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
InputNode node,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
InputStream source)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
InputStream source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
Reader source)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
Reader source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
String source)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(Class<? extends T> type,
String source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. |
<T> T |
read(T value,
File source)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
File source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
InputNode source)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
InputNode node,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
InputStream source)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
InputStream source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
Reader source)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
Reader source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
String source)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
<T> T |
read(T value,
String source,
boolean strict)
This
read method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. |
boolean |
validate(Class type,
File source)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
File source,
boolean strict)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
InputNode source)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
InputNode node,
boolean strict)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
InputStream source)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
InputStream source,
boolean strict)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
Reader source)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
Reader source,
boolean strict)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
String source)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
boolean |
validate(Class type,
String source,
boolean strict)
This
validate method will validate the contents of
the XML document against the specified XML class schema. |
void |
write(Object source,
File out)
This
write method will traverse the provided object
checking for field annotations in order to compose the XML data. |
void |
write(Object source,
OutputNode root)
This
write method will traverse the provided object
checking for field annotations in order to compose the XML data. |
void |
write(Object source,
OutputStream out)
This
write method will traverse the provided object
checking for field annotations in order to compose the XML data. |
void |
write(Object source,
OutputStream out,
String charset)
This
write method will traverse the provided object
checking for field annotations in order to compose the XML data. |
void |
write(Object source,
Writer out)
This
write method will traverse the provided object
checking for field annotations in order to compose the XML data. |
public Persister()
Persister
object. This is used
to create a serializer object that will use an empty filter.
This means that template variables will remain unchanged within
the XML document parsed when an object is deserialized.public Persister(Format format)
Persister
object. This is used
to create a serializer object that will use the provided format
instructions. The persister uses the Format
object
to structure the generated XML. It determines the indent size
of the document and whether it should contain a prolog.format
- this is used to structure the generated XMLpublic Persister(Map filter)
Persister
object. This is used
to create a serializer object that will use a platform filter
object using the overrides within the provided map. This means
that template variables will be replaced firstly with mappings
from within the provided map, followed by system properties.filter
- this is the map that contains the overridespublic Persister(Map filter, Format format)
Persister
object. This is used
to create a serializer object that will use a platform filter
object using the overrides within the provided map. This means
that template variables will be replaced firstly with mappings
from within the provided map, followed by system properties.filter
- this is the map that contains the overridesformat
- this is the format used to format the documentspublic Persister(Filter filter)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.filter
- the filter used to replace template variablespublic Persister(Filter filter, Format format)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.filter
- the filter used to replace template variablesformat
- this is used to structure the generated XMLpublic Persister(Matcher matcher)
Persister
object. This is used
to create a serializer object that will use the provided matcher
for customizable transformations. The Matcher
will
enable the persister to determine the correct way to transform
the types that are not annotated and considered primitives.matcher
- this is used to customize the transformationspublic Persister(Matcher matcher, Format format)
Persister
object. This is used
to create a serializer object that will use the provided matcher
for customizable transformations. The Matcher
will
enable the persister to determine the correct way to transform
the types that are not annotated and considered primitives.matcher
- this is used to customize the transformationsformat
- this is used to structure the generated XMLpublic Persister(Strategy strategy)
Persister
object. This is used
to create a serializer object that will use a strategy object.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.strategy
- this is the strategy used to resolve classespublic Persister(Strategy strategy, Format format)
Persister
object. This is used
to create a serializer object that will use a strategy object.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.strategy
- this is the strategy used to resolve classesformat
- this is used to structure the generated XMLpublic Persister(Filter filter, Matcher matcher)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.filter
- the filter used to replace template variablesmatcher
- this is used to customize the transformationspublic Persister(Filter filter, Matcher matcher, Format format)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.filter
- the filter used to replace template variablesmatcher
- this is used to customize the transformationsformat
- this is used to structure the generated XMLpublic Persister(Strategy strategy, Map data)
Persister
object. This is used
to create a serializer object that will use a platform filter
object using the overrides within the provided map. This means
that template variables will be replaced firstly with mappings
from within the provided map, followed by system properties.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesdata
- this is the map that contains the overridespublic Persister(Strategy strategy, Map data, Format format)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesdata
- the filter data used to replace template variablesformat
- this is used to format the generated XML documentpublic Persister(Strategy strategy, Filter filter)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesfilter
- the filter used to replace template variablespublic Persister(Strategy strategy, Filter filter, Format format)
Persister
object. This is used
to create a serializer object that will use the provided filter.
This persister will replace all variables encountered when
deserializing an object with mappings found in the filter.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesfilter
- the filter used to replace template variablesformat
- this is used to format the generated XML documentpublic Persister(Strategy strategy, Matcher matcher)
Persister
object. This is used
to create a serializer object that will use the provided matcher
for customizable transformations. The Matcher
will
enable the persister to determine the correct way to transform
the types that are not annotated and considered primitives.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesmatcher
- this is used to customize the transformationspublic Persister(Strategy strategy, Matcher matcher, Format format)
Persister
object. This is used
to create a serializer object that will use the provided matcher
for customizable transformations. The Matcher
will
enable the persister to determine the correct way to transform
the types that are not annotated and considered primitives.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesmatcher
- this is used to customize the transformationsformat
- this is used to format the generated XML documentpublic Persister(Strategy strategy, Filter filter, Matcher matcher)
Persister
object. This is used
to create a serializer object that will use the provided matcher
for customizable transformations. The Matcher
will
enable the persister to determine the correct way to transform
the types that are not annotated and considered primitives.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesmatcher
- this is used to customize the transformationsfilter
- the filter used to replace template variablespublic Persister(Strategy strategy, Filter filter, Matcher matcher, Format format)
Persister
object. This is used
to create a serializer object that will use the provided matcher
for customizable transformations. The Matcher
will
enable the persister to determine the correct way to transform
the types that are not annotated and considered primitives.
This persister will use the provided Strategy
to
intercept the XML elements in order to read and write persistent
data, such as the class name or version of the document.
strategy
- this is the strategy used to resolve classesmatcher
- this is used to customize the transformationsfilter
- the filter used to replace template variablespublic <T> T read(Class<? extends T> type, String source) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, File source) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, InputStream source) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, Reader source) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, InputNode source) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, String source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, File source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, InputStream source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, Reader source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(Class<? extends T> type, InputNode node, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and convert it into an object
of the specified type. If the XML source cannot be deserialized
or there is a problem building the object graph an exception
is thrown. The instance deserialized is returned.read
in interface Serializer
type
- this is the class type to be deserialized from XMLnode
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(T value, String source) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(T value, File source) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(T value, InputStream source) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(T value, Reader source) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(T value, InputNode source) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentException
- if the object cannot be fully deserializedpublic <T> T read(T value, String source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(T value, File source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(T value, InputStream source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(T value, Reader source, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tosource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic <T> T read(T value, InputNode node, boolean strict) throws Exception
read
method will read the contents of the XML
document from the provided source and populate the object with
the values deserialized. This is used as a means of injecting an
object with values deserialized from an XML document. If the
XML source cannot be deserialized or there is a problem building
the object graph an exception is thrown.read
in interface Serializer
value
- this is the object to deserialize the XML in tonode
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the object cannot be fully deserializedpublic boolean validate(Class type, String source) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentException
- if the class XML schema does not fully matchpublic boolean validate(Class type, File source) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentException
- if the class XML schema does not fully matchpublic boolean validate(Class type, InputStream source) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentException
- if the class XML schema does not fully matchpublic boolean validate(Class type, Reader source) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentException
- if the class XML schema does not fully matchpublic boolean validate(Class type, InputNode source) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentException
- if the class XML schema does not fully matchpublic boolean validate(Class type, String source, boolean strict) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the class XML schema does not fully matchpublic boolean validate(Class type, File source, boolean strict) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the class XML schema does not fully matchpublic boolean validate(Class type, InputStream source, boolean strict) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the class XML schema does not fully matchpublic boolean validate(Class type, Reader source, boolean strict) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLsource
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the class XML schema does not fully matchpublic boolean validate(Class type, InputNode node, boolean strict) throws Exception
validate
method will validate the contents of
the XML document against the specified XML class schema. This is
used to perform a read traversal of the class schema such that
the document can be tested against it. This is preferred to
reading the document as it does not instantiate the objects or
invoke any callback methods, thus making it a safe validation.validate
in interface Serializer
type
- this is the class type to be validated against XMLnode
- this provides the source of the XML documentstrict
- this determines whether to read in strict modeException
- if the class XML schema does not fully matchpublic void write(Object source, OutputNode root) throws Exception
write
method will traverse the provided object
checking for field annotations in order to compose the XML data.
This uses the getClass
method on the object to
determine the class file that will be used to compose the schema.
If there is no Root
annotation for the class then
this will throw an exception. The root annotation is the only
annotation required for an object to be serialized.write
in interface Serializer
source
- this is the object that is to be serializedroot
- this is where the serialized XML is written toException
- if the schema for the object is not validpublic void write(Object source, File out) throws Exception
write
method will traverse the provided object
checking for field annotations in order to compose the XML data.
This uses the getClass
method on the object to
determine the class file that will be used to compose the schema.
If there is no Root
annotation for the class then
this will throw an exception. The root annotation is the only
annotation required for an object to be serialized.write
in interface Serializer
source
- this is the object that is to be serializedout
- this is where the serialized XML is written toException
- if the schema for the object is not validpublic void write(Object source, OutputStream out) throws Exception
write
method will traverse the provided object
checking for field annotations in order to compose the XML data.
This uses the getClass
method on the object to
determine the class file that will be used to compose the schema.
If there is no Root
annotation for the class then
this will throw an exception. The root annotation is the only
annotation required for an object to be serialized.write
in interface Serializer
source
- this is the object that is to be serializedout
- this is where the serialized XML is written toException
- if the schema for the object is not validpublic void write(Object source, OutputStream out, String charset) throws Exception
write
method will traverse the provided object
checking for field annotations in order to compose the XML data.
This uses the getClass
method on the object to
determine the class file that will be used to compose the schema.
If there is no Root
annotation for the class then
this will throw an exception. The root annotation is the only
annotation required for an object to be serialized.source
- this is the object that is to be serializedout
- this is where the serialized XML is written tocharset
- this is the character encoding to be usedException
- if the schema for the object is not validpublic void write(Object source, Writer out) throws Exception
write
method will traverse the provided object
checking for field annotations in order to compose the XML data.
This uses the getClass
method on the object to
determine the class file that will be used to compose the schema.
If there is no Root
annotation for the class then
this will throw an exception. The root annotation is the only
annotation required for an object to be serialized.write
in interface Serializer
source
- this is the object that is to be serializedout
- this is where the serialized XML is written toException
- if the schema for the object is not valid