com.ibm.tspaces.xtuples
Class TSXQuery

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

public class TSXQuery
extends java.lang.Object
implements com.ibm.tspaces.server.tsmmdb.TSQuery

The TSXQuery class encapsulates a single XQL-like query Here is the list of components inside an TSXQuery 1. boolean anchored - whether this query has a leading "/" 2. Stack path - main list of path references, which include possible encapsulated objects with attributes and other query specifications, stored in stack order, with the last subpath at the top of the stack.

Author:
Ben Y. Zhao
See Also:
Query, TSMMDB, SubPath, XQueryImpl, XTuple, TupleTree, XTupleException, Serialized Form

Constructor Summary
TSXQuery(java.lang.String xquerystring)
          The TSXQuery constructor that takes then entire XQL-like query string and converts it to a sequence of SubPath objects for easy evaluation.
TSXQuery(XMLQuery xmlquery)
          The TSXQuery constructor that takes a XMLQuery-wrapped query string as input
 
Method Summary
 java.util.Vector apply()
          The method that applies the query to the TSMMDB that I've got It creates an instance of XQueryImpl and then calls the processQuery method for that class.
 void config(com.ibm.tspaces.server.tsmmdb.TSMMDB db_, java.lang.String clientID_)
          The setup method that saves the db pointer
 SuperTuple getOrigTuple()
          Returns a tuple corresponding to the original XML tuple that was used to insert the XML document.
 java.util.Stack getPath()
          Stack getPath() * The method returns the stack containing the query path expression
 Tuple getTupleSet()
          Returns a tuple corresponding to the set of tuples that this query should operate on.
 boolean isAnchored()
          The method returns whether the current query is anchored to the document root
static void main(java.lang.String[] argv)
           
 boolean satisfiedBy(com.ibm.tspaces.server.tsmmdb.ResultTuple rt)
          A method that's used to perform XQL queries on an XML document (vs.
 void setTupleSet(Tuple set)
          Sets the tuple corresponding to the set of tuples that this query should operate on.
 int size()
          Returns our best guess at the potential size of the result of this query For XMLQueries this is hard to say, but this is really an issue of how many documents of each DTD type are stored inside the TSDB.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSXQuery

public TSXQuery(XMLQuery xmlquery)
The TSXQuery constructor that takes a XMLQuery-wrapped query string as input
Parameters:
xmlquery - The XMLQuery object passed in by query.QueryPlan

TSXQuery

public TSXQuery(java.lang.String xquerystring)
The TSXQuery constructor that takes then entire XQL-like query string and converts it to a sequence of SubPath objects for easy evaluation.
Parameters:
xquerystring - is the XQL-like query string to be converted
Method Detail

isAnchored

public boolean isAnchored()
The method returns whether the current query is anchored to the document root
Returns:
whether the query is anchored

getPath

public java.util.Stack getPath()
Stack getPath() * The method returns the stack containing the query path expression
Returns:
the stack containing the query path expression

config

public void config(com.ibm.tspaces.server.tsmmdb.TSMMDB db_,
                   java.lang.String clientID_)
            throws com.ibm.tspaces.server.tsmmdb.TSMMDBException
The setup method that saves the db pointer
Specified by:
config in interface com.ibm.tspaces.server.tsmmdb.TSQuery
Parameters:
db_ - The TSDB that the query is performed on
clientID_ - The clientID from the client
Throws:
com.ibm.tspaces.server.tsmmdb.TSMMDBException -  

size

public int size()
         throws com.ibm.tspaces.server.tsmmdb.TSMMDBException
Returns our best guess at the potential size of the result of this query For XMLQueries this is hard to say, but this is really an issue of how many documents of each DTD type are stored inside the TSDB.
Specified by:
size in interface com.ibm.tspaces.server.tsmmdb.TSQuery
Returns:
an estimate of how many tuples will match this query
Throws:
com.ibm.tspaces.server.tsmmdb.TSMMDBException - thrown when setup hasn't been done

apply

public java.util.Vector apply()
                       throws com.ibm.tspaces.server.tsmmdb.TSMMDBException,
                              com.ibm.tspaces.lock.LMAbortedException
The method that applies the query to the TSMMDB that I've got It creates an instance of XQueryImpl and then calls the processQuery method for that class. processQuery will return a vector of Tuple object that should be returned.
Specified by:
apply in interface com.ibm.tspaces.server.tsmmdb.TSQuery
Returns:
vector of tuples that match the query or null if no match.

satisfiedBy

public boolean satisfiedBy(com.ibm.tspaces.server.tsmmdb.ResultTuple rt)
                    throws com.ibm.tspaces.server.tsmmdb.TSMMDBException
A method that's used to perform XQL queries on an XML document (vs. over the whole TupleSpace. The ResultTuple must contain a tuple of tuples (XMLTuples) which represent an XML document (or documents).
Specified by:
satisfiedBy in interface com.ibm.tspaces.server.tsmmdb.TSQuery
Returns:
True if the XQL query has a result set in the given XMLTuples

getOrigTuple

public SuperTuple getOrigTuple()
Returns a tuple corresponding to the original XML tuple that was used to insert the XML document.
Returns:
origTuple, a tuple representing the original XML document tuple

getTupleSet

public Tuple getTupleSet()
Returns a tuple corresponding to the set of tuples that this query should operate on.
Returns:
tupleSet, a tuple of tuples for the query to operate on

setTupleSet

public void setTupleSet(Tuple set)
Sets the tuple corresponding to the set of tuples that this query should operate on.

main

public static void main(java.lang.String[] argv)