/** * Returns the prev sibling of the given node. * @param free True to free sibling index. */ public int getPrevSibling(int nodeIndex, boolean free) { if (nodeIndex == -1) { return -1; } int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; int type = getChunkIndex(fNodeType, chunk, index); if (type == Node.TEXT_NODE) { do { nodeIndex = getChunkIndex(fNodePrevSib, chunk, index); if (nodeIndex == -1) { break; } chunk = nodeIndex >> CHUNK_SHIFT; index = nodeIndex & CHUNK_MASK; type = getChunkIndex(fNodeType, chunk, index); } while (type == Node.TEXT_NODE); } else { nodeIndex = getChunkIndex(fNodePrevSib, chunk, index); } return nodeIndex; } // getPrevSibling(int,boolean):int
int nchunk = 0; int nindex = 0; for (int index = getChunkIndex(fNodeLastChild, nchunk, nindex); index != -1; index = getChunkIndex(fNodePrevSib, nchunk, nindex)) { if (getChunkIndex(fNodeType, nchunk, nindex) == Node.DOCUMENT_TYPE_NODE) { docTypeIndex = index; break; for (int index = getChunkIndex(fNodeLastChild, nchunk, nindex); index != -1; index = getChunkIndex(fNodePrevSib, nchunk, nindex)) { if (getChunkIndex(fNodeType, nchunk, nindex) == NodeImpl.ELEMENT_DEFINITION_NODE && getChunkValue(fNodeName, nchunk, nindex) == elementName) {
/** Sets type of attribute */ public void setIdAttribute(int attrIndex) { int chunk = attrIndex >> CHUNK_SHIFT; int index = attrIndex & CHUNK_MASK; int extra = getChunkIndex(fNodeExtra, chunk, index); extra = extra | ID; setChunkIndex(fNodeExtra, extra, chunk, index); }
/** * Returns the parent node of the given node. * @param free True to free parent node. */ public int getParentNode(int nodeIndex, boolean free) { if (nodeIndex == -1) { return -1; } int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; return free ? clearChunkIndex(fNodeParent, chunk, index) : getChunkIndex(fNodeParent, chunk, index); } // getParentNode(int):int
/** * Returns the <i>real</i> prev sibling of the given node. * @param free True to free sibling index. */ public int getRealPrevSibling(int nodeIndex, boolean free) { if (nodeIndex == -1) { return -1; } int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; return free ? clearChunkIndex(fNodePrevSib, chunk, index) : getChunkIndex(fNodePrevSib, chunk, index); } // getReadPrevSibling(int,boolean):int
/** * Returns the type of the given node. * @param free True to free type index. */ public short getNodeType(int nodeIndex, boolean free) { if (nodeIndex == -1) { return -1; } int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; return free ? (short)clearChunkIndex(fNodeType, chunk, index) : (short)getChunkIndex(fNodeType, chunk, index); } // getNodeType(int):int
/** * Returns the last child of the given node. * @param free True to free child index. */ public int getLastChild(int nodeIndex, boolean free) { if (nodeIndex == -1) { return -1; } int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; return free ? clearChunkIndex(fNodeLastChild, chunk, index) : getChunkIndex(fNodeLastChild, chunk, index); } // getLastChild(int,boolean):int
/** * Returns the extra info of the given node. * @param free True to free the value index. */ public int getNodeExtra(int nodeIndex, boolean free) { if (nodeIndex == -1) { return -1; } int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; return free ? clearChunkIndex(fNodeExtra, chunk, index) : getChunkIndex(fNodeExtra, chunk, index); } // getNodeExtra(int,boolean):int
/** Returns the attribute value of the given name. */ public String getAttribute(int elemIndex, String name) { if (elemIndex == -1 || name == null) { return null; } int echunk = elemIndex >> CHUNK_SHIFT; int eindex = elemIndex & CHUNK_MASK; int attrIndex = getChunkIndex(fNodeExtra, echunk, eindex); while (attrIndex != -1) { int achunk = attrIndex >> CHUNK_SHIFT; int aindex = attrIndex & CHUNK_MASK; if (getChunkValue(fNodeName, achunk, aindex) == name) { return getChunkValue(fNodeValue, achunk, aindex); } attrIndex = getChunkIndex(fNodePrevSib, achunk, aindex); } return null; }
/** Adds an attribute node to the specified element. */ public void setIdAttributeNode(int elemIndex, int attrIndex) { int chunk = attrIndex >> CHUNK_SHIFT; int index = attrIndex & CHUNK_MASK; int extra = getChunkIndex(fNodeExtra, chunk, index); extra = extra | ID; setChunkIndex(fNodeExtra, extra, chunk, index); String value = getChunkValue(fNodeValue, chunk, index); putIdentifier(value, elemIndex); }
/** Appends a child to the specified parent in the table. */ public void appendChild(int parentIndex, int childIndex) { // append parent index int pchunk = parentIndex >> CHUNK_SHIFT; int pindex = parentIndex & CHUNK_MASK; int cchunk = childIndex >> CHUNK_SHIFT; int cindex = childIndex & CHUNK_MASK; setChunkIndex(fNodeParent, parentIndex, cchunk, cindex); // set previous sibling of new child int olast = getChunkIndex(fNodeLastChild, pchunk, pindex); setChunkIndex(fNodePrevSib, olast, cchunk, cindex); // update parent's last child setChunkIndex(fNodeLastChild, childIndex, pchunk, pindex); } // appendChild(int,int)
int type = getChunkIndex(fNodeType, chunk, index); if (type == Node.TEXT_NODE) { int prevSib = getRealPrevSibling(nodeIndex); value = getChunkValue(fNodeValue, chunk, index); fStrChunks.add(value); prevSib = getChunkIndex(fNodePrevSib, chunk, index); if (prevSib == -1) { break; value = getChunkValue(fNodeValue, chunk, index); fStrChunks.add(value); child = getChunkIndex(fNodePrevSib, chunk, index);
/** Inserts a child before the specified node in the table. */ public int insertBefore(int parentIndex, int newChildIndex, int refChildIndex) { if (refChildIndex == -1) { appendChild(parentIndex, newChildIndex); return newChildIndex; } int nchunk = newChildIndex >> CHUNK_SHIFT; int nindex = newChildIndex & CHUNK_MASK; int rchunk = refChildIndex >> CHUNK_SHIFT; int rindex = refChildIndex & CHUNK_MASK; int previousIndex = getChunkIndex(fNodePrevSib, rchunk, rindex); setChunkIndex(fNodePrevSib, newChildIndex, rchunk, rindex); setChunkIndex(fNodePrevSib, previousIndex, nchunk, nindex); return newChildIndex; } // insertBefore(int,int,int):int
/** * Sets an attribute on an element node. * @deprecated */ public int setDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified) { // create attribute int attrNodeIndex = createDeferredAttribute(attrName, attrURI, attrValue, specified); int attrChunk = attrNodeIndex >> CHUNK_SHIFT; int attrIndex = attrNodeIndex & CHUNK_MASK; // set attribute's parent to element setChunkIndex(fNodeParent, elementNodeIndex, attrChunk, attrIndex); int elementChunk = elementNodeIndex >> CHUNK_SHIFT; int elementIndex = elementNodeIndex & CHUNK_MASK; // get element's last attribute int lastAttrNodeIndex = getChunkIndex(fNodeExtra, elementChunk, elementIndex); if (lastAttrNodeIndex != 0) { // add link from new attribute to last attribute setChunkIndex(fNodePrevSib, lastAttrNodeIndex, attrChunk, attrIndex); } // add link from element to new last attribute setChunkIndex(fNodeExtra, attrNodeIndex, elementChunk, elementIndex); // return node index return attrNodeIndex; } // setDeferredAttribute(int,String,String,String,boolean):int
int oldAttrIndex = getChunkIndex(fNodeExtra, echunk, eindex); int nextIndex = -1; int oachunk = -1; oldAttrIndex = getChunkIndex(fNodePrevSib, oachunk, oaindex); int prevIndex = getChunkIndex(fNodePrevSib, oachunk, oaindex); if (nextIndex == -1) { setChunkIndex(fNodeExtra, prevIndex, echunk, eindex); int prevIndex = getChunkIndex(fNodeExtra, echunk, eindex); setChunkIndex(fNodeExtra, attrIndex, echunk, eindex); setChunkIndex(fNodePrevSib, prevIndex, achunk, aindex);
int pchunk = index >> CHUNK_SHIFT; int pindex = index & CHUNK_MASK; index = getChunkIndex(fNodeParent, pchunk, pindex); } while (index != -1);
int lastAttrNodeIndex = getChunkIndex(fNodeExtra, elementChunk, elementIndex); if (lastAttrNodeIndex != 0) { int extra = getChunkIndex(fNodeExtra, attrChunk, attrIndex); if (id) { extra = extra | ID;
int type = getChunkIndex(fNodeType, chunk, index); if (type != Node.TEXT_NODE && type != Node.CDATA_SECTION_NODE) { clearChunkIndex(fNodeType, chunk, index);