Extension SDK 10.1.2

oracle.ide.model
Class XMLDataNode

java.lang.Object
  extended byoracle.ide.model.DefaultDisplayable
      extended byoracle.ide.model.DefaultElement
          extended byoracle.ide.model.DefaultDocument
              extended byoracle.ide.model.DefaultNode
                  extended byoracle.ide.model.XMLDataNode
All Implemented Interfaces:
Category, Data, Dirtyable, Displayable, Document, Element, LazyLoadable, Locatable, Node, Subject
Direct Known Subclasses:
XMLDataContainer

public class XMLDataNode
extends DefaultNode

The 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.

See Also:
Object2Dom

Nested Class Summary
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.
 
Field Summary
 
Fields inherited from interface oracle.ide.addin.Subject
OBJECT_MODIFIED
 
Fields inherited from interface oracle.ide.model.Category
UNDEFINED
 
Constructor Summary
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.
 
Method Summary
 void close()
          Closes the Document and unloads any associated data.
 Attributes getAttributes()
          This method returns an Attributes object that encodes the attributes of the Element.
 int getCategory()
          Get the bit field identifying the different categories this data node falls under.
 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  oracle.ide.marshal.xml.Object2Dom newObject2Dom()
          Returns an appropriately configured instance of Object2Dom which will be used to carry out the marshalling.
 void open()
          Document interface method.
 void reopen()
           
 void save(boolean shallow)
          Document interface method.
 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 DefaultNode and recaches the DefaultNode in the NodeFactory with the new URL so that subsequent queries for the DefaultNode will return successfully.
 
Methods inherited from class oracle.ide.model.DefaultNode
equalsImpl
 
Methods inherited from class oracle.ide.model.DefaultDocument
attach, copyToImpl, createSubject, detach, ensureOpen, equalsImpl, getInputStream, getLongLabel, getShortLabel, getSubject, getTimestamp, getTimestampDirectly, getURL, isDirty, isNew, isOpen, isReadOnly, notifyObservers, refreshTimestamp, setOpen, setTimestampDirectly, setURLDirectly
 
Methods inherited from class oracle.ide.model.DefaultDisplayable
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.ide.model.Document
getInputStream, getTimestamp, isNew, isReadOnly
 
Methods inherited from interface oracle.ide.model.Locatable
getURL
 
Methods inherited from interface oracle.ide.model.Displayable
getLongLabel, getShortLabel, toString
 
Methods inherited from interface oracle.ide.addin.Subject
attach, detach, notifyObservers
 
Methods inherited from interface oracle.ide.model.Dirtyable
isDirty
 
Methods inherited from interface oracle.ide.model.LazyLoadable
isOpen
 

Constructor Detail

XMLDataNode

public XMLDataNode()
Default constructor required for JavaBeans status. By having JavaBean status, an instance of 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.


XMLDataNode

public XMLDataNode(java.lang.Object dataObject,
                   java.net.URL url)
Creates an 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 save(boolean) method is called.

Method Detail

setURL

public void setURL(java.net.URL url)
Description copied from class: DefaultNode
Sets the URL associated with this DefaultNode and recaches the DefaultNode in the NodeFactory with the new URL so that subsequent queries for the DefaultNode will return successfully.

Specified by:
setURL in interface Locatable
Overrides:
setURL in class DefaultNode
See Also:
Locatable.setURL(URL), DefaultDocument.setURL(URL)

getIcon

public javax.swing.Icon getIcon()
Part of the 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.

Specified by:
getIcon in interface Displayable
Overrides:
getIcon in class DefaultDisplayable
See Also:
Displayable.getIcon()

getToolTipText

public java.lang.String getToolTipText()
Part of the 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.

Specified by:
getToolTipText in interface Displayable
Overrides:
getToolTipText in class DefaultDocument
See Also:
Displayable.getToolTipText()

getData

