sboag 01/05/20 10:33:27
Modified: java/src/org/apache/xml/dtm Tag: DTM_EXP DTM.java
DTMDefaultBase.java DTMDocumentImpl.java
ExpandedNameTable.java
java/src/org/apache/xml/dtm/dom2dtm Tag: DTM_EXP
DOM2DTM.java
java/src/org/apache/xml/dtm/sax2dtm Tag: DTM_EXP
SAX2DTM.java
Added: java/src/org/apache/xml/dtm Tag: DTM_EXP Axis.java
DTMAxisIterator.java DTMAxisIteratorBase.java
Log:
Added getTypedAxisIterator and getAxisIterator for DTM. Added
DTMAxisIterator, DTMAxisIteratorBase, and Axes classes based
on XSLTC classes. Added AncestorIterator, AttributeIterator,
ChildrenIterator, DescendantIterator, FollowingIterator,
FollowingSiblingIterator, NamespaceAttributeIterator,
NamespaceChildrenIterator, NthDescendantIterator, ParentIterator,
PrecedingIterator, PrecedingSiblingIterator, SingletonIterator,
TypedAncestorIterator, TypedAttributeIterator, TypedChildrenIterator,
TypedDescendantIterator, TypedFollowingIterator,
TypedFollowingSiblingIterator, TypedPrecedingIterator,
TypedPrecedingSiblingIterator, and TypedSingletonIterator
based on XSLTC. These are as of yet untested.
Abandon m_info variable in DTMDefaultBase and derivatives,
in favor of an array for each field, and an access function for
each field. This decision was based on performance profiling.
The resizing strategy needs to be reviewed by Joe (see ensureSize).
Revision Changes Path
No revision
No revision
1.1.2.17 +32 -9 xml-xalan/java/src/org/apache/xml/dtm/Attic/DTM.java
Index: DTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTM.java,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -u -r1.1.2.16 -r1.1.2.17
--- DTM.java 2001/05/18 07:16:35 1.1.2.16
+++ DTM.java 2001/05/20 17:33:26 1.1.2.17
@@ -90,7 +90,7 @@
* implementation of DTM can be created that wraps a DOM and vice
* versa.</p>
*
- * <p>State: In progress!!</p>
+ * <p>State: In progress!!</p>
*/
public interface DTM
{
@@ -187,6 +187,29 @@
public void setFeature(String featureId, boolean state);
// ========= Document Navigation Functions =========
+
+ /**
+ * This is a shortcut to the iterators that implement the
+ * supported XPath axes (only namespace::) is not supported.
+ * Returns a bare-bones iterator that must be initialized
+ * with a start node (using iterator.setStartNode()).
+ *
+ * @param axis One of Axes.ANCESTORORSELF, etc.
+ *
+ * @return A DTMAxisIterator, or null if the givin axis isn't supported.
+ */
+ public DTMAxisIterator getAxisIterator(final int axis);
+
+ /**
+ * Get an iterator that can navigate over an XPath Axis, predicated by
+ * the extended type ID.
+ *
+ * @param axis
+ * @param type An extended type ID.
+ *
+ * @return A DTMAxisIterator, or null if the givin axis isn't supported.
+ */
+ public DTMAxisIterator getTypedAxisIterator(final int axis, final int
type);
/**
* Given a node handle, test if it has child nodes.
@@ -384,7 +407,7 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(int nodeHandle);
+ public int getExpandedTypeID(int nodeHandle);
/**
* Given an expanded name, return an ID. If the expanded-name does not
@@ -400,7 +423,7 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(String namespace, String localName, int type);
+ public int getExpandedTypeID(String namespace, String localName, int type);
/**
* Given an expanded-name ID, return the local name part.
@@ -699,7 +722,7 @@
*
* @return false if secondNode comes before firstNode, otherwise return
true.
* You can think of this as
- * <code>(firstNode.documentOrderPosition <=
secondNode.documentOrderPosition)</code>.
+ * <code>(firstNode.documentOrderPosition <=
secondNode.documentOrderPosition)</code>.
*/
public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle);
@@ -793,15 +816,15 @@
*/
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
throws org.xml.sax.SAXException;
-
+
/**
* Return an DOM node for the given node.
- *
+ *
* @param nodeHandle The node ID.
- *
+ *
* @return A node representation of the DTM node.
*/
- public org.w3c.dom.Node getNode(int nodeHandle);
+ public org.w3c.dom.Node getNode(int nodeHandle);
// ==== Construction methods (may not be supported by some
implementations!) =====
// %REVIEW% What response occurs if not supported?
@@ -880,7 +903,7 @@
* @param newChild Must be a valid new node handle.
* @param clone true if the child should be cloned into the document.
* @param cloneDepth if the clone argument is true, specifies that the
- * clone should include all it's children.
+ * clone should include all it's children.
*/
public void appendChild(int newChild, boolean clone, boolean cloneDepth);
1.1.2.8 +2067 -115
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDefaultBase.java
Index: DTMDefaultBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDefaultBase.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- DTMDefaultBase.java 2001/05/18 07:16:36 1.1.2.7
+++ DTMDefaultBase.java 2001/05/20 17:33:26 1.1.2.8
@@ -86,43 +86,36 @@
{
/**
- * This is extra information about the node objects. Each information
- * block is composed of several array members. The size of this will
always
- * be (m_nodes.size() * NODEINFOBLOCKSIZE).
+ * The number of nodes, which is also used to determine the next
+ * node index.
*/
- protected IntVector m_info = new IntVector();
+ protected int m_size = 0;
- // Offsets into each set of integers in the <code>m_info</code> table.
+ /** The expanded names, one array element for each node. */
+ protected int[] m_exptype;
- /** %TBD% Doc */
- protected static final int OFFSET_EXPANDEDNAMEID = 0;
+ /** levels deep, one array element for each node. */
+ protected byte[] m_level;
- /** %TBD% Doc */
- protected static final int OFFSET_TYPE = 1;
+ /** First child values, one array element for each node. */
+ protected int[] m_firstch;
- /** %TBD% Doc */
- protected static final int OFFSET_LEVEL = 2;
+ /** Next sibling values, one array element for each node. */
+ protected int[] m_nextsib;
- /** %TBD% Doc */
- protected static final int OFFSET_FIRSTCHILD = 3;
+ /** Previous sibling values, one array element for each node. */
+ protected short[] m_prevsib;
- /** %TBD% Doc */
- protected static final int OFFSET_NEXTSIBLING = 4;
+ /** Previous sibling values, one array element for each node. */
+ protected short[] m_parent;
- /** %TBD% Doc */
- protected static final int OFFSET_PREVSIBLING = 5;
+ /** The default initial block size of the node arrays */
+ protected int m_initialblocksize = 512; // favor small docs.
- /** %TBD% Doc */
- protected static final int OFFSET_PARENT = 6;
+ /** Size of blocks to allocate */
+ protected int m_blocksize = 2 * 1024;
/**
- * This represents the number of integers per node in the
- * <code>m_info</code> member variable, if the derived class
- * does not add information.
- */
- protected static final int DEFAULTNODEINFOBLOCKSIZE = 7;
-
- /**
* The value to use when the information has not been built yet.
*/
protected static final int NOTPROCESSED = DTM.NULL - 1;
@@ -135,13 +128,13 @@
*/
protected DTMManager m_mgr;
- /** %TBD% Doc */
+ /** The document identity, which is OR'd with node indexes to make
handles. */
protected int m_dtmIdent;
- /** %TBD% Doc */
+ /** The mask for the identity. %REVIEW% static constant? */
protected int m_mask;
- /** %TBD% Doc */
+ /** The base URI for this document. */
protected String m_documentBaseURI;
/**
@@ -154,25 +147,35 @@
/** Stack of flags indicating whether to strip whitespace nodes */
protected BoolStack m_shouldStripWhitespaceStack;
-
+
/** The XMLString factory for creating XMLStrings. */
protected XMLStringFactory m_xstrf;
+ /** The identity of the root node. */
+ public static final int ROOTNODE = 0;
+
/**
* Construct a DTMDefaultBase object from a DOM node.
*
* @param mgr The DTMManager who owns this DTM.
* @param domSource the DOM source that this DTM will wrap.
- * NEEDSDOC @param source
+ * @param source The object that is used to specify the construction
source.
* @param dtmIdentity The DTM identity ID for this DTM.
* @param whiteSpaceFilter The white space filter for this DTM, which may
* be null.
+ * @param xstringfactory The factory to use for creating XMLStrings.
*/
public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory)
{
+ m_exptype = new int[m_initialblocksize];
+ m_level = new byte[m_initialblocksize];
+ m_firstch = new int[m_initialblocksize];
+ m_nextsib = new int[m_initialblocksize];
+ m_prevsib = new short[m_initialblocksize];
+ m_parent = new short[m_initialblocksize];
m_mgr = mgr;
m_documentBaseURI = (null != source) ? source.getSystemId() : null;
m_dtmIdent = dtmIdentity;
@@ -205,36 +208,140 @@
*/
protected abstract boolean nextNode();
+ /**
+ * Get the number of nodes that have been added.
+ *
+ * @return the number of nodes that have been mapped.
+ */
+ protected abstract int getNumberOfNodes();
+
+ /**
+ * Ensure that the size of the information arrays can hold another entry
+ * at the given index.
+ *
+ * @param on exit from this function, the information arrays sizes must be
+ * at least index+1.
+ *
+ * NEEDSDOC @param index
+ */
+ protected void ensureSize(int index)
+ {
+
+ int capacity = m_exptype.length;
+
+ if (capacity <= index)
+ {
+ int[] exptype = m_exptype;
+ byte[] level = m_level;
+ int[] firstch = m_firstch;
+ int[] nextsib = m_nextsib;
+ short[] prevsib = m_prevsib;
+ short[] parent = m_parent;
+ int newcapacity = capacity + m_blocksize;
+
+ m_exptype = new int[newcapacity];
+ m_level = new byte[newcapacity];
+ m_firstch = new int[newcapacity];
+ m_nextsib = new int[newcapacity];
+ m_prevsib = new short[newcapacity];
+ m_parent = new short[newcapacity];
+
+ System.arraycopy(exptype, 0, m_exptype, 0, capacity);
+ System.arraycopy(level, 0, m_level, 0, capacity);
+ System.arraycopy(firstch, 0, m_firstch, 0, capacity);
+ System.arraycopy(nextsib, 0, m_nextsib, 0, capacity);
+ System.arraycopy(prevsib, 0, m_prevsib, 0, capacity);
+ System.arraycopy(parent, 0, m_parent, 0, capacity);
+
+ // %REVIEW%
+ m_blocksize = m_blocksize + m_blocksize;
+ }
+ }
+
/**
- * Return the number of integers in each node info block.
+ * Get the simple type ID for the given node identity.
+ *
+ * @param identity The node identity.
*
- * NEEDSDOC ($objectName$) @return
+ * @return The simple type ID, or DTM.NULL.
*/
- protected int getNodeInfoBlockSize()
+ protected int _type(int identity)
{
- return DEFAULTNODEINFOBLOCKSIZE;
+
+ int info = getExpandedTypeID(identity);
+
+ if (NULL != info)
+ return ExpandedNameTable.getType(info);
+ else
+ return NULL;
}
/**
- * Get the number of nodes that have been added.
+ * Get the expanded type ID for the given node identity.
+ *
+ * @param identity The node identity.
*
- * NEEDSDOC ($objectName$) @return
+ * @return The expanded type ID, or DTM.NULL.
*/
- protected abstract int getNumberOfNodes();
+ protected int _exptype(int identity)
+ {
+
+ if (identity < m_size)
+ return m_exptype[identity];
+
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
+ // processed.
+ while (true)
+ {
+ boolean isMore = nextNode();
+
+ if (!isMore)
+ return NULL;
+ else if (identity < m_size)
+ return m_exptype[identity];
+ }
+ }
+
+ /**
+ * Get the level in the tree for the given node identity.
+ *
+ * @param identity The node identity.
+ *
+ * @return The tree level, or DTM.NULL.
+ */
+ protected int _level(int identity)
+ {
+
+ if (identity < m_size)
+ return m_level[identity];
+
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
+ // processed.
+ while (true)
+ {
+ boolean isMore = nextNode();
+
+ if (!isMore)
+ return NULL;
+ else if (identity < m_size)
+ return m_level[identity];
+ }
+ }
/**
- * Get a node handle that is relative to the given node.
+ * Get the first child for the given node identity.
*
* @param identity The node identity.
- * @param offsetValue One of OFFSET_XXX values.
- * @return The relative node handle.
+ *
+ * @return The first child identity, or DTM.NULL.
*/
- protected int getNodeInfo(int identity, int offsetValue)
+ protected int _firstch(int identity)
{
- int base = (identity * getNodeInfoBlockSize());
- int info = (identity >= getNumberOfNodes())
- ? NOTPROCESSED : m_info.elementAt(base + offsetValue);
+ // Boiler-plate code for each of the _xxx functions, except for the
array.
+ int info = (identity >= m_size) ? NOTPROCESSED : m_firstch[identity];
// Check to see if the information requested has been processed, and,
// if not, advance the iterator until we the information has been
@@ -243,34 +350,96 @@
{
boolean isMore = nextNode();
- if (identity >= getNumberOfNodes())
- {
- info = NOTPROCESSED;
- }
+ if (identity >= m_size &&!isMore)
+ return NULL;
else
- info = m_info.elementAt(base + offsetValue);
+ info = m_firstch[identity];
+ }
- if (!isMore && NOTPROCESSED == info)
- return DTM.NULL;
+ return info;
+ }
+
+ /**
+ * Get the next sibling for the given node identity.
+ *
+ * @param identity The node identity.
+ *
+ * @return The next sibling identity, or DTM.NULL.
+ */
+ protected int _nextsib(int identity)
+ {
+
+ // Boiler-plate code for each of the _xxx functions, except for the
array.
+ int info = (identity >= m_size) ? NOTPROCESSED : m_nextsib[identity];
+
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
+ // processed.
+ while (info == NOTPROCESSED)
+ {
+ boolean isMore = nextNode();
+
+ if (identity >= m_size &&!isMore)
+ return NULL;
+ else
+ info = m_nextsib[identity];
}
return info;
}
+ /**
+ * Get the previous sibling for the given node identity.
+ *
+ * @param identity The node identity.
+ *
+ * @return The previous sibling identity, or DTM.NULL.
+ */
+ protected int _prevsib(int identity)
+ {
+
+ if (identity < m_size)
+ return m_prevsib[identity];
+
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
+ // processed.
+ while (true)
+ {
+ boolean isMore = nextNode();
+
+ if (!isMore)
+ return NULL;
+ else if (identity < m_size)
+ return m_prevsib[identity];
+ }
+ }
+
/**
- * Get a node handle that is relative to the given node, but don't check
for
- * the NOTPROCESSED flag. A class will need to use this call to get values
- * that may be negative. Also, it's a tiny bit faster than getNodeInfo if
- * you know that NOTPROCESSED is not a possibility.
+ * Get the parent for the given node identity.
*
* @param identity The node identity.
- * @param offsetValue One of OFFSET_XXX values.
- * @return The relative node handle.
+ *
+ * @return The parent identity, or DTM.NULL.
*/
- protected int getNodeInfoNoWait(int identity, int offsetValue)
+ protected int _parent(int identity)
{
- return m_info.elementAt((identity * getNodeInfoBlockSize())
- + offsetValue);
+
+ if (identity < m_size)
+ return m_parent[identity];
+
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
+ // processed.
+ while (true)
+ {
+ boolean isMore = nextNode();
+
+ if (!isMore)
+ return NULL;
+ else if (identity < m_size)
+ return m_parent[identity];
+ }
}
/**
@@ -281,15 +450,12 @@
while (nextNode()){}
- int sizePerRecord = getNodeInfoBlockSize();
- int nRecords = m_info.size() / sizePerRecord;
+ int nRecords = m_size;
System.out.println("Total nodes: " + nRecords);
for (int i = 0; i < nRecords; i++)
{
- int offset = i * sizePerRecord;
-
System.out.println("=========== " + i + " ===========");
System.out.println("NodeName: " + getNodeName(i));
System.out.println("NodeNameX: " + getNodeNameX(i));
@@ -297,7 +463,7 @@
System.out.println("NamespaceURI: " + getNamespaceURI(i));
System.out.println("Prefix: " + getPrefix(i));
- int exTypeID = getExpandedNameID(i);
+ int exTypeID = getExpandedTypeID(i);
System.out.println("Expanded Type ID: "
+ Integer.toHexString(exTypeID));
@@ -356,7 +522,7 @@
System.out.println("Type: " + typestring);
- int firstChild = m_info.elementAt(offset + OFFSET_FIRSTCHILD);
+ int firstChild = _firstch(i);
if (DTM.NULL == firstChild)
System.out.println("First child: DTM.NULL");
@@ -365,7 +531,7 @@
else
System.out.println("First child: " + firstChild);
- int prevSibling = m_info.elementAt(offset + OFFSET_PREVSIBLING);
+ int prevSibling = _prevsib(i);
if (DTM.NULL == prevSibling)
System.out.println("Prev sibling: DTM.NULL");
@@ -374,7 +540,7 @@
else
System.out.println("Prev sibling: " + prevSibling);
- int nextSibling = m_info.elementAt(offset + OFFSET_NEXTSIBLING);
+ int nextSibling = _nextsib(i);
if (DTM.NULL == nextSibling)
System.out.println("Next sibling: DTM.NULL");
@@ -383,7 +549,7 @@
else
System.out.println("Next sibling: " + nextSibling);
- int parent = m_info.elementAt(offset + OFFSET_PARENT);
+ int parent = _parent(i);
if (DTM.NULL == parent)
System.out.println("Parent: DTM.NULL");
@@ -392,7 +558,7 @@
else
System.out.println("Parent: " + parent);
- int level = m_info.elementAt(offset + OFFSET_LEVEL);
+ int level = _level(i);
System.out.println("Level: " + level);
System.out.println("Node Value: " + getNodeValue(i));
@@ -430,7 +596,7 @@
{
int identity = nodeHandle & m_mask;
- int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+ int firstChild = _firstch(identity);
return firstChild != DTM.NULL;
}
@@ -447,7 +613,7 @@
{
int identity = nodeHandle & m_mask;
- int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+ int firstChild = _firstch(identity);
return firstChild | m_dtmIdent;
}
@@ -465,13 +631,13 @@
{
int identity = nodeHandle & m_mask;
- int child = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+ int child = _firstch(identity);
int lastChild = DTM.NULL;
while (child != DTM.NULL)
{
lastChild = child;
- child = getNodeInfo(child, OFFSET_NEXTSIBLING);
+ child = _nextsib(child);
}
return lastChild | m_dtmIdent;
@@ -541,7 +707,7 @@
{
int identity = nodeHandle & m_mask;
- int nextSibling = getNodeInfo(identity, OFFSET_NEXTSIBLING);
+ int nextSibling = _nextsib(identity);
return nextSibling | m_dtmIdent;
}
@@ -557,10 +723,7 @@
*/
public int getPreviousSibling(int nodeHandle)
{
-
- int firstChild = getNodeInfo(nodeHandle & m_mask, OFFSET_PREVSIBLING);
-
- return firstChild | m_dtmIdent;
+ return _prevsib(nodeHandle & m_mask) | m_dtmIdent;
}
/**
@@ -601,16 +764,17 @@
return DTM.NULL;
}
- /** NEEDSDOC Field m_namespaceLists */
+ /** Lazily created namespace lists. */
private Vector m_namespaceLists = null; // on demand
/**
- * NEEDSDOC Method getNamespaceList
+ * Get a full list of namespace handles for the given element. In other
words
+ * get all the namespace nodes in context for the given element.
*
*
- * NEEDSDOC @param baseHandle
+ * @param baseHandle The base element handle.
*
- * NEEDSDOC (getNamespaceList) @return
+ * @return A list of namespace handles for this element.
*/
protected NodeVector getNamespaceList(int baseHandle)
{
@@ -638,12 +802,13 @@
}
/**
- * NEEDSDOC Method buildNamespaceList
+ * Build a list of all namespace nodes in context for this element.
*
*
- * NEEDSDOC @param baseHandle
+ * @param baseHandle The base element handle.
*
- * NEEDSDOC (buildNamespaceList) @return
+ * @return a NodeVector that contains a list of all namespace nodes in
+ * context for this element.
*/
private NodeVector buildNamespaceList(int baseHandle)
{
@@ -762,8 +927,9 @@
* was relative to (needed to return nodes in document order).
* @param namespaceHandle handle to node which must be of type
* NAMESPACE_NODE.
- * NEEDSDOC @param nodeHandle
- * NEEDSDOC @param inScope
+ * @param nodeHandle A namespace handle for which we will find the next
node.
+ * @param inScope true if all namespaces that are in scope should be
processed,
+ * otherwise just process the nodes in the given element handle.
* @return handle of next namespace, or DTM.NULL to indicate none exists.
*/
public int getNextNamespaceNode(int baseHandle, int nodeHandle,
@@ -826,11 +992,7 @@
int identity = nodeHandle & m_mask;
if (identity > 0)
- {
- int parent = getNodeInfo(identity, OFFSET_PARENT);
-
- return parent | m_dtmIdent;
- }
+ return _parent(identity) | m_dtmIdent;
else
return DTM.NULL;
}
@@ -934,11 +1096,11 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(int nodeHandle)
+ public int getExpandedTypeID(int nodeHandle)
{
int identity = nodeHandle & m_mask;
- int expandedNameID = getNodeInfo(identity, OFFSET_EXPANDEDNAMEID);
+ int expandedNameID = _exptype(identity);
return expandedNameID;
}
@@ -950,19 +1112,22 @@
* expanded name will use this ID.
*
* @param nodeHandle The handle to the node in question.
- * NEEDSDOC @param type
+ * @param type The simple type, i.e. one of ELEMENT, ATTRIBUTE, etc.
*
- * NEEDSDOC @param namespace
- * NEEDSDOC @param localName
+ * @param namespace The namespace URI, which may be null, may be an empty
+ * string (which will be the same as null), or may be a
+ * namespace URI.
+ * @param localName The local name string, which must be a valid
+ * <a
href="http://www.w3.org/TR/REC-xml-names/">NCName</a>.
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(String namespace, String localName, int type)
+ public int getExpandedTypeID(String namespace, String localName, int type)
{
ExpandedNameTable ent = m_mgr.getExpandedNameTable(this);
- return ent.getExpandedNameID(namespace, localName, type);
+ return ent.getExpandedTypeID(namespace, localName, type);
}
/**
@@ -995,6 +1160,20 @@
}
/**
+ * Returns the namespace type of a specific node
+ * @param nodeHandle the id of the node.
+ * @return the ID of the namespace.
+ */
+ public int getNamespaceType(final int nodeHandle)
+ {
+
+ int identity = nodeHandle & m_mask;
+ int expandedNameID = _exptype(identity);
+
+ return ExpandedNameTable.getNamespaceID(expandedNameID);
+ }
+
+ /**
* Given a node handle, return its DOM-style node name. This will
* include names such as #text or #document.
*
@@ -1082,7 +1261,7 @@
{
int identity = nodeHandle & m_mask;
- short type = (short) getNodeInfo(identity, OFFSET_TYPE);
+ short type = (short) _type(identity);
return type;
}
@@ -1101,7 +1280,7 @@
int identity = nodeHandle & m_mask;
// Apparently, the axis walker stuff requires levels to count from 1.
- return (short) (getNodeInfo(identity, OFFSET_LEVEL) + 1);
+ return (short) (_level(identity) + 1);
}
// ============== Document query functions ==============
@@ -1115,7 +1294,7 @@
* If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
- * NEEDSDOC @param version
+ * @param version The version string of the feature requested, may be null.
* @return Returns <code>true</code> if the specified feature is
* supported on this node, <code>false</code> otherwise.
*/
@@ -1196,10 +1375,8 @@
* property is derived from the XML declaration optionally present at the
* beginning of the document entity, and has no value if there is no XML
* declaration.
- *
- * @param the document handle
*
- * NEEDSDOC @param documentHandle
+ * @param documentHandle The document handle
*
* @return the document version String object.
*/
@@ -1326,12 +1503,9 @@
*
* TODO: Make sure this does the right thing with attribute nodes!!!
*
- * @param node1 DOM Node to perform position comparison on.
- * @param node2 DOM Node to perform position comparison on .
+ * @param nodeHandle1 Node handle to perform position comparison on.
+ * @param nodeHandle2 Second Node handle to perform position comparison on
.
*
- * NEEDSDOC @param nodeHandle1
- * NEEDSDOC @param nodeHandle2
- *
* @return false if node2 comes before node1, otherwise return true.
* You can think of this as
* <code>(node1.documentOrderPosition <=
node2.documentOrderPosition)</code>.
@@ -1392,9 +1566,8 @@
* specified in the start-tag of its element, or was defaulted from
the
* DTD.
*
- * @param the attribute handle
+ * @param attributeHandle The attribute handle in question.
*
- * NEEDSDOC @param attributeHandle
* @return <code>true</code> if the attribute was specified;
* <code>false</code> if it was defaulted.
*/
@@ -1479,7 +1652,7 @@
/**
* Simple error for asserts and the like.
*
- * NEEDSDOC @param msg
+ * @param msg Error message to report.
*/
protected void error(String msg)
{
@@ -1538,4 +1711,1783 @@
if (null != m_shouldStripWhitespaceStack)
m_shouldStripWhitespaceStack.setTop(shouldStrip);
}
+
+ /**
+ * Get an iterator that can navigate over an XPath Axis, predicated by
+ * the extended type ID.
+ *
+ * @param axis One of Axes.ANCESTORORSELF, etc.
+ * @param type An extended type ID.
+ *
+ * @return A DTMAxisIterator, or null if the givin axis isn't supported.
+ */
+ public DTMAxisIterator getTypedAxisIterator(int axis, int type)
+ {
+
+ DTMAxisIterator iterator = null;
+
+ /* This causes an error when using patterns for elements that
+ do not exist in the DOM (translet types which do not correspond
+ to a DOM type are mapped to the DOM.ELEMENT type).
+ */
+
+ // if (type == NO_TYPE) {
+ // return(EMPTYITERATOR);
+ // }
+ // else if (type == ELEMENT) {
+ // iterator = new FilterIterator(getAxisIterator(axis),
+ // getElementFilter());
+ // }
+ // else
+ {
+ switch (axis)
+ {
+ case Axis.SELF :
+ iterator = new TypedSingletonIterator(type);
+ break;
+ case Axis.CHILD :
+ iterator = new TypedChildrenIterator(type);
+ break;
+ case Axis.PARENT :
+ return (new ParentIterator().setNodeType(type));
+ case Axis.ANCESTOR :
+ return (new TypedAncestorIterator(type));
+ case Axis.ANCESTORORSELF :
+ return ((new TypedAncestorIterator(type)).includeSelf());
+ case Axis.ATTRIBUTE :
+ return (new TypedAttributeIterator(type));
+ case Axis.DESCENDANT :
+ iterator = new TypedDescendantIterator(type);
+ break;
+ case Axis.DESCENDANTORSELF :
+ iterator = (new TypedDescendantIterator(type)).includeSelf();
+ break;
+ case Axis.FOLLOWING :
+ iterator = new TypedFollowingIterator(type);
+ break;
+ case Axis.PRECEDING :
+ iterator = new TypedPrecedingIterator(type);
+ break;
+ case Axis.FOLLOWINGSIBLING :
+ iterator = new TypedFollowingSiblingIterator(type);
+ break;
+ case Axis.PRECEDINGSIBLING :
+ iterator = new TypedPrecedingSiblingIterator(type);
+ break;
+ default :
+ throw new DTMException("Error: typed iterator for axis "
+ + Axis.names[axis] + "not implemented");
+ }
+ }
+
+ return (iterator);
+ }
+
+ /**
+ * This is a shortcut to the iterators that implement the
+ * supported XPath axes (only namespace::) is not supported.
+ * Returns a bare-bones iterator that must be initialized
+ * with a start node (using iterator.setStartNode()).
+ *
+ * @param axis One of Axes.ANCESTORORSELF, etc.
+ *
+ * @return A DTMAxisIterator, or null if the givin axis isn't supported.
+ */
+ public DTMAxisIterator getAxisIterator(final int axis)
+ {
+
+ DTMAxisIterator iterator = null;
+
+ switch (axis)
+ {
+ case Axis.SELF :
+ iterator = new SingletonIterator();
+ break;
+ case Axis.CHILD :
+ iterator = new ChildrenIterator();
+ break;
+ case Axis.PARENT :
+ return (new ParentIterator());
+ case Axis.ANCESTOR :
+ return (new AncestorIterator());
+ case Axis.ANCESTORORSELF :
+ return ((new AncestorIterator()).includeSelf());
+ case Axis.ATTRIBUTE :
+ return (new AttributeIterator());
+ case Axis.DESCENDANT :
+ iterator = new DescendantIterator();
+ break;
+ case Axis.DESCENDANTORSELF :
+ iterator = (new DescendantIterator()).includeSelf();
+ break;
+ case Axis.FOLLOWING :
+ iterator = new FollowingIterator();
+ break;
+ case Axis.PRECEDING :
+ iterator = new PrecedingIterator();
+ break;
+ case Axis.FOLLOWINGSIBLING :
+ iterator = new FollowingSiblingIterator();
+ break;
+ case Axis.PRECEDINGSIBLING :
+ iterator = new PrecedingSiblingIterator();
+ break;
+ case Axis.NAMESPACE :
+
+ // return(new N()); %TBD%
+ default :
+ throw new DTMException("Error: iterator for axis '" + Axis.names[axis]
+ + "' not implemented");
+ }
+
+ return (iterator);
+ }
+
+ /**
+ * Iterator that returns all children of a given node
+ */
+ private final class ChildrenIterator extends DTMAxisIteratorBase
+ {
+
+ /** child to return next. */
+ private int _currentChild;
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(final int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _currentChild = NOTPROCESSED;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ _currentChild = (NOTPROCESSED == _currentChild)
+ ? getFirstChild(_startNode)
+ : getNextSibling(_currentChild);
+
+ return returnNode(_currentChild);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _currentChild;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _currentChild = _markedNode;
+ }
+ } // end of ChildrenIterator
+
+ /**
+ * Iterator that returns the parent of a given node
+ */
+ private final class ParentIterator extends DTMAxisIteratorBase
+ {
+
+ /** candidate parent node. */
+ private int _node;
+
+ /** The extended type ID that was requested. */
+ private int _nodeType = -1;
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _node = getParent(node);
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Set the node type of the parent that we're looking for.
+ *
+ *
+ * @param type extended type ID.
+ *
+ * @return The node type.
+ */
+ public DTMAxisIterator setNodeType(final int type)
+ {
+
+ _nodeType = type;
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int result = _node;
+
+ if ((_nodeType != -1) && (getExpandedTypeID(_node) != _nodeType))
+ result = END;
+ else
+ result = _node;
+
+ _node = END;
+
+ return returnNode(result);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ } // end of ParentIterator
+
+ /**
+ * Iterator that returns children of a given type for a given node.
+ * The functionality chould be achieved by putting a filter on top
+ * of a basic child iterator, but a specialised iterator is used
+ * for efficiency (both speed and size of translet).
+ */
+ private final class TypedChildrenIterator extends DTMAxisIteratorBase
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /** node to consider next. */
+ private int _currentChild;
+
+ /**
+ * Constructor TypedChildrenIterator
+ *
+ *
+ * @param nodeType The extended type ID being requested.
+ */
+ public TypedChildrenIterator(int nodeType)
+ {
+ _nodeType = nodeType;
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _currentChild = NOTPROCESSED;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ for (int node = (NOTPROCESSED == _currentChild)
+ ? getFirstChild(_startNode)
+ : getNextSibling(_currentChild); node
+ != END; node = getNextSibling(node))
+ {
+ if (getExpandedTypeID(node) == _nodeType)
+ {
+ _currentChild = node;
+
+ return returnNode(node);
+ }
+ }
+
+ return END;
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _currentChild;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _currentChild = _markedNode;
+ }
+ } // end of TypedChildrenIterator
+
+ /**
+ * Iterator that returns children within a given namespace for a
+ * given node. The functionality chould be achieved by putting a
+ * filter on top of a basic child iterator, but a specialised
+ * iterator is used for efficiency (both speed and size of translet).
+ */
+ private final class NamespaceChildrenIterator extends DTMAxisIteratorBase
+ {
+
+ /** The extended type ID being requested. */
+ private final int _nsType;
+
+ /** The current child. */
+ private int _currentChild;
+
+ /**
+ * Constructor NamespaceChildrenIterator
+ *
+ *
+ * @param type The extended type ID being requested.
+ */
+ public NamespaceChildrenIterator(final int type)
+ {
+ _nsType = type;
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _currentChild = NOTPROCESSED;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ for (int node = (NOTPROCESSED == _currentChild)
+ ? getFirstChild(_startNode)
+ : getNextSibling(_currentChild); node
+ != END; node = getNextSibling(node))
+ {
+ if (getNamespaceType(node) == _nsType)
+ {
+ _currentChild = node;
+
+ return returnNode(node);
+ }
+ }
+
+ return END;
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _currentChild;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _currentChild = _markedNode;
+ }
+ } // end of TypedChildrenIterator
+
+ /**
+ * Iterator that returns attributes within a given namespace for a node.
+ */
+ private final class NamespaceAttributeIterator extends DTMAxisIteratorBase
+ {
+
+ /** The extended type ID being requested. */
+ private final int _nsType;
+
+ /** The current attribute. */
+ private int _attribute;
+
+ /**
+ * Constructor NamespaceAttributeIterator
+ *
+ *
+ * @param nsType The extended type ID being requested.
+ */
+ public NamespaceAttributeIterator(int nsType)
+ {
+
+ super();
+
+ _nsType = nsType;
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _attribute = getFirstNamespaceNode(node, false);
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node = _attribute;
+
+ if (DTM.NULL != node)
+ _attribute = getNextNamespaceNode(_startNode, node, false);
+
+ return returnNode(node);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _attribute;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _attribute = _markedNode;
+ }
+ } // end of TypedChildrenIterator
+
+ /**
+ * Iterator that returns all siblings of a given node.
+ */
+ private class FollowingSiblingIterator extends DTMAxisIteratorBase
+ {
+
+ /** The current node. */
+ private int _node;
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _node = _startNode = node;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+ return returnNode(_node = getNextSibling(_node));
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ } // end of FollowingSiblingIterator
+
+ /**
+ * Iterator that returns all following siblings of a given node.
+ */
+ private final class TypedFollowingSiblingIterator
+ extends FollowingSiblingIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedFollowingSiblingIterator
+ *
+ *
+ * @param type The extended type ID being requested.
+ */
+ public TypedFollowingSiblingIterator(int type)
+ {
+ _nodeType = type;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node;
+
+ while ((node = super.next()) != NULL
+ && getExpandedTypeID(node) != _nodeType){}
+
+ return node;
+ }
+ } // end of TypedFollowingSiblingIterator
+
+ /**
+ * Iterator that returns attribute nodes (of what nodes?)
+ */
+ private final class AttributeIterator extends DTMAxisIteratorBase
+ {
+
+ /** The current attribute. */
+ private int _attribute;
+
+ // assumes caller will pass element nodes
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _attribute = getFirstAttribute(node);
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ final int node = _attribute;
+
+ _attribute = getNextAttribute(node);
+
+ return returnNode(node);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _attribute;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _attribute = _markedNode;
+ }
+ } // end of AttributeIterator
+
+ /**
+ * Iterator that returns attribute nodes of a given type
+ */
+ private final class TypedAttributeIterator extends DTMAxisIteratorBase
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /** The current attribute. */
+ private int _attribute;
+
+ /**
+ * Constructor TypedAttributeIterator
+ *
+ *
+ * @param nodeType The extended type ID that is requested.
+ */
+ public TypedAttributeIterator(int nodeType)
+ {
+ _nodeType = nodeType;
+ }
+
+ // assumes caller will pass element nodes
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+
+ for (node = getFirstAttribute(node); node != END;
+ node = getNextAttribute(node))
+ {
+ if (getExpandedTypeID(node) == _nodeType)
+ break;
+ }
+
+ _attribute = node;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ final int node = _attribute;
+
+ // singleton iterator, since there can only be one attribute of
+ // a given type.
+ _attribute = NULL;
+
+ return returnNode(node);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _attribute;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _attribute = _markedNode;
+ }
+ } // end of TypedAttributeIterator
+
+ /**
+ * Iterator that returns preceding siblings of a given node
+ */
+ private class PrecedingSiblingIterator extends DTMAxisIteratorBase
+ {
+
+ /** The start node (...on the left of the graph, I think. -sb) */
+ private int _start;
+
+ /** The current node. */
+ private int _node;
+
+ /**
+ * True if this iterator has a reversed axis.
+ *
+ * @return true.
+ */
+ public boolean isReverse()
+ {
+ return true;
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+ _node = getFirstChild(getParent(node));
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ if (_node == _start)
+ {
+ return NULL;
+ }
+ else
+ {
+ final int node = _node;
+
+ _node = getNextSibling(node);
+
+ return returnNode(node);
+ }
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ } // end of PrecedingSiblingIterator
+
+ /**
+ * Iterator that returns preceding siblings of a given type for
+ * a given node
+ */
+ private final class TypedPrecedingSiblingIterator
+ extends PrecedingSiblingIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedPrecedingSiblingIterator
+ *
+ *
+ * @param type The extended type ID being requested.
+ */
+ public TypedPrecedingSiblingIterator(int type)
+ {
+ _nodeType = type;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node;
+
+ while ((node = super.next()) != NULL
+ && getExpandedTypeID(node) != _nodeType){}
+
+ return node;
+ }
+ } // end of PrecedingSiblingIterator
+
+ /**
+ * Iterator that returns preceding nodes of a given node.
+ * This includes the node set {root+1, start-1}, but excludes
+ * all ancestors.
+ */
+ private class PrecedingIterator extends DTMAxisIteratorBase
+ {
+
+ /** The max ancestors, but it can grow... */
+ private final int _maxAncestors = 8;
+
+ /**
+ * The stack of start node + ancestors up to ROOTNODE,
+ * which we must avoid.
+ */
+ private int[] _stack = new int[_maxAncestors];
+
+ /** (not sure yet... -sb) */
+ private int _sp, _oldsp;
+
+ /** _node precedes candidates. This is the identity, not the handle! */
+ private int _node;
+
+ /**
+ * True if this iterator has a reversed axis.
+ *
+ * @return true since this iterator is a reversed axis.
+ */
+ public boolean isReverse()
+ {
+ return true;
+ }
+
+ /**
+ * Returns a deep copy of this iterator.
+ *
+ * @return a deep copy of this iterator.
+ */
+ public DTMAxisIterator cloneIterator()
+ {
+
+ _isRestartable = false;
+
+ final int[] stackCopy = new int[_maxAncestors];
+
+ try
+ {
+ final PrecedingIterator clone = (PrecedingIterator) super.clone();
+
+ System.arraycopy(_stack, 0, stackCopy, 0, _stack.length);
+
+ clone._stack = stackCopy;
+
+ return clone.reset();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new DTMException("Iterator clone not supported.");
+ }
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+
+ // iterator is not a clone
+ int parent, index;
+
+ _startNode = node;
+ _node = ROOTNODE; // Remember it's the identity, not the full
handle.
+ _stack[index = 0] = node;
+
+ if (node > ROOTNODE)
+ {
+ while ((parent = _parent(node)) != ROOTNODE)
+ {
+ if (++index == _stack.length)
+ {
+ final int[] stack = new int[index + 4];
+
+ System.arraycopy(_stack, 0, stack, 0, index);
+
+ _stack = stack;
+ }
+
+ _stack[index] = node = parent;
+ }
+ }
+
+ _oldsp = _sp = index;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ final int node = _node + 1;
+
+ if ((_sp >= 0) && (node < _stack[_sp]))
+ {
+ return returnNode((_node = node) | m_dtmIdent);
+ }
+ else
+ {
+ _node = node; // skip ancestor
+
+ return --_sp >= 0 ? next() : NULL;
+ }
+ }
+
+ // redefine DTMAxisIteratorBase's reset
+
+ /**
+ * Resets the iterator to the last start node.
+ *
+ * @return A DTMAxisIterator, which may or may not be the same as this
+ * iterator.
+ */
+ public DTMAxisIterator reset()
+ {
+
+ _sp = _oldsp;
+
+ return resetPosition();
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ } // end of PrecedingIterator
+
+ /**
+ * Iterator that returns preceding nodes of agiven type for a
+ * given node. This includes the node set {root+1, start-1}, but
+ * excludes all ancestors.
+ */
+ private final class TypedPrecedingIterator extends PrecedingIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedPrecedingIterator
+ *
+ *
+ * @param type The extended type ID being requested.
+ */
+ public TypedPrecedingIterator(int type)
+ {
+ _nodeType = type;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node;
+
+ while ((node = super.next()) != NULL
+ && getExpandedTypeID(node) != _nodeType){}
+
+ return node;
+ }
+ } // end of TypedPrecedingIterator
+
+ /**
+ * Iterator that returns following nodes of for a given node.
+ */
+ private class FollowingIterator extends DTMAxisIteratorBase
+ {
+
+ /** _node precedes search for next. */
+ protected int _node;
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ _startNode = node;
+
+ // ?? -sb
+ // find rightmost descendant (or self)
+ // int current;
+ // while ((node = getLastChild(current = node)) != NULL){}
+ // _node = current;
+ _node = node;
+
+ // _node precedes possible following(node) nodes
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node = _node;
+
+ while (END != node)
+ {
+ node++;
+
+ int type = _type(node);
+
+ if (DTM.NAMESPACE_NODE != type && DTM.ATTRIBUTE_NODE != type)
+ {
+ _node = node;
+
+ return returnNode(_node | m_dtmIdent);
+ }
+ }
+
+ return returnNode(_node = END);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ } // end of FollowingIterator
+
+ /**
+ * Iterator that returns following nodes of a given type for a given node.
+ */
+ private final class TypedFollowingIterator extends FollowingIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedFollowingIterator
+ *
+ *
+ * @param type The extended type ID being requested.
+ */
+ public TypedFollowingIterator(int type)
+ {
+ _nodeType = type;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node;
+
+ while ((node = super.next()) != NULL
+ && getExpandedTypeID(node) != _nodeType){}
+
+ return returnNode(node);
+ }
+ } // end of TypedFollowingIterator
+
+ /**
+ * Iterator that returns the ancestors of a given node in document
+ * order. (NOTE! This was changed from the XSLTC code!)
+ */
+ private class AncestorIterator extends DTMAxisIteratorBase
+ {
+
+ /** The current ancestor index. */
+ protected int _index;
+
+ /**
+ * True if this iterator has a reversed axis.
+ *
+ * @return true since this iterator is a reversed axis.
+ */
+ public final boolean isReverse()
+ {
+ return true;
+ }
+
+ /**
+ * Returns the last element in this interation.
+ *
+ * @return the last element in this interation.
+ */
+ public int getLast()
+ {
+ return (_startNode);
+ }
+
+ /**
+ * Returns a deep copy of this iterator.
+ *
+ * @return a deep copy of this iterator.
+ */
+ public DTMAxisIterator cloneIterator()
+ {
+
+ _isRestartable = false; // must set to false for any clone
+
+ try
+ {
+ final AncestorIterator clone = (AncestorIterator) super.clone();
+
+ clone._startNode = _startNode;
+
+ return clone.reset();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new DTMException("Iterator clone not supported.");
+ }
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ if (_includeSelf)
+ _startNode = node;
+ else
+ _startNode = getParent(node);
+
+ _index = getDocument();
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Resets the iterator to the last start node.
+ *
+ * @return A DTMAxisIterator, which may or may not be the same as this
+ * iterator.
+ */
+ public DTMAxisIterator reset()
+ {
+
+ _index = _startNode;
+
+ return resetPosition();
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int next = _index;
+
+ // The alternative to this is to just allocate a stack in setStartNode.
+ // Given often next() is only called once, I'm not sure that would
+ // be optimal. -sb
+ int node = _startNode;
+
+ while (node != END && node != _index)
+ {
+ _index = node;
+ node = getParent(node);
+ }
+
+ return (next);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _index;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _index = _markedNode;
+ }
+ } // end of AncestorIterator
+
+ /**
+ * Typed iterator that returns the ancestors of a given node.
+ */
+ private final class TypedAncestorIterator extends AncestorIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedAncestorIterator
+ *
+ *
+ * @param type The extended type ID being requested.
+ */
+ public TypedAncestorIterator(int type)
+ {
+ _nodeType = type;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node;
+
+ while ((node = super.next()) != NULL)
+ {
+ if (getExpandedTypeID(node) == _nodeType)
+ return returnNode(node);
+ }
+
+ return (NULL);
+ }
+
+ /**
+ * Returns the last element in this interation.
+ *
+ * @return the last element in this interation.
+ */
+ public int getLast()
+ {
+
+ int last = NULL;
+ int curr = _startNode;
+
+ while (curr != NULL)
+ {
+ if (getExpandedTypeID(curr) == _nodeType)
+ last = curr;
+
+ curr = getParent(curr);
+ }
+
+ return (last);
+ }
+ } // end of TypedAncestorIterator
+
+ /**
+ * Iterator that returns the descendants of a given node.
+ */
+ private class DescendantIterator extends DTMAxisIteratorBase
+ {
+
+ /** _node precedes search for next */
+ protected int _node; // Identity, not handle!
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isRestartable)
+ {
+ node = node & m_mask;
+ _startNode = node;
+
+ if (_includeSelf)
+ node--;
+
+ _node = node;
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Tell if this node identity is a descendant. Assumes that
+ * the node info for the element has already been obtained.
+ * @param identity The index number of the node in question.
+ * @return true if the index is a descendant of _startNode.
+ */
+ protected boolean isDescendant(int identity)
+ {
+ return _parent(identity) >= _startNode;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ while (true)
+ {
+ int node = ++_node;
+ int type = _type(node);
+
+ if (NULL == type ||!isDescendant(node))
+ return END;
+
+ if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type)
+ continue;
+
+ return returnNode(node | m_dtmIdent); // make handle.
+ }
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ } // end of DescendantIterator
+
+ /**
+ * Typed iterator that returns the descendants of a given node.
+ */
+ private final class TypedDescendantIterator extends DescendantIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedDescendantIterator
+ *
+ *
+ * @param nodeType Extended type ID being requested.
+ */
+ public TypedDescendantIterator(int nodeType)
+ {
+ _nodeType = nodeType;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ int node;
+
+ while ((node = super.next()) != NULL
+ && getExpandedTypeID(node) != _nodeType){}
+
+ return node;
+ }
+ } // end of TypedDescendantIterator
+
+ /**
+ * Iterator that returns the descendants of a given node.
+ * I'm not exactly clear about this one... -sb
+ */
+ private class NthDescendantIterator extends DescendantIterator
+ {
+
+ /** The current nth position. */
+ int _pos;
+
+ /**
+ * Constructor NthDescendantIterator
+ *
+ *
+ * @param pos The nth position being requested.
+ */
+ public NthDescendantIterator(int pos)
+ {
+ _pos = pos;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ // I'm not exactly clear yet what this is doing... -sb
+ int node;
+
+ while ((node = super.next()) != END)
+ {
+ node = (node & m_mask);
+
+ int parent = _parent(node);
+ int child = _firstch(parent);
+ int pos = 0;
+
+ do
+ {
+ int type = _type(child);
+
+ if (ELEMENT_NODE == type)
+ pos++;
+ }
+ while ((pos < _pos) && (child = _nextsib(child)) != END);
+
+ if (node == child)
+ return node;
+ }
+
+ return (END);
+ }
+ } // end of NthDescendantIterator
+
+ /**
+ * Class SingletonIterator.
+ */
+ private class SingletonIterator extends DTMAxisIteratorBase
+ {
+
+ /** The current node. */
+ private int _node;
+
+ /** (not sure yet what this is. -sb) */
+ private final boolean _isConstant;
+
+ /**
+ * Constructor SingletonIterator
+ *
+ */
+ public SingletonIterator()
+ {
+ this(Integer.MIN_VALUE, false);
+ }
+
+ /**
+ * Constructor SingletonIterator
+ *
+ *
+ * @param node The node handle to return.
+ */
+ public SingletonIterator(int node)
+ {
+ this(node, false);
+ }
+
+ /**
+ * Constructor SingletonIterator
+ *
+ *
+ * @param node the node handle to return.
+ * @param constant (Not sure what this is yet. -sb)
+ */
+ public SingletonIterator(int node, boolean constant)
+ {
+ _node = _startNode = node;
+ _isConstant = constant;
+ }
+
+ /**
+ * Set start to END should 'close' the iterator,
+ * i.e. subsequent call to next() should return END.
+ *
+ * @param node Sets the root of the iteration.
+ *
+ * @return A DTMAxisIterator set to the start of the iteration.
+ */
+ public DTMAxisIterator setStartNode(int node)
+ {
+
+ if (_isConstant)
+ {
+ _node = _startNode;
+
+ return resetPosition();
+ }
+ else if (_isRestartable)
+ {
+ if (_node == Integer.MIN_VALUE)
+ {
+ _node = _startNode = node;
+ }
+
+ return resetPosition();
+ }
+
+ return this;
+ }
+
+ /**
+ * Resets the iterator to the last start node.
+ *
+ * @return A DTMAxisIterator, which may or may not be the same as this
+ * iterator.
+ */
+ public DTMAxisIterator reset()
+ {
+
+ if (_isConstant)
+ {
+ _node = _startNode;
+
+ return resetPosition();
+ }
+ else
+ {
+ final boolean temp = _isRestartable;
+
+ _isRestartable = true;
+
+ setStartNode(_startNode);
+
+ _isRestartable = temp;
+ }
+
+ return this;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ final int result = _node;
+
+ _node = END;
+
+ return returnNode(result);
+ }
+
+ /**
+ * Remembers the current node for the next call to gotoMark().
+ */
+ public void setMark()
+ {
+ _markedNode = _node;
+ }
+
+ /**
+ * Restores the current node remembered by setMark().
+ */
+ public void gotoMark()
+ {
+ _node = _markedNode;
+ }
+ }
+
+ /**
+ * Iterator that returns a given node only if it is of a given type.
+ */
+ private final class TypedSingletonIterator extends SingletonIterator
+ {
+
+ /** The extended type ID that was requested. */
+ private final int _nodeType;
+
+ /**
+ * Constructor TypedSingletonIterator
+ *
+ *
+ * @param nodeType The extended type ID being requested.
+ */
+ public TypedSingletonIterator(int nodeType)
+ {
+ _nodeType = nodeType;
+ }
+
+ /**
+ * Get the next node in the iteration.
+ *
+ * @return The next node handle in the iteration, or END.
+ */
+ public int next()
+ {
+
+ final int result = super.next();
+
+ return getExpandedTypeID(result) == _nodeType ? result : NULL;
+ }
+ } // end of TypedSingletonIterator
}
1.1.2.20 +33 -2
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDocumentImpl.java
Index: DTMDocumentImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDocumentImpl.java,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -r1.1.2.19 -r1.1.2.20
--- DTMDocumentImpl.java 2001/05/18 07:16:37 1.1.2.19
+++ DTMDocumentImpl.java 2001/05/20 17:33:26 1.1.2.20
@@ -1548,7 +1548,7 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(int nodeHandle) {
+ public int getExpandedTypeID(int nodeHandle) {
nodes.readSlot(nodeHandle, gotslot);
String qName = m_localNames.indexToString(gotslot[3]);
// Remove prefix from qName
@@ -1575,7 +1575,7 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(String namespace, String localName, int
type) {
+ public int getExpandedTypeID(String namespace, String localName, int
type) {
// Create expanded name
// %TBD% jjk Expanded name is bitfield-encoded as
// typeID[6]nsuriID[10]localID[16]. Switch to that form, and to
@@ -2313,6 +2313,37 @@
return ;//(m_docHandle | ourslot);
}
+ /**
+ * This is a shortcut to the iterators that implement the
+ * supported XPath axes (only namespace::) is not supported.
+ * Returns a bare-bones iterator that must be initialized
+ * with a start node (using iterator.setStartNode()).
+ *
+ * @param axis One of Axes.ANCESTORORSELF, etc.
+ *
+ * @return A DTMAxisIterator, or null if the givin axis isn't supported.
+ */
+ public DTMAxisIterator getAxisIterator(final int axis)
+ {
+ // %TBD%
+ return null;
+ }
+
+ /**
+ * Get an iterator that can navigate over an XPath Axis, predicated by
+ * the extended type ID.
+ *
+ *
+ * @param axis
+ * @param type An extended type ID.
+ *
+ * @return A DTMAxisIterator, or null if the givin axis isn't supported.
+ */
+ public DTMAxisIterator getTypedAxisIterator(final int axis, final int type)
+ {
+ // %TBD%
+ return null;
+ }
/** Terminate the element currently acting as an insertion point.
Subsequent
1.1.2.6 +31 -9
xml-xalan/java/src/org/apache/xml/dtm/Attic/ExpandedNameTable.java
Index: ExpandedNameTable.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/ExpandedNameTable.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- ExpandedNameTable.java 2001/05/14 05:19:11 1.1.2.5
+++ ExpandedNameTable.java 2001/05/20 17:33:26 1.1.2.6
@@ -119,7 +119,7 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(String namespace, String localName, int type)
+ public int getExpandedTypeID(String namespace, String localName, int type)
{
int nsID = (null != namespace) ?
m_namespaceNames.stringToIndex(namespace) : 0;
int lnID = m_locNamesPool.stringToIndex(localName);
@@ -139,7 +139,7 @@
*
* @return the expanded-name id of the node.
*/
- public int getExpandedNameID(int type)
+ public int getExpandedTypeID(int type)
{
int expandedTypeID = (type << (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME));
@@ -161,6 +161,18 @@
else
return m_locNamesPool.indexToString(localNameID);
}
+
+ /**
+ * Given an expanded-name ID, return the local name ID.
+ *
+ * @param ExpandedNameID an ID that represents an expanded-name.
+ * @return The id of this local name.
+ */
+ public static final int getLocalNameID(int ExpandedNameID)
+ {
+ return (ExpandedNameID & MASK_LOCALNAME);
+ }
+
/**
* Given an expanded-name ID, return the namespace URI part.
@@ -175,17 +187,27 @@
int id = (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
return (0 == id) ? null : m_namespaceNames.indexToString(id);
}
-
+
/**
- * Given an expanded-name ID, return the namespace URI part.
+ * Given an expanded-name ID, return the namespace URI ID.
*
* @param ExpandedNameID an ID that represents an expanded-name.
- * @return String URI value of this node's namespace, or null if no
- * namespace was resolved.
+ * @return The id of this namespace.
*/
- public int getType(int ExpandedNameID)
+ public static final int getNamespaceID(int ExpandedNameID)
{
-
- return ((ExpandedNameID & MASK_NAMESPACE) >>
(BITS_PER_LOCALNAME+BITS_PER_NAMESPACE));
+ return (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
}
+
+ /**
+ * Given an expanded-name ID, return the local name ID.
+ *
+ * @param ExpandedNameID an ID that represents an expanded-name.
+ * @return The id of this local name.
+ */
+ public static final int getType(int ExpandedNameID)
+ {
+ return ExpandedNameID >> (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME);
+ }
+
}
No revision
No revision
1.1.2.1 +155 -0 xml-xalan/java/src/org/apache/xml/dtm/Attic/Axis.java
1.1.2.1 +130 -0
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMAxisIterator.java
1.1.2.1 +219 -0
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMAxisIteratorBase.java
No revision
No revision
1.1.2.17 +56 -78
xml-xalan/java/src/org/apache/xml/dtm/dom2dtm/Attic/DOM2DTM.java
Index: DOM2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/dom2dtm/Attic/DOM2DTM.java,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -u -r1.1.2.16 -r1.1.2.17
--- DOM2DTM.java 2001/05/18 21:01:25 1.1.2.16
+++ DOM2DTM.java 2001/05/20 17:33:27 1.1.2.17
@@ -83,12 +83,6 @@
*/
public class DOM2DTM extends DTMDefaultBase
{
- /**
- * This represents the number of integers per node in the
- * <code>m_info</code> member variable.
- */
- protected static final int NODEINFOBLOCKSIZE = DEFAULTNODEINFOBLOCKSIZE;
-
/** The top of the subtree, may not be the same as m_context if "//foo"
pattern. */
transient private Node m_root;
@@ -173,15 +167,14 @@
{
int nodeIndex = m_nodes.size();
+ ensureSize(nodeIndex);
int type = node.getNodeType();
m_nodes.addElement(node);
-
- int startInfo = nodeIndex * NODEINFOBLOCKSIZE;
-
- m_info.addElements(NODEINFOBLOCKSIZE);
- m_info.setElementAt(level, startInfo + OFFSET_LEVEL);
+
+ // Do casts here so that if we change the sizes, the changes are
localized.
+ m_level[nodeIndex] = (byte)level;
if (Node.ATTRIBUTE_NODE == type)
{
@@ -192,20 +185,18 @@
type = DTM.NAMESPACE_NODE;
}
}
-
- m_info.setElementAt(type, startInfo + OFFSET_TYPE);
- m_info.setElementAt(NOTPROCESSED, startInfo + OFFSET_FIRSTCHILD);
- m_info.setElementAt(NOTPROCESSED, startInfo + OFFSET_NEXTSIBLING);
- m_info.setElementAt(previousSibling, startInfo + OFFSET_PREVSIBLING);
- m_info.setElementAt(parentIndex, startInfo + OFFSET_PARENT);
+
+ m_firstch[nodeIndex] = NOTPROCESSED;
+ m_nextsib[nodeIndex] = NOTPROCESSED;
+ m_prevsib[nodeIndex] = (short)previousSibling;
+ m_parent[nodeIndex] = (short)parentIndex;
- if(DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE && type !=
DTM.NAMESPACE_NODE)
+ if(DTM.NULL != parentIndex &&
+ type != DTM.ATTRIBUTE_NODE &&
+ type != DTM.NAMESPACE_NODE)
{
- int startParentInfo = parentIndex * NODEINFOBLOCKSIZE;
- if(NOTPROCESSED == m_info.elementAt(startParentInfo +
OFFSET_FIRSTCHILD))
- {
- m_info.setElementAt(nodeIndex, startParentInfo + OFFSET_FIRSTCHILD);
- }
+ if(NOTPROCESSED == m_firstch[parentIndex])
+ m_firstch[parentIndex] = (short)nodeIndex;
}
String nsURI = node.getNamespaceURI();
@@ -215,30 +206,18 @@
ExpandedNameTable exnt = m_mgr.getExpandedNameTable(this);
int expandedNameID = (null != localName)
- ? exnt.getExpandedNameID(nsURI, localName, type) :
- exnt.getExpandedNameID(type);
+ ? exnt.getExpandedTypeID(nsURI, localName, type) :
+ exnt.getExpandedTypeID(type);
- m_info.setElementAt(expandedNameID, startInfo + OFFSET_EXPANDEDNAMEID);
+ m_exptype[nodeIndex] = expandedNameID;
if (DTM.NULL != previousSibling)
- {
- m_info.setElementAt(nodeIndex,
- (previousSibling * NODEINFOBLOCKSIZE)
- + OFFSET_NEXTSIBLING);
- }
+ m_nextsib[previousSibling] = nodeIndex;
return nodeIndex;
}
/**
- * Return the number of integers in each node info block.
- */
- protected int getNodeInfoBlockSize()
- {
- return NODEINFOBLOCKSIZE;
- }
-
- /**
* Get the number of nodes that have been added.
*/
protected int getNumberOfNodes()
@@ -280,7 +259,7 @@
int type = pos.getNodeType();
int currentIndexHandle = m_nodes.size()-1;
- int posInfo = currentIndexHandle * NODEINFOBLOCKSIZE;
+ int posInfo = currentIndexHandle;
boolean shouldPushLevel = true;
if (Node.ELEMENT_NODE == type)
@@ -306,7 +285,7 @@
}
else if (Node.ATTRIBUTE_NODE == type)
{
- m_info.setElementAt(DTM.NULL, posInfo + OFFSET_FIRSTCHILD);
+ m_firstch[posInfo] = DTM.NULL;
m_attrsPos++;
if (m_attrsPos < m_attrs.getLength())
@@ -316,10 +295,10 @@
}
else
{
- m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
+ m_nextsib[posInfo] = NULL;
pos = m_elementForAttrs;
currentIndexHandle = m_elementForAttrsIndex;
- posInfo = currentIndexHandle * NODEINFOBLOCKSIZE;
+ posInfo = currentIndexHandle;
nextNode = pos.getFirstChild();
m_levelInfo.quickPop(LEVELINFO_NPERLEVEL);
}
@@ -349,14 +328,14 @@
while (null == nextNode)
{
- if(m_info.elementAt(posInfo + OFFSET_FIRSTCHILD) == NOTPROCESSED)
+ if(m_firstch[posInfo] == NOTPROCESSED)
{
- m_info.setElementAt(DTM.NULL, posInfo + OFFSET_FIRSTCHILD);
+ m_firstch[posInfo] = NULL;
}
if (top.equals(pos))
{
- m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
+ m_nextsib[posInfo] = NULL;
break;
}
@@ -391,16 +370,15 @@
if (null == nextNode)
{
- m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
-
- currentIndexHandle = m_info.elementAt(posInfo + OFFSET_PARENT);
- posInfo = currentIndexHandle * NODEINFOBLOCKSIZE;
+ m_nextsib[posInfo] = NULL;
+ m_parent[posInfo] = (short)currentIndexHandle;
+ posInfo = currentIndexHandle;
m_levelInfo.quickPop(LEVELINFO_NPERLEVEL);
pos = pos.getParentNode();
if ((null == pos) || (top.equals(pos)))
{
- m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
+ m_nextsib[posInfo] = NULL;
nextNode = null;
// break;
m_nodesAreProcessed = true;
@@ -510,10 +488,10 @@
{
int len = m_nodes.size();
for (int i = 0; i < len; i++)
- {
- if (m_nodes.elementAt(i) == node)
- return i | m_dtmIdent;
- }
+ {
+ if (m_nodes.elementAt(i) == node)
+ return i | m_dtmIdent;
+ }
}
return DTM.NULL;
@@ -540,29 +518,29 @@
// This would be easier if m_root was always the Document node, but
// we decided to allow wrapping a DTM around a subtree.
if((m_root==node) ||
- (m_root.getNodeType()==DOCUMENT_NODE &&
- m_root==node.getOwnerDocument()) ||
- (m_root.getNodeType()!=DOCUMENT_NODE &&
- m_root.getOwnerDocument()==node.getOwnerDocument())
- )
- {
- // If node _is_ in m_root's tree, find its handle
- //
- // %OPT% This check may be improved significantly when DOM
- // Level 3 nodeKey and relative-order tests become
- // available!
- for(Node cursor=node;
- cursor!=null;
- cursor=
- (cursor.getNodeType()!=ATTRIBUTE_NODE)
- ? cursor.getParentNode()
- : ((org.w3c.dom.Attr)cursor).getOwnerElement())
- {
- if(cursor==m_root)
- // We know this node; find its handle.
- return getHandleFromNode(node);
- } // for ancestors of node
- } // if node and m_root in same Document
+ (m_root.getNodeType()==DOCUMENT_NODE &&
+ m_root==node.getOwnerDocument()) ||
+ (m_root.getNodeType()!=DOCUMENT_NODE &&
+ m_root.getOwnerDocument()==node.getOwnerDocument())
+ )
+ {
+ // If node _is_ in m_root's tree, find its handle
+ //
+ // %OPT% This check may be improved significantly when DOM
+ // Level 3 nodeKey and relative-order tests become
+ // available!
+ for(Node cursor=node;
+ cursor!=null;
+ cursor=
+ (cursor.getNodeType()!=ATTRIBUTE_NODE)
+ ? cursor.getParentNode()
+ : ((org.w3c.dom.Attr)cursor).getOwnerElement())
+ {
+ if(cursor==m_root)
+ // We know this node; find its handle.
+ return getHandleFromNode(node);
+ } // for ancestors of node
+ } // if node and m_root in same Document
} // if node!=null
return DTM.NULL;
No revision
No revision
1.1.2.15 +137 -140
xml-xalan/java/src/org/apache/xml/dtm/sax2dtm/Attic/SAX2DTM.java
Index: SAX2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/sax2dtm/Attic/SAX2DTM.java,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -u -r1.1.2.14 -r1.1.2.15
--- SAX2DTM.java 2001/05/18 07:16:50 1.1.2.14
+++ SAX2DTM.java 2001/05/20 17:33:27 1.1.2.15
@@ -114,12 +114,6 @@
private int m_appCoroutineID = -1;
/**
- * The number of nodes, which is also used to determine the next
- * node index.
- */
- private int m_size = 0;
-
- /**
* All the character content, including attribute values, are stored in
* this buffer.
* %REVIEW% Should this have an option of being shared?
@@ -136,7 +130,7 @@
transient private IntStack m_parents = new IntStack();
/** The current construction level, needed only for construction time. */
- transient private int m_level = 0;
+ transient private int m_levelAmount = 0;
/** The current previous node, needed only for construction time. */
transient private int m_previous = 0;
@@ -169,24 +163,10 @@
/** End document has been reached. */
private boolean m_endDocumentOccured = false;
- /**
- * This represents the number of integers per node in the
- * <code>m_info</code> member variable.
- */
- protected static final int NODEINFOBLOCKSIZE = DEFAULTNODEINFOBLOCKSIZE +
1;
+ /** Data or qualified name values, one array element for each node. */
+ protected short[] m_dataOrQName;
/**
- * The value at this offset in the m_info table is an index
- * into the data table, or name prefix. Or if the node is an
- * attribute node, if the value is positive, it is a pool index into
- * the m_valuesOrPrefixes pool, or if the value is negative, it should
- * be made positive and used as an index into the m_data list, with the
- * first value at that offset being the qname index, and the next value
- * at the offset being the value index.
- */
- protected static final int OFFSET_DATA_OR_QNAME = DEFAULTNODEINFOBLOCKSIZE;
-
- /**
* This table holds the ID string to node associations, for
* XML IDs.
*/
@@ -249,16 +229,17 @@
super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory);
+ m_dataOrQName = new short[m_initialblocksize];
m_ent = mgr.getExpandedNameTable(this);
if (null == m_ent)
m_ent = new ExpandedNameTable();
int doc = addNode(DTM.DOCUMENT_NODE,
- m_ent.getExpandedNameID(DTM.DOCUMENT_NODE), m_level,
- DTM.NULL, DTM.NULL, 0, true);
+ m_ent.getExpandedTypeID(DTM.DOCUMENT_NODE),
+ m_levelAmount, DTM.NULL, DTM.NULL, 0, true);
- m_level++;
+ m_levelAmount++;
m_parents.push(doc);
@@ -266,6 +247,33 @@
}
/**
+ * Get the data or qualified name for the given node identity.
+ *
+ * @param identity The node identity.
+ *
+ * @return The data or qualified name, or DTM.NULL.
+ */
+ protected int _dataOrQName(int identity)
+ {
+
+ if (identity < m_size)
+ return m_dataOrQName[identity];
+
+ // Check to see if the information requested has been processed, and,
+ // if not, advance the iterator until we the information has been
+ // processed.
+ while (true)
+ {
+ boolean isMore = nextNode();
+
+ if (!isMore)
+ return NULL;
+ else if (identity < m_size)
+ return m_dataOrQName[identity];
+ }
+ }
+
+ /**
* Get the CoRoutine ID for the application.
*
* @return The CoRoutine ID for the application.
@@ -284,10 +292,10 @@
}
/**
- * Ask the CoRoutine parser to doTerminate and clear the reference. If
+ * Ask the CoRoutine parser to doTerminate and clear the reference. If
* the CoRoutine parser has already been cleared, this will have no effect.
*
- * @param callDoTerminate true of doTerminate should be called on the
+ * @param callDoTerminate true of doTerminate should be called on the
* coRoutine parser.
*/
public void clearCoRoutine(boolean callDoTerminate)
@@ -456,7 +464,7 @@
if (isTextType(type))
{
- int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int dataIndex = m_dataOrQName[identity];
int offset = m_data.elementAt(dataIndex);
int length = m_data.elementAt(dataIndex + 1);
@@ -464,24 +472,23 @@
}
else
{
- int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+ int firstChild = _firstch(identity);
if (DTM.NULL != firstChild)
{
int offset = -1;
int length = 0;
- int level = getNodeInfo(identity, OFFSET_LEVEL);
+ int level = _level(identity);
identity = firstChild;
- while (DTM.NULL != identity
- && (getNodeInfo(identity, OFFSET_LEVEL) > level))
+ while (DTM.NULL != identity && (_level(identity) > level))
{
type = getNodeType(identity);
if (isTextType(type))
{
- int dataIndex = getNodeInfoNoWait(identity,
OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
if (-1 == offset)
{
@@ -501,7 +508,7 @@
}
else
{
- int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
if (dataIndex < 0)
{
@@ -528,7 +535,7 @@
public String getNodeName(int nodeHandle)
{
- int expandedTypeID = getExpandedNameID(nodeHandle);
+ int expandedTypeID = getExpandedTypeID(nodeHandle);
int namespaceID = (expandedTypeID & ExpandedNameTable.MASK_NAMESPACE)
>> ExpandedNameTable.BITS_PER_LOCALNAME;
@@ -553,8 +560,7 @@
}
else
{
- int qnameIndex = getNodeInfoNoWait(nodeHandle & m_mask,
- OFFSET_DATA_OR_QNAME);
+ int qnameIndex = m_dataOrQName[nodeHandle & m_mask];
if (qnameIndex < 0)
{
@@ -577,7 +583,7 @@
public String getNodeNameX(int nodeHandle)
{
- int expandedTypeID = getExpandedNameID(nodeHandle);
+ int expandedTypeID = getExpandedTypeID(nodeHandle);
int namespaceID = (expandedTypeID & ExpandedNameTable.MASK_NAMESPACE)
>> ExpandedNameTable.BITS_PER_LOCALNAME;
@@ -592,8 +598,7 @@
}
else
{
- int qnameIndex = getNodeInfoNoWait(nodeHandle & m_mask,
- OFFSET_DATA_OR_QNAME);
+ int qnameIndex = m_dataOrQName[nodeHandle & m_mask];
if (qnameIndex < 0)
{
@@ -697,16 +702,6 @@
}
/**
- * Return the number of integers in each node info block.
- *
- * @return the number of integers in each node info block.
- */
- protected int getNodeInfoBlockSize()
- {
- return NODEINFOBLOCKSIZE;
- }
-
- /**
* Get the number of nodes that have been added.
*
* @return The number of that are currently in the tree.
@@ -780,6 +775,35 @@
}
/**
+ * Ensure that the size of the information arrays can hold another entry
+ * at the given index.
+ *
+ * @param on exit from this function, the information arrays sizes must be
+ * at least index+1.
+ *
+ * NEEDSDOC @param index
+ */
+ protected void ensureSize(int index)
+ {
+
+ int capacity = m_dataOrQName.length;
+
+ if (capacity <= index)
+ {
+ short[] dataOrQName = m_dataOrQName;
+ int newcapacity = capacity + m_blocksize;
+
+ m_dataOrQName = new short[newcapacity];
+
+ System.arraycopy(dataOrQName, 0, m_dataOrQName, 0, capacity);
+ }
+
+ // We have to do this after we do our resize, since DTMDefaultBase
+ // will change m_blocksize before it exits.
+ super.ensureSize(index);
+ }
+
+ /**
* Construct the node map from the node.
*
* @param type raw type ID, one of DTM.XXX_NODE.
@@ -799,43 +823,29 @@
{
int nodeIndex = m_size++;
- int startInfo = nodeIndex * NODEINFOBLOCKSIZE;
-
- m_info.addElements(NODEINFOBLOCKSIZE);
- m_info.setElementAt(level, startInfo + OFFSET_LEVEL);
- m_info.setElementAt(type, startInfo + OFFSET_TYPE);
- m_info.setElementAt((canHaveFirstChild) ? NOTPROCESSED : DTM.NULL,
- startInfo + OFFSET_FIRSTCHILD);
- m_info.setElementAt(NOTPROCESSED, startInfo + OFFSET_NEXTSIBLING);
- m_info.setElementAt(previousSibling, startInfo + OFFSET_PREVSIBLING);
- m_info.setElementAt(parentIndex, startInfo + OFFSET_PARENT);
- m_info.setElementAt(expandedTypeID, startInfo + OFFSET_EXPANDEDNAMEID);
- m_info.setElementAt(dataOrPrefix, startInfo + OFFSET_DATA_OR_QNAME);
- // Text nodes no longer need special handling, because we
- // don't add them until they're complete
- {
- if (DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE
- && type != DTM.NAMESPACE_NODE)
- {
- int startParentInfo = parentIndex * NODEINFOBLOCKSIZE;
+ ensureSize(nodeIndex);
- if (NOTPROCESSED
- == m_info.elementAt(startParentInfo + OFFSET_FIRSTCHILD))
- {
- m_info.setElementAt(nodeIndex, startParentInfo +
OFFSET_FIRSTCHILD);
- }
- }
-
- // Note that we don't want nextSibling to be processed until
- // charactersFlush() is called.
- if (DTM.NULL != previousSibling)
- {
- int startPrevInfo = previousSibling * NODEINFOBLOCKSIZE;
-
- m_info.setElementAt(nodeIndex, startPrevInfo + OFFSET_NEXTSIBLING);
- }
- }
+ // Do the hard casts here, so we localize changes that may have to be
made.
+ m_level[nodeIndex] = (byte) level;
+ m_firstch[nodeIndex] = canHaveFirstChild ? NOTPROCESSED : DTM.NULL;
+ m_nextsib[nodeIndex] = NOTPROCESSED;
+ m_prevsib[nodeIndex] = (short) previousSibling;
+ m_parent[nodeIndex] = (short) parentIndex;
+ m_exptype[nodeIndex] = expandedTypeID;
+ m_dataOrQName[nodeIndex] = (short) dataOrPrefix;
+
+ if (DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE
+ && type != DTM.NAMESPACE_NODE)
+ {
+ if (NOTPROCESSED == m_firstch[parentIndex])
+ m_firstch[parentIndex] = nodeIndex;
+ }
+
+ // Note that we don't want nextSibling to be processed until
+ // charactersFlush() is called.
+ if (DTM.NULL != previousSibling)
+ m_nextsib[previousSibling] = nodeIndex;
return nodeIndex;
}
@@ -857,7 +867,7 @@
if (isTextType(type))
{
- int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
int offset = m_data.elementAt(dataIndex);
int length = m_data.elementAt(dataIndex + 1);
@@ -871,7 +881,7 @@
}
else
{
- int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
if (dataIndex < 0)
{
@@ -894,7 +904,7 @@
public String getLocalName(int nodeHandle)
{
- int expandedTypeID = getExpandedNameID(nodeHandle);
+ int expandedTypeID = getExpandedTypeID(nodeHandle);
String name = m_ent.getLocalName(expandedTypeID);
if (name == null)
@@ -1003,7 +1013,7 @@
if (DTM.ELEMENT_NODE == type)
{
- int prefixIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int prefixIndex = _dataOrQName(identity);
if (0 == prefixIndex)
return "";
@@ -1016,7 +1026,7 @@
}
else if (DTM.ATTRIBUTE_NODE == type)
{
- int prefixIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int prefixIndex = _dataOrQName(identity);
if (prefixIndex < 0)
{
@@ -1096,7 +1106,7 @@
public String getNamespaceURI(int nodeHandle)
{
- int expandedTypeID = getExpandedNameID(nodeHandle);
+ int expandedTypeID = getExpandedTypeID(nodeHandle);
return m_ent.getNamespace(expandedTypeID);
}
@@ -1118,7 +1128,7 @@
if (isTextType(type))
{
- int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
int offset = m_data.elementAt(dataIndex);
int length = m_data.elementAt(dataIndex + 1);
@@ -1126,24 +1136,23 @@
}
else
{
- int firstChild = getNodeInfo(identity, OFFSET_FIRSTCHILD);
+ int firstChild = _firstch(identity);
if (DTM.NULL != firstChild)
{
int offset = -1;
int length = 0;
- int level = getNodeInfo(identity, OFFSET_LEVEL);
+ int level = _level(identity);
identity = firstChild;
- while (DTM.NULL != identity
- && (getNodeInfo(identity, OFFSET_LEVEL) > level))
+ while (DTM.NULL != identity && (_level(identity) > level))
{
type = getNodeType(identity);
if (isTextType(type))
{
- int dataIndex = getNodeInfoNoWait(identity,
OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
if (-1 == offset)
{
@@ -1163,7 +1172,7 @@
}
else
{
- int dataIndex = getNodeInfoNoWait(identity, OFFSET_DATA_OR_QNAME);
+ int dataIndex = _dataOrQName(identity);
if (dataIndex < 0)
{
@@ -1308,10 +1317,10 @@
m_chars.setLength(m_textPendingStart); // Discard accumulated text
else
{
- int exName = m_ent.getExpandedNameID(DTM.TEXT_NODE);
+ int exName = m_ent.getExpandedTypeID(DTM.TEXT_NODE);
int dataIndex = m_data.size();
- m_previous = addNode(m_coalescedTextType, exName, m_level,
+ m_previous = addNode(m_coalescedTextType, exName, m_levelAmount,
m_parents.peek(), m_previous, dataIndex, false);
m_data.addElement(m_textPendingStart);
@@ -1487,22 +1496,20 @@
{
charactersFlush();
- m_info.setElementAt(DTM.NULL, OFFSET_NEXTSIBLING);
- int lastNode = m_previous;
+ m_nextsib[0] = NULL;
- if (DTM.NULL != m_previous)
- {
- int startInfo = lastNode * NODEINFOBLOCKSIZE;
+ if (m_firstch[0] == NOTPROCESSED)
+ m_firstch[0] = NULL;
- m_info.setElementAt(DTM.NULL, startInfo + OFFSET_NEXTSIBLING);
- }
+ if (DTM.NULL != m_previous)
+ m_nextsib[m_previous] = DTM.NULL;
m_parents = null;
m_prefixMappings = null;
m_contextIndexes = null;
- m_level--;
+ m_levelAmount--;
m_endDocumentOccured = true;
}
@@ -1621,14 +1628,14 @@
charactersFlush();
- int exName = m_ent.getExpandedNameID(uri, localName, DTM.ELEMENT_NODE);
+ int exName = m_ent.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE);
String prefix = getPrefix(qName, uri);
int prefixIndex = (null != prefix)
? m_valuesOrPrefixes.stringToIndex(qName) : 0;
- int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_level,
+ int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_levelAmount,
m_parents.peek(), m_previous, prefixIndex, true);
- m_level++;
+ m_levelAmount++;
m_parents.push(elemNode);
@@ -1645,12 +1652,12 @@
String declURL = (String) m_prefixMappings.elementAt(i + 1);
- exName = m_ent.getExpandedNameID(null, prefix, DTM.NAMESPACE_NODE);
+ exName = m_ent.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
int val = m_valuesOrPrefixes.stringToIndex(declURL);
- prev = addNode(DTM.NAMESPACE_NODE, exName, m_level, elemNode, prev,
- val, false);
+ prev = addNode(DTM.NAMESPACE_NODE, exName, m_levelAmount, elemNode,
+ prev, val, false);
}
int n = attributes.getLength();
@@ -1697,16 +1704,13 @@
val = -dataIndex;
}
- exName = m_ent.getExpandedNameID(attrUri, attrLocalName, nodeType);
- prev = addNode(nodeType, exName, m_level, elemNode, prev, val, false);
+ exName = m_ent.getExpandedTypeID(attrUri, attrLocalName, nodeType);
+ prev = addNode(nodeType, exName, m_levelAmount, elemNode, prev, val,
+ false);
}
if (DTM.NULL != prev)
- {
- int startInfo = prev * NODEINFOBLOCKSIZE;
-
- m_info.setElementAt(DTM.NULL, startInfo + OFFSET_NEXTSIBLING);
- }
+ m_nextsib[prev] = DTM.NULL;
if (null != m_wsfilter)
{
@@ -1760,25 +1764,17 @@
m_prefixMappings.setSize(m_contextIndexes.pop());
m_contextIndexes.push(m_prefixMappings.size()); // for the next element.
- m_level--;
+ m_levelAmount--;
int lastNode = m_previous;
m_previous = m_parents.pop();
- int startInfo = m_previous * NODEINFOBLOCKSIZE;
-
- if (m_info.elementAt(startInfo + OFFSET_FIRSTCHILD) == NOTPROCESSED)
- {
- m_info.setElementAt(DTM.NULL, startInfo + OFFSET_FIRSTCHILD);
- }
+ if (NOTPROCESSED == m_firstch[m_previous])
+ m_firstch[m_previous] = DTM.NULL;
else if (DTM.NULL != lastNode)
- {
- startInfo = lastNode * NODEINFOBLOCKSIZE;
+ m_nextsib[lastNode] = DTM.NULL;
- m_info.setElementAt(DTM.NULL, startInfo + OFFSET_NEXTSIBLING);
- }
-
popShouldStripWhitespace();
}
@@ -1863,12 +1859,13 @@
charactersFlush();
- int exName = m_ent.getExpandedNameID(null, target,
+ int exName = m_ent.getExpandedTypeID(null, target,
DTM.PROCESSING_INSTRUCTION_NODE);
int dataIndex = m_valuesOrPrefixes.stringToIndex(data);
- m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName, m_level,
- m_parents.peek(), m_previous, dataIndex, false);
+ m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName,
+ m_levelAmount, m_parents.peek(), m_previous,
+ dataIndex, false);
}
/**
@@ -2177,14 +2174,14 @@
charactersFlush();
- int exName = m_ent.getExpandedNameID(DTM.COMMENT_NODE);
+ int exName = m_ent.getExpandedTypeID(DTM.COMMENT_NODE);
// For now, treat comments as strings... I guess we should do a
// seperate FSB buffer instead.
int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start,
length));
- m_previous = addNode(DTM.COMMENT_NODE, exName, m_level, m_parents.peek(),
- m_previous, dataIndex, false);
+ m_previous = addNode(DTM.COMMENT_NODE, exName, m_levelAmount,
+ m_parents.peek(), m_previous, dataIndex, false);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]