com.waveset.util
Class AbstractXmlObject

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
All Implemented Interfaces:
javax.naming.Referenceable, XmlObject
Direct Known Subclasses:
Answer, AttestationEntry, AttributeCondition, AttributeRef, AuthContext, AuthType, AuthTypes, Binary, CacheConfig, CallStatistics, CallTimer, CallTree, CertificateData, CustomCatalog, DeviceResetConfig, Diagram, EncryptedData, FormItem, GenericAttribute, GenericObject, IAPI, Library, License, LighthouseAccountPolicy.Question, LinkIdentifier, LogicalExpression, Message, MessageParameter, MetaEvent, MetaEventResponse, MetaViewAttribute, MetaViewSource, MetaViewTarget, Modification, NamedValue, ObjectCache, ObjectRef, PageRouter, Property, Report, RepositoryResult, ResourceInfo, ResourceResult, ResultData, ResultError, ResultFieldDisplay, ResultItem, ResultTable, RoleAttribute, Rule.Argument, SignedData, SignedData.SignerInfo, SOAPConfig, Subject, TaskEvent, UserUIConfig, Util.TimePeriod, VariableScope, WavesetResult, WorkflowComponent, WSAttribute, XmlComponent, XmlObjectWrapper

public abstract class AbstractXmlObject
extends java.lang.Object
implements XmlObject, javax.naming.Referenceable

An abstract class that implements the XmlObject interface and provides a set of default implementations for some methods. You normally want to extend this rather than implement XmlObject, though you may be forced to implement XmlObject if you're already extending some other class.

This got a lot simpler as it evolved, we may be able to get rid of this and move some of the stuff to XmlUtil.

Implements Referenceable so that any AbstractXmlObject can be bound into a JNDI service provider.


Field Summary
protected  boolean _trace
          Debug flag
static java.lang.String code_id
           
 
Constructor Summary
AbstractXmlObject()
           
 
Method Summary
static void addXmlHeader(java.lang.StringBuffer b, java.lang.String doctypeName)
          Adds a standard XML header, DOCTYPE statement and element start tag.
 java.lang.Object cloneObject()
          Make a deep copy of an object by serializing it and parsing the serialization into a new object.
 void dump()
          Dump an XML for an object to the console.
 void dumpFile(java.lang.String file)
          Dump the XML for an object to a file.
abstract  java.lang.String getElementName()
          Return the element name.
 javax.naming.Reference getReference()
           
protected static void println(java.lang.Object o)
          Ubiquitous macro
 void setTrace(boolean b)
           
 java.lang.String toIdentityString()
           
 java.lang.String toVerboseString()
           
 java.lang.String toVerboseString(java.lang.String indent)
           
 java.lang.String toXml()
          A default implementation for rendering as a valid XML document.
 void toXml(java.lang.StringBuffer b)
          This isn't defined in the XmlObject interface, but its used a lot in older code, so provide an implementation to ease the transition.
abstract  void toXml(java.lang.StringBuffer b, int indent)
          Serialize into a buffer with optional indentation.
static java.lang.String toXml(XmlObject obj)
          Renders the full XML for an object, including header and DOCTYPE statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

_trace

protected boolean _trace
Debug flag

Constructor Detail

AbstractXmlObject

public AbstractXmlObject()
Method Detail

addXmlHeader

public static void addXmlHeader(java.lang.StringBuffer b,
                                java.lang.String doctypeName)
Adds a standard XML header, DOCTYPE statement and element start tag. This is typically called by the toXml method below prior to calling the toXml method of a subclass. Subclasses may also call it if they want to overload the generation of the header or DOCTYPE for some reason, though there should be no reason to do so.

Direct implementations of XmlObject that can't subclass AbstractXmlObject may also call this in their required implementations of toXml.


toXml

public static java.lang.String toXml(XmlObject obj)
Renders the full XML for an object, including header and DOCTYPE statement.

This is provided as a static method so that it may be called from the required toXml method of classes that implement XmlObject rather than extend AbstractXmlObject.

We'll ask the object for its element name which we then use in the DOCTYPE. If it doesn't give us one, we'll wrap it in our generic container element.


cloneObject

public java.lang.Object cloneObject()
                             throws WavesetException
Make a deep copy of an object by serializing it and parsing the serialization into a new object. We don't use clone so we can throw exceptions.

Throws:
WavesetException

dump

public void dump()
Dump an XML for an object to the console. This is a debugging aid, you can call this from the JBuilder Evaluate/Modify dialog to get an object rendered into the output panel, its easier than navigating through the object browser.


dumpFile

public void dumpFile(java.lang.String file)
Dump the XML for an object to a file. This is a debugging aid you can call from within JBuilder.


setTrace

public void setTrace(boolean b)

println

protected static void println(java.lang.Object o)
Ubiquitous macro


getElementName

public abstract java.lang.String getElementName()
Return the element name.

Specified by:
getElementName in interface XmlObject
Returns:
the element name

toXml

public abstract void toXml(java.lang.StringBuffer b,
                           int indent)
Serialize into a buffer with optional indentation. This must be implemented by the subclass.

Specified by:
toXml in interface XmlObject
Parameters:
b - target buffer
indent - amount of indentation

toXml

public java.lang.String toXml()
A default implementation for rendering as a valid XML document.

Specified by:
toXml in interface XmlObject
Returns:
the string representation of this object

toXml

public void toXml(java.lang.StringBuffer b)
This isn't defined in the XmlObject interface, but its used a lot in older code, so provide an implementation to ease the transition.


getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Specified by:
getReference in interface javax.naming.Referenceable
Throws:
javax.naming.NamingException

toVerboseString

public java.lang.String toVerboseString()

toIdentityString

public java.lang.String toIdentityString()

toVerboseString

public java.lang.String toVerboseString(java.lang.String indent)