buoy.xml

Class WidgetDecoder


public class WidgetDecoder
extends java.lang.Object

This class is used for reconstructing user interfaces that were serialized as XML by WidgetDecoder.

To use this class, simply create a new WidgetDecoder, passing it an input stream from which it can read the XML file. You then can call getRootObject() to get the root object of the hierarchy, or getObject() to look up any Widget in the file by name.

Note that WidgetDecoder does not close the stream you pass to it, so be sure to close the stream when you are done with it.

Author:
Peter Eastman

Constructor Summary

WidgetDecoder(InputStream in)
Create a WidgetDecoder to reconstruct a Widget hierarchy from its XML representation.
WidgetDecoder(InputStream in, ExceptionListener listener)
Create a WidgetDecoder to reconstruct a Widget hierarchy from its XML representation.

Method Summary

Object
getObject(String name)
Get an object that was stored in the XML file.
Object
getRootObject()
Get the root object that was stored in the XML file.
static void
registerObject(String name, Object obj)
This method is used during decoding.

Constructor Details

WidgetDecoder

public WidgetDecoder(InputStream in)
Create a WidgetDecoder to reconstruct a Widget hierarchy from its XML representation.
Parameters:
in - the InputStream from which to read the XML

WidgetDecoder

public WidgetDecoder(InputStream in,
                     ExceptionListener listener)
Create a WidgetDecoder to reconstruct a Widget hierarchy from its XML representation. If recoverable errors occur during reconstruction, the listener will be notified of them.
Parameters:
in - the InputStream from which to read the XML
listener - the listener to notify of recoverable errors

Method Details

getObject

public Object getObject(String name)
Get an object that was stored in the XML file.
Parameters:
name - the name of the object to get
Returns:
the specified object, or null if there was no object in the file with that name

getRootObject

public Object getRootObject()
Get the root object that was stored in the XML file.

registerObject

public static void registerObject(String name,
                                  Object obj)
This method is used during decoding. It records a named object into the table of objects in the current file. If no file is currently being read, this does nothing. There usually is no reason for you to call this directly.

Written by Peter Eastman.