Class RXArchiver
java.lang.Object
com.inductiveautomation.rm.archiver.RXArchiver
- Direct Known Subclasses:
RMArchiver
This class manages archival and unarchival to/from RXElements.
For archival, objects simply implement the toXML() method to configure and return RXElements. RXArchiver's
toXML() method manages the process, allowing for object references.
For unarchival, classes register for particular element names. Then during RXArchiver.fromXML(), RXArchiver will
call fromXML() on the classes for encountered tags to reconstruct the object graph.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This inner class represents a named resource associated with an archiver. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddResource
(byte[] bytes, String aName) Adds a byte array resource to this archiver (only if absent).<T> T
copy
(T anObj) Returns a copy of the given object using archival.protected Map
Creates the class map.<T> T
Returns an object unarchived from the given element by instantiating the given class.Returns an object unarchived from the given element.Calls fromXML on given object.fromXMLList
(RXElement anElement, String aName, Class aClass, Object anOwner) Returns the list of objects of the given name and/or class (either can be null) unarchived from the given element.protected Class
Returns the class for a given element.Returns the class for a given element name.Returns the archiver class loader.Returns the class map.Returns the top parent from the parent stack.<T> T
Returns the first parent from the parent stack of given class.int
getReference
(Object anObj) Returns a reference id for the given object (used in archival).int
getReference
(Object anObj, boolean add) Returns a reference id for given object if in references list with option to add if absent (used in archival).getReference
(String aName, RXElement anElement) Returns an object for a given reference (used in unarchival).getResource
(int anIndex) Returns an individual resource associated with this archiver, by index.byte[]
getResource
(String aName) Returns an individual resource associated with this archiver, by name.Returns the list of optional resources associated with this archiver.void
getResources
(RXElement anElement) Reads resources from <resource> elements in given xml (top-level) element, converts from ASCII encoding and adds to archiver.Returns the object that the archiver should read "into".Returns the root xml.Returns the WebURL of the currently loading archive.int
Returns the index of the first child element with the given name.int
Returns the index of the first child element with the given name at or beyond the given index.protected Object
newInstance
(RXElement anElement) Returns a new instance of an object given an element.protected Object
newInstance
(Class aClass) Returns a new instance of an object given a class.protected Object
Pops a parent from the parent stack.protected void
pushParent
(Object anObj) Pushes a parent on the parent stack.readObject
(byte[] theBytes) Returns a root object unarchived from an RMByteSource.readObject
(RXElement theXML) Returns a root object unarchived from the XML source (a File, String path, InputStream, URL, byte[], etc.).readObject
(Object aSource) Returns a root object unarchived from a generic input source (a File, String path, InputStream, URL, byte[], etc.).void
setClassLoader
(ClassLoader aClassLoader) Sets the archiver class loader.void
setRootObject
(Object anObj) Sets the object that the archiver should read "into".Writes the given object to XML elements.Writes the given object to XML elements.writeObject
(Object anObj) Returns an xml element for a given object.
-
Constructor Details
-
RXArchiver
public RXArchiver()
-
-
Method Details
-
getSourceURL
Returns the WebURL of the currently loading archive. -
getRootObject
Returns the object that the archiver should read "into". -
setRootObject
Sets the object that the archiver should read "into". -
getClassLoader
Returns the archiver class loader. -
setClassLoader
Sets the archiver class loader. -
getRootXML
Returns the root xml. -
getClassMap
Returns the class map. -
createClassMap
Creates the class map. -
readObject
Returns a root object unarchived from a generic input source (a File, String path, InputStream, URL, byte[], etc.). -
readObject
Returns a root object unarchived from an RMByteSource. -
readObject
Returns a root object unarchived from the XML source (a File, String path, InputStream, URL, byte[], etc.). You can also provide a root object to be read "into", and an owner that the object is being read "for". -
writeObject
Returns an xml element for a given object. This top level method encodes resources, in addition to doing the basic toXML stuff. -
fromXML
Returns an object unarchived from the given element. -
fromXML
Returns an object unarchived from the given element by instantiating the given class. -
fromXML
Calls fromXML on given object. -
toXML
Writes the given object to XML elements. -
toXML
Writes the given object to XML elements. -
getClass
Returns the class for a given element name. -
getClass
Returns the class for a given element. -
newInstance
Returns a new instance of an object given a class. -
newInstance
Returns a new instance of an object given an element. -
getReference
Returns a reference id for the given object (used in archival). -
getReference
Returns a reference id for given object if in references list with option to add if absent (used in archival). -
getReference
Returns an object for a given reference (used in unarchival). -
indexOf
Returns the index of the first child element with the given name. -
indexOf
Returns the index of the first child element with the given name at or beyond the given index. -
fromXMLList
Returns the list of objects of the given name and/or class (either can be null) unarchived from the given element. -
copy
public <T> T copy(T anObj) Returns a copy of the given object using archival. -
getParent
Returns the top parent from the parent stack. -
getParent
Returns the first parent from the parent stack of given class. -
pushParent
Pushes a parent on the parent stack. -
popParent
Pops a parent from the parent stack. -
getResources
Returns the list of optional resources associated with this archiver. -
getResource
Returns an individual resource associated with this archiver, by index. -
getResource
Returns an individual resource associated with this archiver, by name. -
addResource
Adds a byte array resource to this archiver (only if absent). -
getResources
Reads resources from <resource> elements in given xml (top-level) element, converts from ASCII encoding and adds to archiver.
-