Class RXArchiver
- java.lang.Object
- 
- com.inductiveautomation.rm.archiver.RXArchiver
 
- 
- Direct Known Subclasses:
- RMArchiver
 
 public class RXArchiver extends java.lang.ObjectThis 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 SummaryNested Classes Modifier and Type Class Description static classRXArchiver.ResourceThis inner class represents a named resource associated with an archiver.
 - 
Constructor SummaryConstructors Constructor Description RXArchiver()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringaddResource(byte[] bytes, java.lang.String aName)Adds a byte array resource to this archiver (only if absent).<T> Tcopy(T anObj)Returns a copy of the given object using archival.protected java.util.MapcreateClassMap()Creates the class map.<T> TfromXML(RXElement anElement, java.lang.Class<T> aClass, java.lang.Object anOwner)Returns an object unarchived from the given element by instantiating the given class.java.lang.ObjectfromXML(RXElement anElement, java.lang.Object anOwner)Returns an object unarchived from the given element.java.lang.ObjectfromXML(RXElement anElement, java.lang.Object anObj, java.lang.Object anOwner)Calls fromXML on given object.java.util.ListfromXMLList(RXElement anElement, java.lang.String aName, java.lang.Class aClass, java.lang.Object anOwner)Returns the list of objects of the given name and/or class (either can be null) unarchived from the given element.protected java.lang.ClassgetClass(RXElement anElement)Returns the class for a given element.java.lang.ClassgetClass(java.lang.String aName)Returns the class for a given element name.java.lang.ClassLoadergetClassLoader()Returns the archiver class loader.java.util.MapgetClassMap()Returns the class map.java.lang.ObjectgetParent()Returns the top parent from the parent stack.<T> TgetParent(java.lang.Class<T> aClass)Returns the first parent from the parent stack of given class.intgetReference(java.lang.Object anObj)Returns a reference id for the given object (used in archival).intgetReference(java.lang.Object anObj, boolean add)Returns a reference id for given object if in references list with option to add if absent (used in archival).java.lang.ObjectgetReference(java.lang.String aName, RXElement anElement)Returns an object for a given reference (used in unarchival).RXArchiver.ResourcegetResource(int anIndex)Returns an individual resource associated with this archiver, by index.byte[]getResource(java.lang.String aName)Returns an individual resource associated with this archiver, by name.java.util.List<RXArchiver.Resource>getResources()Returns the list of optional resources associated with this archiver.voidgetResources(RXElement anElement)Reads resources from <resource> elements in given xml (top-level) element, converts from ASCII encoding and adds to archiver.java.lang.ObjectgetRootObject()Returns the object that the archiver should read "into".RXElementgetRootXML()Returns the root xml.WebURLgetSourceURL()Returns the WebURL of the currently loading archive.intindexOf(RXElement anElement, java.lang.Class aClass)Returns the index of the first child element with the given name.intindexOf(RXElement anElement, java.lang.Class aClass, int startIndex)Returns the index of the first child element with the given name at or beyond the given index.protected java.lang.ObjectnewInstance(RXElement anElement)Returns a new instance of an object given an element.protected java.lang.ObjectnewInstance(java.lang.Class aClass)Returns a new instance of an object given a class.protected java.lang.ObjectpopParent()Pops a parent from the parent stack.protected voidpushParent(java.lang.Object anObj)Pushes a parent on the parent stack.java.lang.ObjectreadObject(byte[] theBytes)Returns a root object unarchived from an RMByteSource.java.lang.ObjectreadObject(RXElement theXML)Returns a root object unarchived from the XML source (a File, String path, InputStream, URL, byte[], etc.).java.lang.ObjectreadObject(java.lang.Object aSource)Returns a root object unarchived from a generic input source (a File, String path, InputStream, URL, byte[], etc.).voidsetClassLoader(java.lang.ClassLoader aClassLoader)Sets the archiver class loader.voidsetRootObject(java.lang.Object anObj)Sets the object that the archiver should read "into".RXElementtoXML(java.lang.Object anObj)Writes the given object to XML elements.RXElementtoXML(java.lang.Object anObj, java.lang.Object anOwner)Writes the given object to XML elements.RXElementwriteObject(java.lang.Object anObj)Returns an xml element for a given object.
 
- 
- 
- 
Method Detail- 
getSourceURLpublic WebURL getSourceURL() Returns the WebURL of the currently loading archive.
 - 
getRootObjectpublic java.lang.Object getRootObject() Returns the object that the archiver should read "into".
 - 
