/** * Given a node handle, advance to its next sibling. * If not yet resolved, waits for more nodes to be added to the document and * tries again. * @param nodeHandle int Handle of the node. * @return int Node-number of next sibling, * or DTM.NULL to indicate none exists. */ public int getTypedNextSibling(int nodeHandle, int nodeType) { if (nodeHandle == DTM.NULL) return DTM.NULL; int node = makeNodeIdentity(nodeHandle); int eType; while ((node = _nextsib(node)) != DTM.NULL && ((eType = _exptype(node)) != nodeType && m_expandedNameTable.getType(eType)!= nodeType)); //_type(node) != nodeType)); return (node == DTM.NULL ? DTM.NULL : makeNodeHandle(node)); }
return makeNodeHandle(_prevsib(makeNodeIdentity(nodeHandle))); else int nodeID = makeNodeIdentity(nodeHandle); int parent = _parent(nodeID); int node = _firstch(parent); int result = DTM.NULL; while (node != nodeID) node = _nextsib(node); return makeNodeHandle(result);
/** * Get the depth level of this node in the tree (equals 1 for * a parentless node). * * @param nodeHandle The node id. * @return the number of ancestors, plus one * @xsl.usage internal */ public short getLevel(int nodeHandle) { // Apparently, the axis walker stuff requires levels to count from 1. int identity = makeNodeIdentity(nodeHandle); return (short) (_level(identity) + 1); }
/** * Given a node handle, advance to its next sibling. * If not yet resolved, waits for more nodes to be added to the document and * tries again. * @param nodeHandle int Handle of the node. * @return int Node-number of next sibling, * or DTM.NULL to indicate none exists. */ public int getNextSibling(int nodeHandle) { if (nodeHandle == DTM.NULL) return DTM.NULL; return makeNodeHandle(_nextsib(makeNodeIdentity(nodeHandle))); }
/** * Given a node handle, get the handle of the node's first child. * If not yet resolved, waits for more nodes to be added to the document and * tries again. * * @param nodeHandle int Handle of the node. * @return int DTM node-number of first child, or DTM.NULL to indicate none exists. */ public int getFirstChild(int nodeHandle) { int identity = makeNodeIdentity(nodeHandle); int firstChild = _firstch(identity); return makeNodeHandle(firstChild); }
while (nextNode()){} int i=makeNodeHandle(index); ps.println("=========== index=" + index + " handle=" + i + " ==========="); ps.println("NodeName: " + getNodeName(i)); ps.println("NodeNameX: " + getNodeNameX(i)); ps.println("LocalName: " + getLocalName(i)); ps.println("NamespaceURI: " + getNamespaceURI(i)); ps.println("Prefix: " + getPrefix(i)); int exTypeID = _exptype(index); int type = _type(index); String typestring; int firstChild = _firstch(index); int prevSibling = _prevsib(index); int nextSibling = _nextsib(index); int parent = _parent(index); int level = _level(index); ps.println("Node Value: " + getNodeValue(i)); ps.println("String Value: " + getStringValue(i));
int identity = makeNodeIdentity(nodeHandle); if (_type(identity) == DTM.ELEMENT_NODE) SuballocatedIntVector nsContext=findNamespaceContext(identity); if(nsContext==null || nsContext.size()<1) return NULL; int identity = makeNodeIdentity(nodeHandle); if (_type(identity) == DTM.ELEMENT_NODE) while (DTM.NULL != (identity = getNextNodeIdentity(identity))) int type = _type(identity); if (type == DTM.NAMESPACE_NODE) return makeNodeHandle(identity); else if (DTM.ATTRIBUTE_NODE != type) break;
int wouldBeAt=findInSortedSuballocatedIntVector(m_namespaceDeclSetElements, elementNodeIndex); if(wouldBeAt>=0) // Found it int ancestor=_parent(elementNodeIndex); int rootHandle = getDocumentRoot(makeNodeHandle(elementNodeIndex)); int rootID = makeNodeIdentity(rootHandle); int uppermostNSCandidateID; if (getNodeType(rootHandle) == DTM.DOCUMENT_NODE) { int ch = _firstch(rootID); uppermostNSCandidateID = (ch != DTM.NULL) ? ch : rootID; } else { ancestor=_parent(ancestor); } while (candidate < ancestor); } else if(wouldBeAt > 0){
/** * Given a node handle and an expanded type ID, get the index of the node's * attribute of that type, if any. * * @param nodeHandle int Handle of the node. * @param attType int expanded type ID of the required attribute. * @return Handle of attribute of the required type, or DTM.NULL to indicate * none exists. */ protected int getTypedAttribute(int nodeHandle, int attType) { int type = getNodeType(nodeHandle); if (DTM.ELEMENT_NODE == type) { int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { type = _type(identity); if (type == DTM.ATTRIBUTE_NODE) { if (_exptype(identity) == attType) return makeNodeHandle(identity); } else if (DTM.NAMESPACE_NODE != type) { break; } } } return DTM.NULL; }
findNamespaceContext(_parent(elementNodeIndex)); int newEType=_exptype(namespaceNodeIndex); if(newEType==getExpandedTypeID(nsList.elementAt(i))) nsList.setElementAt(makeNodeHandle(namespaceNodeIndex),i); return; nsList.addElement(makeNodeHandle(namespaceNodeIndex));
/** * Given a node handle, advance to the next attribute. * If an attr, we advance to * the next attr on the same node. If not an attribute, we return NULL. * * @param nodeHandle int Handle of the node. * @return int DTM node-number of the resolved attr, * or DTM.NULL to indicate none exists. */ public int getNextAttribute(int nodeHandle) { int nodeID = makeNodeIdentity(nodeHandle); if (_type(nodeID) == DTM.ATTRIBUTE_NODE) { return makeNodeHandle(getNextAttributeIdentity(nodeID)); } return DTM.NULL; }
/** * Given a node handle, return an ID that represents the node's expanded name. * * @param nodeHandle The handle to the node in question. * * @return the expanded-name id of the node. */ public int getExpandedTypeID(int nodeHandle) { // %REVIEW% This _should_ only be null if someone asked the wrong DTM about the node... // which one would hope would never happen... int id=makeNodeIdentity(nodeHandle); if(id==NULL) return NULL; return _exptype(id); }
/** * Given a node handle, find its parent node. * * @param nodeHandle the id of the node. * @return int Node-number of parent, * or DTM.NULL to indicate none exists. */ public int getParent(int nodeHandle) { int identity = makeNodeIdentity(nodeHandle); if (identity > 0) return makeNodeHandle(_parent(identity)); else return DTM.NULL; }
/** * Given a node identity for an attribute, advance to the next attribute. * * @param identity int identity of the attribute node. This * <strong>must</strong> be an attribute node. * * @return int DTM node-identity of the resolved attr, * or DTM.NULL to indicate none exists. * */ protected int getNextAttributeIdentity(int identity) { // Assume that attributes and namespace nodes immediately follow the element while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.ATTRIBUTE_NODE) { return identity; } else if (type != DTM.NAMESPACE_NODE) { break; } } return DTM.NULL; }
/** * Append a text node child that will be constructed from a string, * to the end of the document. * * <p>%REVIEW% "End of the document" needs to be defined more clearly. * Does it become the last child of the Document? Of the root element?</p> * * @param str Non-null reverence to a string. */ public void appendTextChild(String str) { error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendTextChild not yet supported!"); }
/** * Add a node to the element indexes. The node will not be added unless * it's an element. * * @param expandedTypeID The expanded type ID of the node. * @param identity The node identity index. */ protected void indexNode(int expandedTypeID, int identity) { ExpandedNameTable ent = m_expandedNameTable; short type = ent.getType(expandedTypeID); if (DTM.ELEMENT_NODE == type) { int namespaceID = ent.getNamespaceID(expandedTypeID); int localNameID = ent.getLocalNameID(expandedTypeID); ensureSizeOfIndex(namespaceID, localNameID); int[] index = m_elemIndexes[namespaceID][localNameID]; index[index[0]] = identity; index[0]++; } }
int pos = findGTE(elems, 1, elems[0], firstPotential);
/** * Given a node handle, test if it has child nodes. * <p> %REVIEW% This is obviously useful at the DOM layer, where it * would permit testing this without having to create a proxy * node. It's less useful in the DTM API, where * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and * almost as self-evident. But it's a convenience, and eases porting * of DOM code to DTM. </p> * * @param nodeHandle int Handle of the node. * @return int true if the given node has child nodes. */ public boolean hasChildNodes(int nodeHandle) { int identity = makeNodeIdentity(nodeHandle); int firstChild = _firstch(identity); return firstChild != DTM.NULL; }
/** * 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) { while (identity>=m_size) { boolean isMore = nextNode(); if (!isMore && identity >= m_size) return NULL; } int i=0; while(NULL != (identity=_parent(identity))) ++i; return i; }
/** * Get the simple type ID for the given node identity. * * @param identity The node identity. * * @return The simple type ID, or DTM.NULL. */ protected short _type(int identity) { int info = _exptype(identity); if (NULL != info) return m_expandedNameTable.getType(info); else return NULL; }