/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XNodeSet.java,v 1.2.4.2 2005/09/14 20:34:45 jeffsuttor Exp $
*/
/**
* This class represents an XPath nodeset object, and is capable of
* converting the nodeset to other types, such as a string.
* @xsl.usage general
*/
{
/**
* Default constructor for derived objects.
*/
protected XNodeSet()
{
}
/**
* Construct a XNodeSet object.
*
* @param val Value of the XNodeSet object
*/
{
super();
{
// First make sure the DTMIterator val has a cache,
// so if it doesn't have one, make one.
nodeSet.setShouldCacheNodes(true);
// Get the cache from val and use it ourselves (we share it).
}
else
}
/**
* Construct a XNodeSet object.
*
* @param val Value of the XNodeSet object
*/
{
super();
val.setShouldCacheNodes(true);
}
/**
* Construct an empty XNodeSet object. This is used to create a mutable
* nodeset to which random nodes may be added.
*/
{
}
/**
* Construct a XNodeSet object for one node.
*
* @param n Node to add to the new XNodeSet object
*/
{
super(new NodeSetDTM(dtmMgr));
{
m_last = 1;
}
else
m_last = 0;
}
/**
* Tell that this is a CLASS_NODESET.
*
* @return type CLASS_NODESET
*/
public int getType()
{
return CLASS_NODESET;
}
/**
* Given a request type, return the equivalent string.
* For diagnostic purposes.
*
* @return type string "#NODESET"
*/
{
return "#NODESET";
}
/**
* Get numeric value of the string conversion from a single node.
*
* @param n Node to convert
*
* @return numeric value of the string conversion from a single node.
*/
public double getNumberFromNode(int n)
{
}
/**
* Cast result object to a number.
*
* @return numeric value of the string conversion from the
* next node in the NodeSetDTM, or NAN if no node was found
*/
public double num()
{
}
/**
* Cast result object to a number, but allow side effects, such as the
* incrementing of an iterator.
*
* @return numeric value of the string conversion from the
* next node in the NodeSetDTM, or NAN if no node was found
*/
public double numWithSideEffects()
{
}
/**
* Cast result object to a boolean.
*
* @return True if there is a next node in the nodeset
*/
public boolean bool()
{
}
/**
* Cast result object to a boolean, but allow side effects, such as the
* incrementing of an iterator.
*
* @return True if there is a next node in the nodeset
*/
public boolean boolWithSideEffects()
{
}
/**
* Get the string conversion from a single node.
*
* @param n Node to convert
*
* @return the string conversion from a single node.
*/
{
// %OPT%
// I guess we'll have to get a static instance of the DTM manager...
{
}
else
{
}
}
/**
* Directly call the
* characters method on the passed ContentHandler for the
* string-value. Multiple calls to the
* ContentHandler's characters methods may well occur for a single call to
* this method.
*
* @param ch A non-null reference to a ContentHandler.
*
* @throws org.xml.sax.SAXException
*/
{
{
}
}
/**
* Cast result object to an XMLString.
*
* @return The document fragment node data or the empty string.
*/
{
}
/**
* Cast result object to a string.
*
* @return The string this wraps or the empty string if null
*/
{
}
/**
* Cast result object to a string.
*
* @return the string conversion from the next node in the nodeset
* or "" if there is no next node
*/
{
}
/**
* Return a java object that's closest to the representation
* that should be handed to an extension.
*
* @return The object that this class wraps
*/
{
return this;
else
return m_obj;
}
// %REVIEW%
// hmmm...
// /**
// * Cast result object to a result tree fragment.
// *
// * @param support The XPath context to use for the conversion
// *
// * @return the nodeset as a result tree fragment.
// */
// public DocumentFragment rtree(XPathContext support)
// {
// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// DocumentBuilder db = dbf.newDocumentBuilder();
// Document myDoc = db.newDocument();
//
// DocumentFragment docFrag = myDoc.createDocumentFragment();
//
// DTMIterator nl = iter();
// int node;
//
// while (DTM.NULL != (node = nl.nextNode()))
// {
// frag.appendChild(node, true, true);
// }
//
// return frag.getDocument();
// }
/**
* Cast result object to a nodelist.
*
* @return a NodeIterator.
*
* @throws javax.xml.transform.TransformerException
*/
{
}
/**
* Cast result object to a nodelist.
*
* @return a NodeList.
*
* @throws javax.xml.transform.TransformerException
*/
{
com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList nodelist = new com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList(this);
// Creating a DTMNodeList has the side-effect that it will create a clone
// XNodeSet with cache and run m_iter to the end. You cannot get any node
// from m_iter after this call. As a fix, we call SetVector() on the clone's
// cache. See Bugzilla 14406.
return nodelist;
}
// /**
// * Return a java object that's closest to the representation
// * that should be handed to an extension.
// *
// * @return The object that this class wraps
// */
// public Object object()
// {
// return new com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList(iter());
// }
/**
* Return the iterator without cloning, etc.
*/
{
return this;
}
{
}
/**
* Cast result object to a nodelist.
*
* @return The nodeset as a nodelist
*/
{
try
{
if(hasCache())
return cloneWithReset();
else
return this; // don't bother to clone... won't do any good!
}
catch (CloneNotSupportedException cnse)
{
}
}
/**
* Get a fresh copy of the object. For use with variables.
*
* @return A fresh nodelist.
*/
{
try
{
if(hasCache())
return (XObject)cloneWithReset();
else
return this; // don't bother to clone... won't do any good!
}
catch (CloneNotSupportedException cnse)
{
}
}
/**
* Cast result object to a mutableNodeset.
*
* @return The nodeset as a mutableNodeset
*/
{
if(m_obj instanceof NodeSetDTM)
{
}
else
{
setCurrentPos(0);
}
return mnl;
}
/** Less than comparator */
/** Less than or equal comparator */
/** Greater than comparator */
/** Greater than or equal comparator */
new GreaterThanOrEqualComparator();
/** Equal comparator */
/** Not equal comparator */
/**
* Tell if one object is less than the other.
*
* @param obj2 Object to compare this nodeset to
* @param comparator Comparator to use
*
* @return See the comments below for each object type comparison
*
* @throws javax.xml.transform.TransformerException
*/
{
boolean result = false;
{
// %OPT% This should be XMLString based instead of string based...
// From http://www.w3.org/TR/xpath:
// If both objects to be compared are node-sets, then the comparison
// will be true if and only if there is a node in the first node-set
// and a node in the second node-set such that the result of performing
// the comparison on the string-values of the two nodes is true.
// Note this little gem from the draft:
// NOTE: If $x is bound to a node-set, then $x="foo"
// does not mean the same as not($x!="foo"): the former
// is true if and only if some node in $x has the string-value
// foo; the latter is true if and only if all nodes in $x have
// the string-value foo.
int node1;
{
if (null == node2Strings)
{
int node2;
{
{
result = true;
break;
}
if (null == node2Strings)
}
}
else
{
int n = node2Strings.size();
for (int i = 0; i < n; i++)
{
{
result = true;
break;
}
}
}
}
}
{
// From http://www.w3.org/TR/xpath:
// If one object to be compared is a node-set and the other is a boolean,
// then the comparison will be true if and only if the result of
// performing the comparison on the boolean and on the result of
// converting the node-set to a boolean using the boolean function
// is true.
}
{
// From http://www.w3.org/TR/xpath:
// If one object to be compared is a node-set and the other is a number,
// then the comparison will be true if and only if there is a
// node in the node-set such that the result of performing the
// comparison on the number to be compared and on the result of
// converting the string-value of that node to a number using
// the number function is true.
int node;
{
{
result = true;
break;
}
}
}
{
int node;
{
{
result = true;
break;
}
}
}
{
// From http://www.w3.org/TR/xpath:
// If one object to be compared is a node-set and the other is a
// string, then the comparison will be true if and only if there
// is a node in the node-set such that the result of performing
// the comparison on the string-value of the node and the other
// string is true.
int node;
{
{
result = true;
break;
}
}
}
else
{
}
return result;
}
/**
* Tell if one object is less than the other.
*
* @param obj2 object to compare this nodeset to
*
* @return see this.compare(...)
*
* @throws javax.xml.transform.TransformerException
*/
{
}
/**
* Tell if one object is less than or equal to the other.
*
* @param obj2 object to compare this nodeset to
*
* @return see this.compare(...)
*
* @throws javax.xml.transform.TransformerException
*/
{
}
/**
* Tell if one object is less than the other.
*
* @param obj2 object to compare this nodeset to
*
* @return see this.compare(...)
*
* @throws javax.xml.transform.TransformerException
*/
{
}
/**
* Tell if one object is less than the other.
*
* @param obj2 object to compare this nodeset to
*
* @return see this.compare(...)
*
* @throws javax.xml.transform.TransformerException
*/
{
}
/**
* Tell if two objects are functionally equal.
*
* @param obj2 object to compare this nodeset to
*
* @return see this.compare(...)
*
* @throws javax.xml.transform.TransformerException
*/
{
try
{
}
{
}
}
/**
* Tell if two objects are functionally not equal.
*
* @param obj2 object to compare this nodeset to
*
* @return see this.compare(...)
*
* @throws javax.xml.transform.TransformerException
*/
{
}
}
/**
* compares nodes for various boolean operations.
*/
abstract class Comparator
{
/**
* Compare two strings
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return Whether the strings are equal or not
*/
/**
* Compare two numbers
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return Whether the numbers are equal or not
*/
}
/**
* Compare strings or numbers for less than.
*/
{
/**
* Compare two strings for less than.
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return True if s1 is less than s2
*/
{
// return s1.compareTo(s2) < 0;
}
/**
* Compare two numbers for less than.
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return true if n1 is less than n2
*/
{
}
}
/**
* Compare strings or numbers for less than or equal.
*/
{
/**
* Compare two strings for less than or equal.
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return true if s1 is less than or equal to s2
*/
{
// return s1.compareTo(s2) <= 0;
}
/**
* Compare two numbers for less than or equal.
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return true if n1 is less than or equal to n2
*/
{
}
}
/**
* Compare strings or numbers for greater than.
*/
{
/**
* Compare two strings for greater than.
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return true if s1 is greater than s2
*/
{
// return s1.compareTo(s2) > 0;
}
/**
* Compare two numbers for greater than.
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return true if n1 is greater than n2
*/
{
}
}
/**
* Compare strings or numbers for greater than or equal.
*/
{
/**
* Compare two strings for greater than or equal.
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return true if s1 is greater than or equal to s2
*/
{
// return s1.compareTo(s2) >= 0;
}
/**
* Compare two numbers for greater than or equal.
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return true if n1 is greater than or equal to n2
*/
{
}
}
/**
* Compare strings or numbers for equality.
*/
{
/**
* Compare two strings for equality.
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return true if s1 is equal to s2
*/
{
}
/**
* Compare two numbers for equality.
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return true if n1 is equal to n2
*/
{
}
}
/**
* Compare strings or numbers for non-equality.
*/
{
/**
* Compare two strings for non-equality.
*
*
* @param s1 First string to compare
* @param s2 Second String to compare
*
* @return true if s1 is not equal to s2
*/
{
}
/**
* Compare two numbers for non-equality.
*
*
* @param n1 First number to compare
* @param n2 Second number to compare
*
* @return true if n1 is not equal to n2
*/
{
}
}