public java.lang.Object getData()
Part of the Element interface. If necessary, this method will first load the data from the location returned by DefaultDocument.getURL() and unmarshal it with Object2Dom. Once loaded and unmarshalled, if the wrapped object is an Element then the value of its Data.getData() method is returned; otherwise the data object itself will be returned. In any case, the returned object is a JavaBean.

Specified by:
getData in interface Data
Overrides:
getData in class DefaultElement
Returns:
the JavaBean object corresponding to the XML content stored at the location specified by DefaultDocument.getURL().
See Also:
open()

mayHaveChildren

public boolean mayHaveChildren()
Description copied from interface: Element
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.

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.

Specified by:
mayHaveChildren in interface Element
Overrides:
mayHaveChildren in class DefaultElement
See Also:
Element.mayHaveChildren()

getChildren

public java.util.Iterator getChildren()
Description copied from interface: Element
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.

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.

Specified by:
getChildren in interface Element
Overrides:
getChildren in class DefaultElement
See Also:
Element.getChildren()

getAttributes

public Attributes getAttributes()
Description copied from interface: Element
This method returns an Attributes 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.

Specified by:
getAttributes in interface Element
Overrides:
getAttributes in class DefaultElement
See Also:
Element.getAttributes()

markDirty

public void markDirty(boolean dirty)
Dirtyable interface method. If the wrapped object is an instance of Dirtyable, then this implementation delegates the setting of the dirty flag to the wrapped object. Otherwise, the determination of the return value is delegated to the superclass.

Specified by:
markDirty in interface Dirtyable
Overrides:
markDirty in class DefaultDocument

open

public void open()
          throws java.io.IOException
Document interface method. This method uses Object2Dom to unmarshal the XML file into a JavaBean instance. The JavaBean instance then becomes available through the getData() method.

Specified by:
open in interface Document
Overrides:
open in class DefaultDocument
Throws:
java.io.IOException
See Also:
Object2Dom

close

public void close()
Description copied from interface: Document
Closes the Document and unloads any associated data. When this method returns, the state of the Document object should be equivalent to when the Document object has just been instantiated but not yet opened.

Specified by:
close in interface Document
Overrides:
close in class DefaultDocument
See Also:
Document.close()

reopen

public void reopen()
            throws java.io.IOException
Throws:
java.io.IOException

save

public void save(boolean shallow)
          throws java.io.IOException
Document interface method. This method uses Object2Dom to marshal the underlying JavaBean into an XML form.

Specified by:
save in interface Document
Overrides:
save in class DefaultDocument
Throws:
java.io.IOException
See Also:
Object2Dom

getCategory

public int getCategory()
Description copied from interface: Category
Get the bit field identifying the different categories this data node falls under.

Specified by:
getCategory in interface Category
Overrides:
getCategory in class DefaultNode

setNodeInfo

public void setNodeInfo(NodeInfo info)
Binds the given info to the XMLDataNode instance as being its node information.


setData

public void setData(java.lang.Object object,
                    boolean dirty)
Binds the specified 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.


getDataCastPacketDirectly

protected XMLDataNode.DataCastPacket getDataCastPacketDirectly()
Returns the 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.


setDataCastPacketDirectly

protected void setDataCastPacketDirectly(XMLDataNode.DataCastPacket data)
Sets the XMLDataNode.DataCastPacket object directly. This method is primarily intended for subclass customization.


getXMLRootElementName

protected java.lang.String getXMLRootElementName()
Returns the XML root element name that is to be used when writing out the XML file. If a subclass needs to use a different XML root element name than the default value provided here, then the subclass sould override this method to return its XML root element name. The save(boolean) 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.

See Also:
XMLRecognizer

newObject2Dom

protected oracle.ide.marshal.xml.Object2Dom newObject2Dom()
Returns an appropriately configured instance of Object2Dom which will be used to carry out the marshalling.


getDefaultClass

protected java.lang.Class getDefaultClass()
The default class that is specified to Object2Dom during marshalling and unmarshalling. Returns null if there is no default class.


Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.