|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object buoy.xml.WidgetEncoder
public class WidgetEncoder
This class is used for serializing Widgets as XML. This allows user interfaces to be saved in a persistent form, then reconstructed using the WidgetDecoder class.
To use this class, simply call WidgetEncoder.writeObject()
,
passing it the root Widget
to save and an OutputStream to write the XML to. It will save that Widget, along with all other objects
referenced by it: child Widgets, event listeners, models, etc.
The serialization is done through the java.beans.XMLEncoder class. It therefore can encode any object
which is a bean. An object which is not a bean can also be saved if a PersistenceDelegate has been
defined for it. The buoy.xml.delegate package includes PersistenceDelegates for all of the Widgets
in the buoy.widget package. If you wish to define delegates for other classes, you can do so by
calling WidgetEncoder.setPersistenceDelegate()
.
If the class in question is an EventSource, the delegate should generally subclass EventSourceDelegate
and invoke initializeEventLinks()
from its initialize()
method so that its
event listeners will be properly saved.
It is possible for XML files to contain localized text, where the actual value to use is
supplied from a ResourceBundle at decoding time. See WidgetLocalization
for details.
Method Summary | |
---|---|
static void |
setPersistenceDelegate(java.lang.Class cls,
java.beans.PersistenceDelegate delegate)
Register a persistence delegate for a class. |
static void |
writeObject(java.lang.Object obj,
java.io.OutputStream out)
Serialize an object hierarchy as XML. |
static void |
writeObject(java.lang.Object obj,
java.io.OutputStream out,
java.beans.ExceptionListener listener)
Serialize an object hierarchy as XML. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void writeObject(java.lang.Object obj, java.io.OutputStream out)
obj
- the object which forms the root of the hierarchy to saveout
- the OutputStream to write the XML topublic static void writeObject(java.lang.Object obj, java.io.OutputStream out, java.beans.ExceptionListener listener)
obj
- the object which forms the root of the hierarchy to saveout
- the OutputStream to write the XML tolistener
- the listener to notify of recoverable errorspublic static void setPersistenceDelegate(java.lang.Class cls, java.beans.PersistenceDelegate delegate)
cls
- the class for which to define a PersistenceDelegatedelegate
- the delegate to use for saving that class
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |