Class XMLSerializer
- java.lang.Object
-
- com.inductiveautomation.ignition.common.xmlserialization.serialization.XMLSerializer
-
public class XMLSerializer extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_ENCODING
-
Constructor Summary
Constructors Constructor Description XMLSerializer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addObject(java.lang.Object obj)
Add another object to serializevoid
addRootAttribute(java.lang.String key, java.lang.String value)
Merges the given attribute for the root element into the existing attributes (if any).void
addSerializationDelegate(java.lang.Class clazz, SerializationDelegate<?> delegate)
void
addSupertypeDelegate(java.lang.Class clazz, SerializationDelegate<?> delegate)
protected Element
createTopElement(java.util.List<Element> elements)
ClassNameResolver
getClassNameMap()
XMLSerializer
initDefaults()
Calls getClassNameMap().addDefaults() in a chaining invocation style.void
registerEqualityDelegate(java.lang.Class<?> clazz, EqualityDelegate<?> delegate)
java.lang.String
serialize()
Deprecated.UseserializeXML()
instead.void
serialize(SerializationWriter writer)
Serializes the object graph to the given serialization writer.void
serialize(java.io.OutputStream out)
Deprecated.useserializeXML(OutputStream, String)
instead.void
serialize(java.io.OutputStream out, java.lang.String encoding)
Deprecated.useserializeXML(OutputStream, String)
instead.void
serialize(java.io.Writer out)
Deprecated.useserializeXML(Writer, String)
instead.void
serialize(java.io.Writer out, java.lang.String encoding)
Deprecated.useserializeXML(Writer, String)
instead.byte[]
serializeAndGZip()
Deprecated.useserializeXMLAndGZip()
instead.byte[]
serializeAndGZip(java.lang.Object obj)
Deprecated.useserializeXMLAndGZip(Object)
instead.byte[]
serializeBinary(boolean gzip)
Serialize using the binary format.void
serializeBinary(java.io.OutputStream stream)
Serializes the added object(s) to the stream, and closes the stream.byte[]
serializeBinary(java.lang.Object object, boolean gzip)
Serialize the given object using binary format.java.lang.String
serializeXML()
Serialize to non-compressed XML using the default encoding (UTF-8)void
serializeXML(java.io.OutputStream out, java.lang.String encoding)
Serialize to XML format using the specified encoding.void
serializeXML(java.io.Writer out, java.lang.String encoding)
Serialize to XML format using the specified encoding.byte[]
serializeXMLAndGZip()
Serializes and gzips using UTF-8 encodingbyte[]
serializeXMLAndGZip(java.lang.Object obj)
Convenience shortcut for:static void
setCleanCopy(java.lang.Class type, java.lang.Object obj)
-
-
-
Method Detail
-
initDefaults
public XMLSerializer initDefaults()
Calls getClassNameMap().addDefaults() in a chaining invocation style.
-
addRootAttribute
public void addRootAttribute(java.lang.String key, java.lang.String value)
Merges the given attribute for the root element into the existing attributes (if any). These attributes can be read on the deserialization side without needing to deserialize the entire structure.
-
addSerializationDelegate
public void addSerializationDelegate(java.lang.Class clazz, SerializationDelegate<?> delegate)
-
addSupertypeDelegate
public void addSupertypeDelegate(java.lang.Class clazz, SerializationDelegate<?> delegate)
-
addObject
public void addObject(java.lang.Object obj)
Add another object to serialize
-
serializeAndGZip
@Deprecated public byte[] serializeAndGZip(java.lang.Object obj) throws SerializationException
Deprecated.useserializeXMLAndGZip(Object)
instead.- Throws:
SerializationException
-
serializeAndGZip
@Deprecated public byte[] serializeAndGZip() throws SerializationException
Deprecated.useserializeXMLAndGZip()
instead.- Throws:
SerializationException
-
serializeXMLAndGZip
public byte[] serializeXMLAndGZip(java.lang.Object obj) throws SerializationException
Convenience shortcut for:serializer.addObject(obj); return serializer.serializeXMLAndGZip();
- Throws:
SerializationException
-
serializeXMLAndGZip
public byte[] serializeXMLAndGZip() throws SerializationException
Serializes and gzips using UTF-8 encoding- Throws:
SerializationException
-
serialize
@Deprecated public java.lang.String serialize() throws SerializationException
Deprecated.UseserializeXML()
instead.- Throws:
SerializationException
-
serialize
@Deprecated public void serialize(java.io.OutputStream out) throws SerializationException
Deprecated.useserializeXML(OutputStream, String)
instead.- Throws:
SerializationException
-
serialize
@Deprecated public void serialize(java.io.OutputStream out, java.lang.String encoding) throws SerializationException
Deprecated.useserializeXML(OutputStream, String)
instead.- Throws:
SerializationException
-
serialize
@Deprecated public void serialize(java.io.Writer out) throws SerializationException
Deprecated.useserializeXML(Writer, String)
instead.- Throws:
SerializationException
-
serialize
@Deprecated public void serialize(java.io.Writer out, java.lang.String encoding) throws SerializationException
Deprecated.useserializeXML(Writer, String)
instead.- Throws:
SerializationException
-
serializeXML
public java.lang.String serializeXML() throws SerializationException
Serialize to non-compressed XML using the default encoding (UTF-8)- Throws:
SerializationException
-
serializeXML
public void serializeXML(java.io.OutputStream out, java.lang.String encoding) throws SerializationException
Serialize to XML format using the specified encoding.- Throws:
SerializationException
-
serializeXML
public void serializeXML(java.io.Writer out, java.lang.String encoding) throws SerializationException
Serialize to XML format using the specified encoding.- Throws:
SerializationException
-
serializeBinary
public byte[] serializeBinary(java.lang.Object object, boolean gzip) throws SerializationException
Serialize the given object using binary format. Shortcut for:serializer.addObject(object); serializer.serializeBinary(gzipFlag);
- Throws:
SerializationException
-
serializeBinary
public byte[] serializeBinary(boolean gzip) throws SerializationException
Serialize using the binary format. Optional gzip compression.- Throws:
SerializationException
-
serializeBinary
public void serializeBinary(java.io.OutputStream stream) throws SerializationException
Serializes the added object(s) to the stream, and closes the stream.- Throws:
SerializationException
-
serialize
public void serialize(SerializationWriter writer) throws SerializationException
Serializes the object graph to the given serialization writer.- Throws:
SerializationException
-
setCleanCopy
public static void setCleanCopy(java.lang.Class type, java.lang.Object obj)
-
getClassNameMap
public ClassNameResolver getClassNameMap()
-
registerEqualityDelegate
public void registerEqualityDelegate(java.lang.Class<?> clazz, EqualityDelegate<?> delegate)
-
-