com.ibm.tspaces.xtuples
Class TupleTree

java.lang.Object
  |
  +--com.ibm.tspaces.xtuples.TupleTree

public class TupleTree
extends java.lang.Object
implements java.io.Serializable

TupleTree is the class that represents the entirety of the XML document that has been converted to the TupleTree. Every single tuple in the tuple tree has a pointer reference to this object, which represents the entire tree structure. Every Tuple includes as one of its fields a XTuple object which embeds the XML related data and the child and parent Tuple references.

This class is used to create and initialize the Tuple Tree.
***MISSING FUNCTIONALITY*** Here's a Key Divergence from the XQL support that's possibly planned for the future. I'm making a decision to not support mixed content (i.e. a single element which has both simple text children and element children mixed together. That's usually used for presentation, a la conversion from HTML to XML or vice versa.) To make version 1 easier, I will assume that DOM nodes/tags which contain text contain no children, and that all the text is together in one string. This string gets put into a known field of the Tuple, and will be very useful in supporting XQL path expression queries, by using TSpaces to find those tuples easily using structural/template matches.
***KEY ASSUMPTION*** We assume that by the time this code is run from the TSDB.java code, the clientID is established, as is the current transaction.

Author:
Ben Y. Zhao
See Also:
XTuple, Field, XMLField, TSDB, XTupleException, Serialized Form

Constructor Summary
TupleTree(java.lang.String xmlString, com.ibm.tspaces.server.TSDB dbPtr, java.lang.String cID, long timestamp, long expire, TupleID origTID)
          TupleTree (String, TSDB, String, long, long, TupleID) ** Constructor
 
Method Summary
static java.util.Vector getChildren(org.w3c.dom.Element e)
          Methods that takes an XML4J/DOM element and returns its children, ignoring whitespaces between tags
 java.lang.String getDTDName()
          This method returns as a string the DTD name that was referenced in the XML document version of the Tuple Tree.
 XMLTuple getRoot()
          This is the standard mechanism by which a client with a reference on a Tuple Tree manages to start traversing the tree.
static int numChildren(org.w3c.dom.Element e)
          Method to take an XML4J DOM element and count its number of children Whitespaces here are not ignored.
 void setRoot(XMLTuple newRoot)
          Method for authorized users to "set" the root tuple of the Tuple Tree I'm still a little unclear on what the qualifier should be, maybe protected?
 java.lang.String toString()
          Prints out the value of the tuple and then dumps the contents of the XTuple object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TupleTree

public TupleTree(java.lang.String xmlString,
                 com.ibm.tspaces.server.TSDB dbPtr,
                 java.lang.String cID,
                 long timestamp,
                 long expire,
                 TupleID origTID)
          throws TupleSpaceServerException
TupleTree (String, TSDB, String, long, long, TupleID) ** Constructor
Parameters:
xmlString - Self explanatory
dbPtr - The pointer to the current TSDB
cID - The current ClientID
timestamp - The timestamp for the entire tupletree
expire - The expiration time for the whole tupletree
origTID - The tupleID ref to the original XMLField tuple
Method Detail

getRoot

public XMLTuple getRoot()
This is the standard mechanism by which a client with a reference on a Tuple Tree manages to start traversing the tree. It returns the root Tuple of the tuple tree

setRoot

public void setRoot(XMLTuple newRoot)
             throws XTupleException
Method for authorized users to "set" the root tuple of the Tuple Tree I'm still a little unclear on what the qualifier should be, maybe protected?

Returns:
boolean: success or failure

getDTDName

public java.lang.String getDTDName()
This method returns as a string the DTD name that was referenced in the XML document version of the Tuple Tree. We can think about using this functionality to "translate" DTDs over to validating tuples maybe.
Returns:
String representation of the DTD name

numChildren

public static int numChildren(org.w3c.dom.Element e)
Method to take an XML4J DOM element and count its number of children Whitespaces here are not ignored. For that, do getChildren().size()
Parameters:
e - The DOM element in question
Returns:
integer that represents the number of children it has

getChildren

public static java.util.Vector getChildren(org.w3c.dom.Element e)
Methods that takes an XML4J/DOM element and returns its children, ignoring whitespaces between tags
Parameters:
e - The DOM element that we find nonwhitespace children for
Returns:
Vector containing the child DOM elements

toString

public java.lang.String toString()
Prints out the value of the tuple and then dumps the contents of the XTuple object
Overrides:
toString in class java.lang.Object