setRootObjectpublic void setRootObject(java.lang.Object anObj) Sets the object that the archiver should read "into".
 - 
getClassLoaderpublic java.lang.ClassLoader getClassLoader() Returns the archiver class loader.
 - 
setClassLoaderpublic void setClassLoader(java.lang.ClassLoader aClassLoader) Sets the archiver class loader.
 - 
getRootXMLpublic RXElement getRootXML() Returns the root xml.
 - 
getClassMappublic java.util.Map getClassMap() Returns the class map.
 - 
createClassMapprotected java.util.Map createClassMap() Creates the class map.
 - 
readObjectpublic java.lang.Object readObject(java.lang.Object aSource) Returns a root object unarchived from a generic input source (a File, String path, InputStream, URL, byte[], etc.).
 - 
readObjectpublic java.lang.Object readObject(byte[] theBytes) Returns a root object unarchived from an RMByteSource.
 - 
readObjectpublic java.lang.Object readObject(RXElement theXML) 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".
 - 
writeObjectpublic RXElement writeObject(java.lang.Object anObj) Returns an xml element for a given object. This top level method encodes resources, in addition to doing the basic toXML stuff.
 - 
fromXMLpublic java.lang.Object fromXML(RXElement anElement, java.lang.Object anOwner) Returns an object unarchived from the given element.
 - 
fromXMLpublic <T> T fromXML(RXElement anElement, java.lang.Class<T> aClass, java.lang.Object anOwner) Returns an object unarchived from the given element by instantiating the given class.
 - 
fromXMLpublic java.lang.Object fromXML(RXElement anElement, java.lang.Object anObj, java.lang.Object anOwner) Calls fromXML on given object.
 - 
toXMLpublic RXElement toXML(java.lang.Object anObj) Writes the given object to XML elements.
 - 
toXMLpublic RXElement toXML(@Nonnull java.lang.Object anObj, @Nullable java.lang.Object anOwner) Writes the given object to XML elements.
 - 
getClasspublic java.lang.Class getClass(java.lang.String aName) Returns the class for a given element name.
 - 
getClassprotected java.lang.Class getClass(RXElement anElement) Returns the class for a given element.
 - 
newInstanceprotected java.lang.Object newInstance(java.lang.Class aClass) Returns a new instance of an object given a class.
 - 
newInstanceprotected java.lang.Object newInstance(RXElement anElement) Returns a new instance of an object given an element.
 - 
getReferencepublic int getReference(java.lang.Object anObj) Returns a reference id for the given object (used in archival).
 - 
getReferencepublic int getReference(java.lang.Object anObj, boolean add)Returns a reference id for given object if in references list with option to add if absent (used in archival).
 - 
getReferencepublic java.lang.Object getReference(java.lang.String aName, RXElement anElement)Returns an object for a given reference (used in unarchival).
 - 
indexOfpublic int indexOf(RXElement anElement, java.lang.Class aClass) Returns the index of the first child element with the given name.
 - 
indexOfpublic int indexOf(RXElement anElement, java.lang.Class aClass, int startIndex) Returns the index of the first child element with the given name at or beyond the given index.
 - 
fromXMLListpublic java.util.List fromXMLList(RXElement anElement, java.lang.String aName, java.lang.Class aClass, java.lang.Object anOwner) Returns the list of objects of the given name and/or class (either can be null) unarchived from the given element.
 - 
copypublic <T> T copy(T anObj) Returns a copy of the given object using archival.
 - 
getParentpublic java.lang.Object getParent() Returns the top parent from the parent stack.
 - 
getParentpublic <T> T getParent(java.lang.Class<T> aClass) Returns the first parent from the parent stack of given class.
 - 
pushParentprotected void pushParent(java.lang.Object anObj) Pushes a parent on the parent stack.
 - 
popParentprotected java.lang.Object popParent() Pops a parent from the parent stack.
 - 
getResourcespublic java.util.List<RXArchiver.Resource> getResources() Returns the list of optional resources associated with this archiver.
 - 
getResourcepublic RXArchiver.Resource getResource(int anIndex) Returns an individual resource associated with this archiver, by index.
 - 
getResourcepublic byte[] getResource(java.lang.String aName) Returns an individual resource associated with this archiver, by name.
 - 
addResourcepublic java.lang.String addResource(byte[] bytes, java.lang.String aName)Adds a byte array resource to this archiver (only if absent).
 - 
getResourcespublic void getResources(RXElement anElement) Reads resources from <resource> elements in given xml (top-level) element, converts from ASCII encoding and adds to archiver.
 
- 
 
-