|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.skaringa.javaxml.impl.ObjectTransformerImpl
public final class ObjectTransformerImpl
Implementation of ObjectTransformer. This implementation uses SAX events to parse and generate the XML documents.
Constructor Summary | |
---|---|
ObjectTransformerImpl()
Construct a new Implementation of an ObjectTransformer |
Method Summary | |
---|---|
java.lang.Object |
deserialize(javax.xml.transform.Source src)
Deserializes an Object from a Source using XML format. |
java.lang.Object |
deserializeFromJson(java.io.InputStream stream)
Deserializes a List or Map from a stream using JSON format. |
java.lang.Object |
deserializeFromJson(java.io.InputStream stream,
java.lang.Class rootType)
Deserializes an Object from a stream using JSON format. |
java.lang.Object |
deserializeFromJsonString(java.lang.String s)
Deserializes a List or Map from a String using JSON format. |
java.lang.Object |
deserializeFromJsonString(java.lang.String s,
java.lang.Class rootType)
Deserializes an Object from a String using JSON format. |
java.lang.Object |
deserializeFromString(java.lang.String s)
Deserializes an Object from a string using XML format. |
void |
serialize(java.lang.Object obj,
javax.xml.transform.Result result)
Serializes an Object into a result using XML format. |
void |
serializeToJson(java.lang.Object obj,
java.io.OutputStream stream)
Serializes an object into a stream using JSON format. |
java.lang.String |
serializeToJsonString(java.lang.Object obj)
Serializes an object into a String using JSON format. |
java.lang.String |
serializeToString(java.lang.Object obj)
Serializes an Object into a String using XML format. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Set the class loader used to load classes during deserialization. |
void |
setPostprocessorInstruction(javax.xml.transform.Source transformationInstruction)
Set the stylesheet to be used for postprocessing. |
void |
setPreprocessorInstruction(javax.xml.transform.Source transformationInstruction)
Set the instructions to be used for preprocessing. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Set a transformer property. |
java.lang.Object |
transform(java.lang.Object obj)
Transform one object into another using pre-parsed transformation instructions. |
java.lang.Object |
transform(java.lang.Object obj,
javax.xml.transform.Source transformationInstruction)
Deprecated. |
void |
transform(java.lang.Object obj,
javax.xml.transform.Source transformationInstruction,
javax.xml.transform.Result result)
Deprecated. |
void |
writeXMLSchema(java.lang.Class type,
java.util.Collection componentTypes,
javax.xml.transform.Result result)
Write the XML schema definition of a type. |
void |
writeXMLSchema(java.lang.Class type,
javax.xml.transform.Result result)
Write the XML schema definition of a type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectTransformerImpl() throws NoImplementationException
NoImplementationException
- If the underlying XML Transformer doesn't support SAXTransformer.Method Detail |
---|
public void serialize(java.lang.Object obj, javax.xml.transform.Result result) throws SerializerException
ObjectTransformer
ObjectTransformer.setPostprocessorInstruction(Source)
these are applied to the result of the serialization.
serialize
in interface ObjectTransformer
obj
- The object to serialize.result
- The result to serialize the Object to.
SerializerException
- If the serialization failed.ObjectTransformer.serialize(Object, Result)
public java.lang.String serializeToString(java.lang.Object obj) throws SerializerException
ObjectTransformer
ObjectTransformer.setPostprocessorInstruction(Source)
these are applied to the result of the serialization.
serializeToString
in interface ObjectTransformer
obj
- The object to serialize.
SerializerException
- If the serialization failed.ObjectTransformer.serializeToString(Object)
public java.lang.Object deserialize(javax.xml.transform.Source src) throws DeserializerException
ObjectTransformer
ObjectTransformer.setPreprocessorInstruction(Source)
these are applied first to the Source before piping it into the
deserializer.
deserialize
in interface ObjectTransformer
src
- Source of the object's XML representation.
DeserializerException
- If the deserialization failed.ObjectTransformer.deserialize(Source)
public java.lang.Object deserializeFromString(java.lang.String s) throws DeserializerException
ObjectTransformer
ObjectTransformer.setPreprocessorInstruction(Source)
these are applied first to the source before piping it into the
deserializer.
deserializeFromString
in interface ObjectTransformer
s
- The string containing the object's XML representation.
DeserializerException
- If the deserialization failed.ObjectTransformer.deserializeFromString(String)
public void writeXMLSchema(java.lang.Class type, javax.xml.transform.Result result) throws SerializerException
ObjectTransformer
writeXMLSchema
in interface ObjectTransformer
type
- The type of the object.result
- The result to write the schema to.
SerializerException
- If an error occured.ObjectTransformer.writeXMLSchema(Class, Result)
public void writeXMLSchema(java.lang.Class type, java.util.Collection componentTypes, javax.xml.transform.Result result) throws SerializerException
ObjectTransformer
writeXMLSchema
in interface ObjectTransformer
type
- The type of the object.componentTypes
- A collection of Class objects which contain the component types.result
- The result to write the schema to.
SerializerException
- If an error occured.ObjectTransformer.writeXMLSchema(Class, Collection, Result)
public java.lang.Object transform(java.lang.Object obj, javax.xml.transform.Source transformationInstruction) throws SerializerException, DeserializerException
ObjectTransformer
transform
in interface ObjectTransformer
obj
- The object to transform.transformationInstruction
- The source where to get the XSLT instructions from.
SerializerException
- If an error occured in the serializer.
DeserializerException
- If an error occured in the deserializer.ObjectTransformer.transform(Object, Source)
public java.lang.Object transform(java.lang.Object obj) throws SerializerException, DeserializerException
ObjectTransformer
ObjectTransformer.setPostprocessorInstruction(Source)
.
transform
in interface ObjectTransformer
obj
- The object to transform.
SerializerException
- If an error occured in the serializer.
DeserializerException
- If an error occured in the deserializer.ObjectTransformer.transform(Object)
public void transform(java.lang.Object obj, javax.xml.transform.Source transformationInstruction, javax.xml.transform.Result result) throws SerializerException
ObjectTransformer
transform
in interface ObjectTransformer
obj
- The object to transform.transformationInstruction
- A source of XSLT instructions or null if a simple copy
transformation has to be performed.result
- The result of the transformation.
SerializerException
- If an error occured.ObjectTransformer.transform(Object, Source, Result)
public void setProperty(java.lang.String name, java.lang.Object value)
ObjectTransformer
setProperty
in interface ObjectTransformer
name
- The name of the property to set.value
- The value of the property.ObjectTransformer.setProperty(String, Object)
public void setClassLoader(java.lang.ClassLoader classLoader)
ObjectTransformer
setClassLoader
in interface ObjectTransformer
classLoader
- The class loader to use.ObjectTransformer.setClassLoader(java.lang.ClassLoader)
public void setPreprocessorInstruction(javax.xml.transform.Source transformationInstruction) throws NoImplementationException
ObjectTransformer
ObjectTransformer.deserialize(Source)
or
ObjectTransformer.deserializeFromString(String)
before deserializing the object.
setPreprocessorInstruction
in interface ObjectTransformer
transformationInstruction
- A source of XSLT instructions.
NoImplementationException
- If the transformer doesn't support this feature.ObjectTransformer.setPreprocessorInstruction(Source)
public void setPostprocessorInstruction(javax.xml.transform.Source transformationInstruction) throws NoImplementationException
ObjectTransformer
ObjectTransformer.serialize(Object, Result)
or ObjectTransformer.serializeToString(Object)
after serializing the object.
Additionally, these instructions are used by ObjectTransformer.transform(Object)
.
setPostprocessorInstruction
in interface ObjectTransformer
transformationInstruction
- A source of XSLT instructions.
NoImplementationException
- If the transformer doesn't support this feature.ObjectTransformer.setPostprocessorInstruction(Source)
public void serializeToJson(java.lang.Object obj, java.io.OutputStream stream) throws SerializerException
ObjectTransformer
serializeToJson
in interface ObjectTransformer
obj
- The object to serialize.stream
- The stream to write the JSON to. Note that JSON is always UTF-8
encoded.
SerializerException
- If the serialization failed.ObjectTransformer.serializeToJson(Object, OutputStream)
public java.lang.String serializeToJsonString(java.lang.Object obj) throws SerializerException
ObjectTransformer
serializeToJsonString
in interface ObjectTransformer
obj
- The object to serialize.
SerializerException
- If the serialization failed.ObjectTransformer.serializeToJsonString(Object)
public java.lang.Object deserializeFromJson(java.io.InputStream stream, java.lang.Class rootType) throws DeserializerException
ObjectTransformer
deserializeFromJson
in interface ObjectTransformer
stream
- The stream containing the JSON. Note that JSON is always UTF-8
encoded.rootType
- The type of the root object to instantiate. If null, then
LinkedList or HashMap is used depending on the JSON stream.
DeserializerException
- If the deserialization failed.ObjectTransformer.deserializeFromJson(InputStream, Class)
public java.lang.Object deserializeFromJsonString(java.lang.String s, java.lang.Class rootType) throws DeserializerException
ObjectTransformer
deserializeFromJsonString
in interface ObjectTransformer
s
- The String in JSON format.rootType
- The type of the root object to instantiate. If null, then
LinkedList or HashMap is used depending on the JSON string.
DeserializerException
- If the deserialization failed.ObjectTransformer.deserializeFromJsonString(java.lang.String,
java.lang.Class)
public java.lang.Object deserializeFromJson(java.io.InputStream stream) throws DeserializerException
ObjectTransformer
deserializeFromJson
in interface ObjectTransformer
stream
- The stream containing the JSON. Note that JSON is always UTF-8
encoded.
DeserializerException
- If the deserialization failed.ObjectTransformer.deserializeFromJson(java.io.InputStream)
public java.lang.Object deserializeFromJsonString(java.lang.String s) throws DeserializerException
ObjectTransformer
deserializeFromJsonString
in interface ObjectTransformer
s
- The String in JSON format.
DeserializerException
- If the deserialization failed.ObjectTransformer.deserializeFromJsonString(java.lang.String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |