/** Synchronizes the data (name and value) for fast nodes. */ protected void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; name = ownerDocument.getNodeName(fNodeIndex); // public and system ids publicID = ownerDocument.getNodeValue(fNodeIndex); systemID = ownerDocument.getNodeURI(fNodeIndex); int extraDataIndex = ownerDocument.getNodeExtra(fNodeIndex); internalSubset = ownerDocument.getNodeValue(extraDataIndex); } // synchronizeData()
/** Returns the type of the given node. */ public short getNodeType(int nodeIndex) { return getNodeType(nodeIndex, true); }
/** * Returns the prev sibling of the given node. * This is post-normalization of Text Nodes. */ public int getPrevSibling(int nodeIndex) { return getPrevSibling(nodeIndex, true); }
public void setEntityInfo(int currentEntityDecl, String version, String encoding){ int eNodeIndex = getNodeExtra(currentEntityDecl, false); if (eNodeIndex !=-1) { int echunk = eNodeIndex >> CHUNK_SHIFT; int eindex = eNodeIndex & CHUNK_MASK; setChunkValue(fNodeValue, version, echunk, eindex); setChunkValue(fNodeURI, encoding, echunk, eindex); } }
public String getDeferredEntityBaseURI (int entityIndex){ if (entityIndex != -1) { int extraDataIndex = getNodeExtra(entityIndex, false); extraDataIndex = getNodeExtra(extraDataIndex, false); return getNodeName (extraDataIndex, false); } return null; }
/** * 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
int node = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (node != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (node, false); if (nodeType == Node.ENTITY_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (node, false); if (nodeName.equals (name)) { found = true; node = fDeferredDocumentImpl.getRealPrevSibling (node, false); fDeferredDocumentImpl.createDeferredEntity (name, null, null, null, (String)fBaseURIStack.peek ()); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, entityIndex);
boolean orig = getMutationEvents(); setMutationEvents(false); for (int index = getLastChild(nodeIndex); index != -1; index = getPrevSibling(index)) { ChildNode node = (ChildNode) getNodeObject(index); if (lastNode == null) { lastNode = node; setMutationEvents(orig);
int node = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (node != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (node, false); if (nodeType == Node.ENTITY_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (node, false); if (nodeName.equals (name)) { fDeferredEntityDecl = node; node = fDeferredDocumentImpl.getRealPrevSibling (node, false); fDeferredDocumentImpl.getLastChild (fDeferredEntityDecl, false) == -1) { int childIndex = fDeferredDocumentImpl.getLastChild (fCurrentNodeIndex, false); while (childIndex != -1) { int cloneIndex = fDeferredDocumentImpl.cloneNode (childIndex, true); fDeferredDocumentImpl.insertBefore (fDeferredEntityDecl, cloneIndex, prevIndex); prevIndex = cloneIndex; childIndex = fDeferredDocumentImpl.getRealPrevSibling (childIndex, false); fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false); } else { //!fCreateEntityRefNodes int childIndex = fDeferredDocumentImpl.getLastChild (fCurrentNodeIndex, false); int parentIndex = fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
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); int childIndex = getLastChild(nodeIndex, false); while (childIndex != -1) { int clonedChildIndex = cloneNode(childIndex, deep); insertBefore(cloneIndex, clonedChildIndex, prevIndex); prevIndex = clonedChildIndex; childIndex = getRealPrevSibling(childIndex, false);
if (needsSyncData()) { synchronizeData(); if (!needsSyncChildren()) { return; needsSyncChildren(false); getNodeType(0); for (int index = getLastChild(0); index != -1; index = getPrevSibling(index)) { ChildNode node = (ChildNode)getNodeObject(index); if (last == null) { last = node; firstChild = first; first.isFirstChild(true); lastChild(last);
fDeferredDocumentImpl.createDeferredEntityReference (name, identifier.getExpandedSystemId ()); if (fDocumentTypeIndex != -1) { int node = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (node != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (node, false); if (nodeType == Node.ENTITY_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (node, false); if (nodeName.equals (name)) { fDeferredEntityDecl = node; fDeferredDocumentImpl.setInputEncoding (node, encoding); break; node = fDeferredDocumentImpl.getRealPrevSibling (node, false); fDeferredDocumentImpl.appendChild (fCurrentNodeIndex, er); fCurrentNodeIndex = er;
/** Synchronizes the data (name and value) for fast nodes. */ protected void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) ownerDocument(); name = ownerDocument.getNodeName(fNodeIndex); int extra = ownerDocument.getNodeExtra(fNodeIndex); isSpecified((extra & SPECIFIED) != 0); isIdAttribute((extra & ID) != 0); int extraNode = ownerDocument.getLastChild(fNodeIndex); type = ownerDocument.getTypeInfo(extraNode); } // synchronizeData()
ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); namespaceURI = ownerDocument.getNodeURI(fNodeIndex); type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex); int attrIndex = ownerDocument.getNodeExtra(fNodeIndex); if (attrIndex != -1) { NamedNodeMap attrs = getAttributes(); boolean seenSchemaDefault = false; do { AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex); attrs.setNamedItem(attr); attrIndex = ownerDocument.getPrevSibling(attrIndex); } while (attrIndex != -1);
int nodeIndex = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (nodeIndex != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (nodeIndex, false); if (nodeType == Node.NOTATION_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (nodeIndex, false); if (nodeName.equals (name)) { found = true; nodeIndex = fDeferredDocumentImpl.getPrevSibling (nodeIndex, false); int notationIndex = fDeferredDocumentImpl.createDeferredNotation ( name, publicId, literalSystemId, identifier.getBaseSystemId ()); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, notationIndex);
String value = free ? clearChunkValue(fNodeValue, chunk, index) : getChunkValue(fNodeValue, chunk, index); if (value == null) { return null; int type = getChunkIndex(fNodeType, chunk, index); if (type == Node.TEXT_NODE) { int prevSib = getRealPrevSibling(nodeIndex); if (prevSib != -1 && getNodeType(prevSib, false) == Node.TEXT_NODE) { value = getChunkValue(fNodeValue, chunk, index); fStrChunks.add(value); prevSib = getChunkIndex(fNodePrevSib, chunk, index); if (prevSib == -1) { break; } while (getNodeType(prevSib, false) == Node.TEXT_NODE); int child = getLastChild(nodeIndex, false); if (child !=-1) { value = getChunkValue(fNodeValue, chunk, index); fStrChunks.add(value); child = getChunkIndex(fNodePrevSib, chunk, index);
/** * Returns internal Xerces details about all elements in the specified document. * The id of the returned {@link Map} is the {@code nodeIndex} of an element, and the list * is the array of ordered attributes names. * @param document the document * @return the map of an element index with its ordered attribute names */ public static Map<Integer, List<String>> getAttributesOrderMap(final Document document) { final Map<Integer, List<String>> map = new HashMap<>(); if (document instanceof DeferredDocumentImpl) { final DeferredDocumentImpl deferredDocument = (DeferredDocumentImpl) document; final int fNodeCount = getPrivate(deferredDocument, "fNodeCount"); for (int i = 0; i < fNodeCount; i++) { final int type = deferredDocument.getNodeType(i, false); if (type == org.w3c.dom.Node.ELEMENT_NODE) { int attrIndex = deferredDocument.getNodeExtra(i, false); final List<String> attributes = new ArrayList<>(); map.put(i, attributes); while (attrIndex != -1) { attributes.add(deferredDocument.getNodeName(attrIndex, false)); attrIndex = deferredDocument.getPrevSibling(attrIndex, false); } } } } return map; }
String attrName = getChunkValue(fNodeName, achunk, aindex); int oldAttrIndex = getChunkIndex(fNodeExtra, echunk, eindex); int nextIndex = -1; int oachunk = -1; oachunk = oldAttrIndex >> CHUNK_SHIFT; oaindex = oldAttrIndex & CHUNK_MASK; String oldAttrName = getChunkValue(fNodeName, oachunk, oaindex); if (oldAttrName.equals(attrName)) { break; oldAttrIndex = getChunkIndex(fNodePrevSib, oachunk, oaindex); int prevIndex = getChunkIndex(fNodePrevSib, oachunk, oaindex); if (nextIndex == -1) { setChunkIndex(fNodeExtra, prevIndex, echunk, eindex); setChunkIndex(fNodePrevSib, prevIndex, pchunk, pindex); 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);
short nodeType = fDeferredDocumentImpl.getNodeType (node, false); String baseURI = fDeferredDocumentImpl.getNodeValueString (fCurrentNodeIndex, false); if (baseURI == null) { baseURI = fDeferredDocumentImpl.getDeferredEntityBaseURI (fDeferredEntityDecl); if (baseURI !=null && !baseURI.equals (fDeferredDocumentImpl.getDocumentURI ())) { fDeferredDocumentImpl.setDeferredAttribute (node, "xml:base", "http://www.w3.org/XML/1998/namespace", String baseURI = fDeferredDocumentImpl.getNodeValueString (fCurrentNodeIndex, false); baseURI = fDeferredDocumentImpl.getDeferredEntityBaseURI (fDeferredEntityDecl);
int elementDefIndex = fDeferredDocumentImpl.lookupElementDefinition (elementName); elementDefIndex = fDeferredDocumentImpl.createDeferredElementDefinition (elementName); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, elementDefIndex); int attrIndex = fDeferredDocumentImpl.createDeferredAttribute ( attributeName, namespaceURI, defaultValue.toString(), false); if ("ID".equals (type)) { fDeferredDocumentImpl.setIdAttribute (attrIndex); fDeferredDocumentImpl.appendChild (elementDefIndex, attrIndex);