Package com.ribs
Class RXArchiver
java.lang.Object
com.ribs.RXArchiver
- Direct Known Subclasses:
RibsArchiver
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.
Copyright (c) 2004 ReportMill Software, Inc. All Rights Reserved. Contact ReportMill <info@reportmill.com>.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This inner class represents a named resource associated with an archiver. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new archiver.RXArchiver
(Map classMap) Creates an archiver with the given class map for unarchival class mapping. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a parent to the parent list.addResource
(byte[] bytes, String aName) Adds a byte array resource to this archiver (only if absent).Returns an object unarchived from the given element.Returns an object unarchived from the given element by instanciating the given class.Returns a root object unarchived from the XML source (a File, String path, InputStream, URL, byte[], etc.).protected Object
Calls fromXML on given object.Returns the first object of the given class from the given element.Returns the named object unarchived from the given element.Returns the named object unarchived from the given element (or, if missing, the given default value).Returns the list of objects of the given class unarchived from the given element.Returns the list of objects with the given name unarchived from given element.Returns the list of objects with the given name unarchived from given element instanciated from given class.Returns the list of objects with the given name unarchived from given element (or, if missing, given default).Returns parent object that initiated unarchival for current object (valid inside that object's fromXML method).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.protected Object
newInstance
(RXElement anElement, Class aClass) Returns a new instance of an object given an element and suggested class (probably null).void
Called when a fromXML method swaps another object in to replace the one unarchiving.Writes the given object to XML elements.
-
Constructor Details
-
RXArchiver
public RXArchiver()Creates a new archiver. -
RXArchiver
Creates an archiver with the given class map for unarchival class mapping.
-
-
Method Details
-
toXML
Writes the given object to XML elements. -
fromXML
Returns a root object unarchived from the XML source (a File, String path, InputStream, URL, byte[], etc.). -
fromXML
Returns an object unarchived from the given element. -
fromXML
Returns an object unarchived from the given element by instanciating the given class. -
newInstance
Returns a new instance of an object given an element and suggested class (probably null). -
fromXML
Calls fromXML on given object. -
get
Returns the named object unarchived from the given element. -
get
Returns the named object unarchived from the given element (or, if missing, the given default value). -
get
Returns the first object of the given class from the given element. -
getList
Returns the list of objects with the given name unarchived from given element. -
getList
Returns the list of objects with the given name unarchived from given element (or, if missing, given default). -
getList
Returns the list of objects with the given name unarchived from given element instanciated from given class. -
getList
Returns the list of objects of the given class unarchived from the given element. -
getParent
Returns parent object that initiated unarchival for current object (valid inside that object's fromXML method). -
addParent
Adds a parent to the parent list. -
replace
Called when a fromXML method swaps another object in to replace the one unarchiving. -
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). -
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).
-