Class XMLDeserializer
java.lang.Object
com.inductiveautomation.ignition.common.xmlserialization.deserialization.XMLDeserializer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ClassNameResolver
static final ThreadLocal<Version>
Will hold the version that the data currently being deserialized was found to be serialized in, if possible.protected Map<String,
DeserializationHandler> protected LoggerEx
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHandler
(DeserializationHandler handler) deserialize
(byte[] bytes) Deserialize the bytes.static Object
deserialize
(XMLDeserializer deser, byte[] data, LoggerEx log) Returns the first object found in the root object stream ofdata
.static Object
deserialize
(XMLDeserializer deser, byte[] data, org.apache.log4j.Logger log) Deprecated.static Object
deserialize
(XMLDeserializer deser, byte[] data, org.slf4j.Logger log) Deprecated.Prefer the overload that accepts aLoggerEx
instead.Deserialize an object graph from an input stream.deserialize
(Reader streamReader) Deserialize an object graph from a reader.deserialize
(String xml) Deserialize an object graph from a reader.deserializeBinary
(byte[] bytes) Deserialize data from a byte[], expected to be in binary format.deserializeBinary
(InputStream stream, boolean topAttributesOnly) deserializeMultiple
(byte[] bytes, int count) Special version of deserialization which will deserialize multiple copies of the serialized objects.deserializeXML
(Reader streamReader, boolean topAttributesOnly) Initializes default handlers in chaining invocation style.protected DeserializationHandler
lookupHandler
(String name) Finds the deserialization handler registered for the given element name.readRootAttributes
(byte[] bytes) Reads the top element's attributes only.Reads the top element's attributes only.readRootAttributes
(Reader streamReader) readRootAttributes
(String xml) transcodeToXML
(InputStream binary, XMLSerializer serializer) This function will take serialized data and return it in uncompressed XML format.
-
Field Details
-
FRAMEWORK_VERSION
Will hold the version that the data currently being deserialized was found to be serialized in, if possible. Only non-null during deserialization. -
instanceHandlers
-
classNameMap
-
log
-
-
Constructor Details
-
XMLDeserializer
public XMLDeserializer() -
XMLDeserializer
-
-
Method Details
-
deserialize
@Deprecated public static Object deserialize(XMLDeserializer deser, byte[] data, org.apache.log4j.Logger log) throws SerializationException Deprecated.Prefer the overload that accepts aLoggerEx
instead.- Throws:
SerializationException
-
deserialize
@Deprecated(since="8.1.25") public static Object deserialize(XMLDeserializer deser, byte[] data, org.slf4j.Logger log) throws SerializationException Deprecated.Prefer the overload that accepts aLoggerEx
instead.- Throws:
SerializationException
-
deserialize
public static Object deserialize(XMLDeserializer deser, byte[] data, LoggerEx log) throws SerializationException Returns the first object found in the root object stream ofdata
. Reports warnings tolog
.- Returns:
- null if the input data is null or empty. Otherwise, the arbitrary serialized object contained in
data
. - Throws:
SerializationException
- if the data is not valid serialized data, or contains no root objects.
-
initDefaults
Initializes default handlers in chaining invocation style. Do not call unlessy you instantiated an XMLDeserializer yourself (generally not the thing to do: get one from your context) -
addHandler
-
deserialize
Deserialize the bytes. Automatically detects GZip compression and binary vs. XML encoding.- Returns:
- DeserializationContext that will contain the root of the serialized object graph, as well as any serialization warnings that occurred.
- Throws:
SerializationException
-
deserialize
Deserialize an object graph from an input stream. Gzip compression and XML vs binary encoding are automatically detected.- Throws:
SerializationException
-
deserialize
Deserialize an object graph from a reader. Encoding is assumed to be XML- Throws:
SerializationException
-
deserialize
Deserialize an object graph from a reader. Encoding is assumed to be XML- Throws:
SerializationException
-
readRootAttributes
- Throws:
SerializationException
-
readRootAttributes
- Throws:
SerializationException
-
readRootAttributes
Reads the top element's attributes only. Automatically detects GZip compression and xml vs binary format- Throws:
SerializationException
-
readRootAttributes
Reads the top element's attributes only. Automatically detects GZip compression and xml vs binary format.- Throws:
SerializationException
-
deserializeBinary
Deserialize data from a byte[], expected to be in binary format. Detects GZip automaticaly.- Throws:
SerializationException
-
deserializeBinary
public DeserializationContext deserializeBinary(InputStream stream, boolean topAttributesOnly) throws SerializationException - Throws:
SerializationException
-
deserializeXML
public DeserializationContext deserializeXML(Reader streamReader, boolean topAttributesOnly) throws SerializationException - Throws:
SerializationException
-
transcodeToXML
public String transcodeToXML(InputStream binary, XMLSerializer serializer) throws SerializationException This function will take serialized data and return it in uncompressed XML format. If the data is already in XML format, it will simple be returned as a string If it is in binary format, it will be transcoded first. The stream will be automatically uncompressed if necessary.- Throws:
SerializationException
-
lookupHandler
Finds the deserialization handler registered for the given element name. -
deserializeMultiple
public List<DeserializationContext> deserializeMultiple(byte[] bytes, int count) throws SerializationException Special version of deserialization which will deserialize multiple copies of the serialized objects. More efficient than calling deserialize X times, as long as X is greater than one.- Throws:
SerializationException
-
getClassNameMap
-
LoggerEx
instead.