org.gxos.gndi.context
Class TreeObjectContext

java.lang.Object
  |
  +--org.gxos.gndi.context.TreeObjectContext
All Implemented Interfaces:
XMLObject
Direct Known Subclasses:
TreeObject

public class TreeObjectContext
extends java.lang.Object
implements XMLObject

Memory XML object interface for GXOS API.

$Id: TreeObjectContext.java,v 1.1 2001/10/09 18:54:32 balsoy Exp $


Constructor Summary
TreeObjectContext()
           
 
Method Summary
 void addObject(XMLObject object)
          Adds an XML object as a child XML object into this XML object.
 java.util.Enumeration enumerateChildren()
          Returns an enumeration of child objects.
 XMLObject getChild(java.lang.String name)
          Returns the child object whose name is as given.
 java.lang.String[] getChildren()
          Returns a list of child XML obhects' names.
 GxContext getContext()
          Returns the memory container of this GXOS object.
 java.lang.String getName()
          Returns the name of this XML object.
 java.lang.String getParameter(java.lang.String key)
          Returns the parameter value associated with this attribute value.
 XMLObject getParentXMLObject()
          Returns the parent of this XML object.
 java.lang.String getURI()
          Returns the URI of this XML object.
 java.lang.String getXML()
          Returns contents of this XML object as an XML document.
 void removeObject(java.lang.String name)
          Removes an XML object from children list of this XML object.
 void setContext(GxContext container)
          Sets the memory container for this GXOS object.
 void setParameter(java.lang.String key, java.lang.String value)
          Returns the parameter value associated with this attribute value.
 void updateObject()
          Writes any changes of XML object back to the database.
 void updateObject(XMLObject object)
          Replaces an XML object with a new one or updated one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeObjectContext

public TreeObjectContext()
Method Detail

setContext

public void setContext(GxContext container)
                throws XMLException
Sets the memory container for this GXOS object.

Parameters:
container - memory container which will hold this GXOS object.
Throws:
XMLException - if an error is encountered.

getContext

public GxContext getContext()
Returns the memory container of this GXOS object.

Returns:
the memory container of this GXOS object.

getName

public java.lang.String getName()
                         throws XMLException
Returns the name of this XML object. This is relative to its parent.

Specified by:
getName in interface XMLObject
Returns:
name of this XML object.
Throws:
XMLException - if an error is encountered.

getURI

public java.lang.String getURI()
                        throws XMLException
Returns the URI of this XML object. This is the absolute name of this object.

Specified by:
getURI in interface XMLObject
Returns:
URI of this XML object.
Throws:
XMLException - if an error is encountered.

getParentXMLObject

public XMLObject getParentXMLObject()
                             throws XMLException
Returns the parent of this XML object.

Specified by:
getParentXMLObject in interface XMLObject
Returns:
parent of this XML object.
Throws:
XMLException - if an error is encountered.

getChild

public XMLObject getChild(java.lang.String name)
                   throws XMLException
Returns the child object whose name is as given. Name is relative to this XML object. Immediate children are refered by their names. Children objects at deeper levels are refered by their paths including their ancestors. As an example, if this is the hierarchy:
    this object
    . child_1
        . grandchild_1
    . child_2
        . grandchild_2
        . grandchild_3
 
then object retrieval can be this.getChild("child_1") or this.getChild("child_2/grandchild_3") and so on.

Specified by:
getChild in interface XMLObject
Parameters:
name - name of the XML object
Returns:
child XML object
Throws:
XMLException - if an error is encountered.

addObject

public void addObject(XMLObject object)
               throws XMLException
Adds an XML object as a child XML object into this XML object.

Specified by:
addObject in interface XMLObject
Parameters:
object - any XML object.
Throws:
XMLException - if an error is encountered.

updateObject

public void updateObject()
                  throws XMLException
Writes any changes of XML object back to the database.

Specified by:
updateObject in interface XMLObject
Throws:
XMLException - if an error is encountered.
See Also:
updateObject(XMLObject)

updateObject

public void updateObject(XMLObject object)
                  throws XMLException
Replaces an XML object with a new one or updated one. New object's name must be the same as the old one.

Specified by:
updateObject in interface XMLObject
Parameters:
object - any XML object.
Throws:
XMLException - if an error is encountered.
See Also:
updateObject()

removeObject

public void removeObject(java.lang.String name)
                  throws XMLException
Removes an XML object from children list of this XML object. Name is relative to this object. See getChild(String) for name usage.

Specified by:
removeObject in interface XMLObject
Parameters:
name - name of the child object to be removed.
Throws:
XMLException - if an error is encountered.

getXML

public java.lang.String getXML()
                        throws XMLException
Returns contents of this XML object as an XML document.

Specified by:
getXML in interface XMLObject
Returns:
XML content as Java String object.
Throws:
XMLException - if an error is encountered.

getChildren

public java.lang.String[] getChildren()
                               throws XMLException
Returns a list of child XML obhects' names.

Specified by:
getChildren in interface XMLObject
Returns:
an array of XML object names
Throws:
XMLException - if an error is encountered.

enumerateChildren

public java.util.Enumeration enumerateChildren()
                                        throws XMLException
Returns an enumeration of child objects. Each object has to be casted to XMLObject.

Specified by:
enumerateChildren in interface XMLObject
Returns:
enumeration of child XML objects
Throws:
XMLException - if an error is encountered.

getParameter

public java.lang.String getParameter(java.lang.String key)
                              throws XMLException
Returns the parameter value associated with this attribute value. If not found, search continues for ancestor contexts until the root node is reached.
Specified by:
getParameter in interface XMLObject
Parameters:
key - key to retrieve a parameter value
Returns:
parameter value; null if key not found.
See Also:
setParameter(java.lang.String, java.lang.String)

setParameter

public void setParameter(java.lang.String key,
                         java.lang.String value)
                  throws XMLException
Returns the parameter value associated with this attribute value. If not found, search continues for ancestor contexts until the root node is reached.
Specified by:
setParameter in interface XMLObject
Parameters:
key - key that the value will be associated.
value - value to retrive with the given key.
See Also:
getParameter(java.lang.String)