public class XMLDataNode extends Node
XMLDataNode class is the Node wrapper for
a JavaBean class that can be persisted to XML using the XML
marshalling framework Object2Dom.
XMLDataNode is capable of wrapping any object.
Persistence of the object's state will be mediated by the
Object2Dom class.
If the wrapped object is an instance of Element, then calls
to XMLDataNode's Element interface will be
forwarded to the wrapped Element.
Object2Dom| Modifier and Type | Class and Description |
|---|---|
protected static class |
XMLDataNode.DataCastPacket
The
DataCastPacket class is a data class that is
helpful for reducing the number of type-cast operations that
need to occur. |
LOG_READONLY| Constructor and Description |
|---|
XMLDataNode()
Default constructor required for JavaBeans status.
|
XMLDataNode(java.lang.Object dataObject,
java.net.URL url)
Creates an
XMLDataNode whose data comes from the given
dataObject. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeImpl()
Subclasses should override this method to customize the close()
behavior.
|
Attributes |
getAttributes()
This method returns an
Attributes object that encodes the
attributes of the Element. |
java.util.Iterator |
getChildren()
This method is part of the
Element interface to
provide a convenient way of getting an Iterator over any
contained child Elements without having to test the
object's type with the instanceof operator or having
to downcast to a more specific type. |
java.lang.Object |
getData()
Part of the
Element interface. |
protected XMLDataNode.DataCastPacket |
getDataCastPacketDirectly()
Returns the
XMLDataNode.DataCastPacket object directly. |
protected java.lang.Class |
getDefaultClass()
The default class that is specified to
Object2Dom during
marshalling and unmarshalling. |
javax.swing.Icon |
getIcon()
Part of the
Element interface. |
java.lang.String |
getToolTipText()
Part of the
Element interface. |
protected java.lang.String |
getXMLRootElementName()
Returns the XML root element name that is to be used when writing
out the XML file.
|
void |
markDirty(boolean dirty)
Dirtyable interface method. |
boolean |
mayHaveChildren()
This method is part of the
Element interface to
provide a convenient way of determining whether an object may
have children without having to test the object's type with the
instanceof operator or having to downcast to a
more specific type. |
protected Object2Dom |
newObject2Dom()
Returns an appropriately configured instance of
Object2Dom
which will be used to carry out the marshalling. |
protected void |
openImpl()
Subclasses should override this method to customize the open()
behavior.
|
protected void |
saveImpl()
Subclasses should override this method to customize the save()
behavior.
|
void |
setData(java.lang.Object object,
boolean dirty)
Binds the specified
Object to the XMLDataNode
instance as being its data object. |
protected void |
setDataCastPacketDirectly(XMLDataNode.DataCastPacket data)
Sets the
XMLDataNode.DataCastPacket object directly. |
void |
setNodeInfo(NodeInfo info)
Binds the given
info to the XMLDataNode
instance as being its node information. |
void |
setURL(java.net.URL url)
Sets the
URL associated with this Node and
recaches the Node in the NodeFactory with
the new URL so that subsequent queries for the
Node will return successfully. |
addNodeListener, addNodeListenerForType, addNodeListenerForTypeHierarchy, addWeakNodeListener, attach, beginThreadNodeUsageCycle, callUnderReadLock, callUnderWriteLock, close, createSubject, delete, deleteImpl, detach, endThreadNodeUsage, endThreadNodeUsageCycle, ensureOpen, equalsImpl, getInputStream, getLongLabel, getShortLabel, getSubject, getTimestamp, getTimestampLoadedUnsafe, getTransientProperties, getUnmodifiedTimestamp, getURL, isDirty, isLoaded, isLockHeld, isMigrating, isNew, isOpen, isReadLocked, isReadLockHeld, isReadOnly, isReadOrWriteLocked, isTrackedInNodeCache, isTrackingThreadNodeUsage, isWriteLocked, isWriteLockHeld, lockCount, markDirtyImpl, nodeLock, notifyObservers, open, readLock, readLockCount, readLockInterruptibly, readUnlock, refreshTimestamp, removeNodeListener, removeNodeListenerForType, removeNodeListenerForTypeHierarchy, removeWeakNodeListener, rename, renameImpl, reportOpenException, revert, revertImpl, runUnderReadLock, runUnderWriteLock, save, setEventLog, setMigrating, setOpen, setReadOnly, setTimestampDirectly, toString, tryRunUnderReadLock, tryRunUnderWriteLock, unsetMigrating, upgradeLock, upgradeUnlock, urlReadOnlyChanged, writeLock, writeLockCount, writeLockInterruptibly, writeUnlockclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAttributedLabelpublic XMLDataNode()
XMLDataNode can itself
be persisted and loaded by the XML marshalling framework.
The default constructor performs no intialization. That is, the
XMLDataNode is initially marked as unopened, and there
is no URL associated with it.
Generally, use of the default constructor should be reserved for
the XML marshalling framework. If other application code does make
use of the default constructor, however, there must be a call to
either setURL(URL) or setData(Object, boolean)
before any of the other methods in XMLDataNode will
produce valid results.
public XMLDataNode(java.lang.Object dataObject,
java.net.URL url)
XMLDataNode whose data comes from the given
dataObject. Because a data object is specified, the
XMLDataNode is marked as opened and the data object is
marked as dirty, if it implements Dirtyable.
The specified URL is used as the output location where
the marshalled XML data will be written to when the
Node.save() method is called.
public void setURL(java.net.URL url)
NodeURL associated with this Node and
recaches the Node in the NodeFactory with
the new URL so that subsequent queries for the
Node will return successfully.setURL in interface LocatablesetURL in class Nodeurl - The URL to set.Locatable.setURL(URL)public javax.swing.Icon getIcon()
Element interface. This method attempts first
to delegate to the underlying JavaBean to determine the
Icon. If there is no associated JavaBean or if the
JavaBean does not implement Element, then the determination
of the Icon is delegated to the superclass.getIcon in interface DisplayablegetIcon in class NodeIcon to be displayed for the
Displayable.public java.lang.String getToolTipText()
Element interface. This method attempts first
to delegate to the underlying JavaBean to determine the tooltip
text. If there is no associated JavaBean or if the JavaBean does
not implement Element, then the determination of the tooltip
text is left to the superclass.getToolTipText in interface DisplayablegetToolTipText in class NodeDisplayable.public java.lang.Object getData()
Element interface. If necessary, this method
will first load the data from the location returned by
Node.getURL() and unmarshal it with Object2Dom. Once
loaded and unmarshalled, if the wrapped object is an
Element then the value of its Element.getData()
method is returned; otherwise the data object itself will be
returned. In any case, the returned object is a JavaBean.getData in interface ElementgetData in class NodeNode.getURL().Node.open()public boolean mayHaveChildren()
ElementElement interface to
provide a convenient way of determining whether an object may
have children without having to test the object's type with the
instanceof operator or having to downcast to a
more specific type.
An implementation of Element that represents a leaf
in a tree structure should return false from this
method. An implementation of Element that could
represent a non-leaf in a tree structure should return
true from this method, even if it does not currently
contain any children.
mayHaveChildren in interface ElementmayHaveChildren in class Nodetrue if this Element may contain
child Elements.public java.util.Iterator getChildren()
ElementElement interface to
provide a convenient way of getting an Iterator over any
contained child Elements without having to test the
object's type with the instanceof operator or having
to downcast to a more specific type.
An implementation of Element that represents a leaf
in a tree structure should return null from this
method. An implementation of Element that could
represent a non-leaf in a tree structure should return either an
Iterator over the child Elements or
null if there are no children.
getChildren in interface ElementgetChildren in class NodeIterator over any child Elements
contained by this Element. If there are no children,
null is returned.public Attributes getAttributes()
ElementAttributes object that encodes the
attributes of the Element. Changing the attribute
settings on the return object changes the element attributes.
Subclasses should use their super class attributes object to
define their own attributes. This allows subclasses to
inherit their super class attributes. If a subclass does not
wish to inherit attributes, they should first call
getAttributes().clear() and define new attributes.getAttributes in interface ElementgetAttributes in class Nodepublic void markDirty(boolean dirty)
protected void openImpl()
throws java.io.IOException
NodeNode.open() invokes this only if the node is not open, under
write lock. The Node implementation does nothing.protected void closeImpl()
throws java.io.IOException
NodeNode.close() invokes this only if the node is open, under
write lock. The Node implementation does nothing.protected void saveImpl()
throws java.io.IOException
NodeNode.save() invokes this only if the node is dirty, under
write lock. The Node implementation does nothing.public void setNodeInfo(NodeInfo info)
info to the XMLDataNode
instance as being its node information.public void setData(java.lang.Object object,
boolean dirty)
Object to the XMLDataNode
instance as being its data object. If this method succeeds, the
XMLDataNode will be marked as opened and the wrapped
data object will have its dirty state set according to the
dirty parameter.protected XMLDataNode.DataCastPacket getDataCastPacketDirectly()
XMLDataNode.DataCastPacket object directly. This
method is primarily intended for subclass customization. In this
method, it is important that the underlying content is not
opened if it is currently closed. It is also important that this
method never return null and instead return an instance
of XMLDataNode.DataCastPacket whose wrapped object is
null.protected void setDataCastPacketDirectly(XMLDataNode.DataCastPacket data)
XMLDataNode.DataCastPacket object directly. This
method is primarily intended for subclass customization.protected java.lang.String getXMLRootElementName()
Node.save() method will use the subclass's
return value for this method when writing out the XML file.
When this method is overridden in a subclass, it is generally also
desirable to have the IDE be able to recognize the XML root element
name so that the IDE will instantiate the correct Node
class for the XML file. Refer to the javadoc for
XMLRecognizer for details.
XMLRecognizerprotected Object2Dom newObject2Dom()
Object2Dom
which will be used to carry out the marshalling.protected java.lang.Class getDefaultClass()
Object2Dom during
marshalling and unmarshalling. Returns null if
there is no default class.