deferreddocumentimpl.java
来自「JAVA 所有包」· Java 代码 · 共 1,830 行 · 第 1/5 页
JAVA
1,830 行
setChunkValue(fNodeName, elementName, elementChunk, elementIndex); setChunkValue(fNodeURI, elementURI, elementChunk, elementIndex); setChunkValue(fNodeValue, type, elementChunk, elementIndex); // return node index return elementNodeIndex; } // createDeferredElement(String,String):int /** @deprecated. Creates an element node in the table. */ public int createDeferredElement(String elementName) { return createDeferredElement(null, elementName); } /** @deprecated. Creates an element node with a URI in the table. */ public int createDeferredElement(String elementURI, String elementName) { // create node int elementNodeIndex = createNode(Node.ELEMENT_NODE); int elementChunk = elementNodeIndex >> CHUNK_SHIFT; int elementIndex = elementNodeIndex & CHUNK_MASK; setChunkValue(fNodeName, elementName, elementChunk, elementIndex); setChunkValue(fNodeURI, elementURI, elementChunk, elementIndex); // return node index return elementNodeIndex; } // createDeferredElement(String,String):int /** * This method is used by the DOMParser to create attributes. * @param elementNodeIndex * @param attrName * @param attrURI * @param attrValue * @param specified * @param id * @param type * @return int */ public int setDeferredAttribute(int elementNodeIndex, String attrName, String attrURI, String attrValue, boolean specified, boolean id, Object type) { // 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) { int lastAttrChunk = lastAttrNodeIndex >> CHUNK_SHIFT; int lastAttrIndex = lastAttrNodeIndex & CHUNK_MASK; // 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); int extra = getChunkIndex(fNodeExtra, attrChunk, attrIndex); if (id) { extra = extra | ID; setChunkIndex(fNodeExtra, extra, attrChunk, attrIndex); String value = getChunkValue(fNodeValue, attrChunk, attrIndex); putIdentifier(value, elementNodeIndex); } // store type information if (type != null) { int extraDataIndex = createNode(DeferredNode.TYPE_NODE); int echunk = extraDataIndex >> CHUNK_SHIFT; int eindex = extraDataIndex & CHUNK_MASK; setChunkIndex(fNodeLastChild, extraDataIndex, attrChunk, attrIndex); setChunkValue(fNodeValue, type, echunk, eindex); } // return node index return attrNodeIndex; } /** @deprecated. Sets an attribute on an element node.*/ 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 /** Creates an attribute in the table. */ public int createDeferredAttribute(String attrName, String attrValue, boolean specified) { return createDeferredAttribute(attrName, null, attrValue, specified); } /** Creates an attribute with a URI in the table. */ public int createDeferredAttribute(String attrName, String attrURI, String attrValue, boolean specified) { // create node int nodeIndex = createNode(NodeImpl.ATTRIBUTE_NODE); int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; setChunkValue(fNodeName, attrName, chunk, index); setChunkValue(fNodeURI, attrURI, chunk, index); setChunkValue(fNodeValue, attrValue, chunk, index); int extra = specified ? SPECIFIED : 0; setChunkIndex(fNodeExtra, extra, chunk, index); // return node index return nodeIndex; } // createDeferredAttribute(String,String,String,boolean):int /** Creates an element definition in the table.*/ public int createDeferredElementDefinition(String elementName) { // create node int nodeIndex = createNode(NodeImpl.ELEMENT_DEFINITION_NODE); int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; setChunkValue(fNodeName, elementName, chunk, index); // return node index return nodeIndex; } // createDeferredElementDefinition(String):int /** Creates a text node in the table. */ public int createDeferredTextNode(String data, boolean ignorableWhitespace) { // create node int nodeIndex = createNode(Node.TEXT_NODE); int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; setChunkValue(fNodeValue, data, chunk, index); // use extra to store ignorableWhitespace info setChunkIndex(fNodeExtra, ignorableWhitespace ? 1 : 0, chunk, index); // return node index return nodeIndex; } // createDeferredTextNode(String,boolean):int /** Creates a CDATA section node in the table. */ public int createDeferredCDATASection(String data) { // create node int nodeIndex = createNode(Node.CDATA_SECTION_NODE); int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; setChunkValue(fNodeValue, data, chunk, index); // return node index return nodeIndex; } // createDeferredCDATASection(String):int /** Creates a processing instruction node in the table. */ public int createDeferredProcessingInstruction(String target, String data) { // create node int nodeIndex = createNode(Node.PROCESSING_INSTRUCTION_NODE); int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; setChunkValue(fNodeName, target, chunk, index); setChunkValue(fNodeValue, data, chunk, index); // return node index return nodeIndex; } // createDeferredProcessingInstruction(String,String):int /** Creates a comment node in the table. */ public int createDeferredComment(String data) { // create node int nodeIndex = createNode(Node.COMMENT_NODE); int chunk = nodeIndex >> CHUNK_SHIFT; int index = nodeIndex & CHUNK_MASK; setChunkValue(fNodeValue, data, chunk, index); // return node index return nodeIndex; } // createDeferredComment(String):int /** Creates a clone of the specified node. */ public int cloneNode(int nodeIndex, boolean deep) { // clone immediate node int nchunk = nodeIndex >> CHUNK_SHIFT; int nindex = nodeIndex & CHUNK_MASK; int nodeType = fNodeType[nchunk][nindex]; int cloneIndex = createNode((short)nodeType); int cchunk = cloneIndex >> CHUNK_SHIFT; int cindex = cloneIndex & CHUNK_MASK; setChunkValue(fNodeName, fNodeName[nchunk][nindex], cchunk, cindex); setChunkValue(fNodeValue, fNodeValue[nchunk][nindex], cchunk, cindex); setChunkValue(fNodeURI, fNodeURI[nchunk][nindex], cchunk, cindex); int extraIndex = fNodeExtra[nchunk][nindex]; if (extraIndex != -1) { if (nodeType != Node.ATTRIBUTE_NODE && nodeType != Node.TEXT_NODE) { extraIndex = cloneNode(extraIndex, false); } setChunkIndex(fNodeExtra, extraIndex, cchunk, cindex); } // clone and attach children if (deep) { int prevIndex = -1; int childIndex = getLastChild(nodeIndex, false); while (childIndex != -1) { int clonedChildIndex = cloneNode(childIndex, deep); insertBefore(cloneIndex, clonedChildIndex, prevIndex); prevIndex = clonedChildIndex; childIndex = getRealPrevSibling(childIndex, false); } } // return cloned node index return cloneIndex; } // cloneNode(int,boolean):int /** 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) /** Adds an attribute node to the specified element. */ public int setAttributeNode(int elemIndex, int attrIndex) { int echunk = elemIndex >> CHUNK_SHIFT; int eindex = elemIndex & CHUNK_MASK; int achunk = attrIndex >> CHUNK_SHIFT; int aindex = attrIndex & CHUNK_MASK; // see if this attribute is already here String attrName = getChunkValue(fNodeName, achunk, aindex); int oldAttrIndex = getChunkIndex(fNodeExtra, echunk, eindex); int nextIndex = -1; int oachunk = -1; int oaindex = -1; while (oldAttrIndex != -1) { oachunk = oldAttrIndex >> CHUNK_SHIFT; oaindex = oldAttrIndex & CHUNK_MASK; String oldAttrName = getChunkValue(fNodeName, oachunk, oaindex); if (oldAttrName.equals(attrName)) { break; } nextIndex = oldAttrIndex; oldAttrIndex = getChunkIndex(fNodePrevSib, oachunk, oaindex); } // remove old attribute if (oldAttrIndex != -1) { // patch links int prevIndex = getChunkIndex(fNodePrevSib, oachunk, oaindex); if (nextIndex == -1) { setChunkIndex(fNodeExtra, prevIndex, echunk, eindex); } else { int pchunk = nextIndex >> CHUNK_SHIFT; int pindex = nextIndex & CHUNK_MASK; setChunkIndex(fNodePrevSib, prevIndex, pchunk, pindex); } // remove connections to siblings clearChunkIndex(fNodeType, oachunk, oaindex); clearChunkValue(fNodeName, oachunk, oaindex); clearChunkValue(fNodeValue, oachunk, oaindex); clearChunkIndex(fNodeParent, oachunk, oaindex); clearChunkIndex(fNodePrevSib, oachunk, oaindex); int attrTextIndex = clearChunkIndex(fNodeLastChild, oachunk, oaindex); int atchunk = attrTextIndex >> CHUNK_SHIFT; int atindex = attrTextIndex & CHUNK_MASK; clearChunkIndex(fNodeType, atchunk, atindex); clearChunkValue(fNodeValue, atchunk, atindex); clearChunkIndex(fNodeParent, atchunk, atindex); clearChunkIndex(fNodeLastChild, atchunk, atindex); } // add new attribute int prevIndex = getChunkIndex(fNodeExtra, echunk, eindex); setChunkIndex(fNodeExtra, attrIndex, echunk, eindex); setChunkIndex(fNodePrevSib, prevIndex, achunk, aindex); // return return oldAttrIndex; } // setAttributeNode(int,int):int /** 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); } /** Sets type of attribute */ public void setIdAttribute(int attrIndex) { int chunk = attrIndex >> CHUNK_SHIFT; int index = attrIndex & CHUNK_MASK;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?