public static Document newDocument(Node firstElement, boolean deepcopy) { Document newDoc = new DocumentImpl(); newDoc.appendChild(newDoc.importNode(firstElement, deepcopy)); return newDoc; }
/** Synchronizes the data (name and value) for fast nodes. */ protected void synchronizeData() { // no need to sync in the future needsSyncData(false); // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.getMutationEvents(); ownerDocument.setMutationEvents(false); // attributes setupDefaultAttributes(); // set mutation events flag back to its original value ownerDocument.setMutationEvents(orig); } // synchronizeData()
/** Synchronizes the data. */ protected void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) this.ownerDocument(); target = ownerDocument.getNodeName(fNodeIndex); data = ownerDocument.getNodeValueString(fNodeIndex); } // synchronizeData()
/** * NON-DOM: sets attribute node for this element */ protected int setXercesAttributeNode (Attr attr){ if (needsSyncData()) { synchronizeData(); } if (attributes == null) { attributes = new AttributeMap(this, null); } return attributes.addItem(attr); }
/** * Introduced in DOM Level 2. */ public boolean hasAttributes() { if (needsSyncData()) { synchronizeData(); } return (attributes != null && attributes.getLength() != 0); }
/** * Sets the content, possibly firing related events, * and updating ranges (via notification to the document) */ public void setNodeValue(String value) { setNodeValueInternal(value); // notify document ownerDocument().replacedText(this); }
/** Clones the node. */ public Node cloneNode(boolean deep) { DocumentTypeImpl newnode = (DocumentTypeImpl)super.cloneNode(deep); // NamedNodeMaps must be cloned explicitly, to avoid sharing them. newnode.entities = entities.cloneMap(newnode); newnode.notations = notations.cloneMap(newnode); newnode.elements = elements.cloneMap(newnode); return newnode; } // cloneNode(boolean):Node
public void removeEventListener(String type, EventListener listener, boolean useCapture) { // simply forward to Document ownerDocument().removeEventListener(this, type, listener, useCapture); }
/** * Returns the number of changes to this node. */ protected int changes() { // we do not actually store this information on every node, we only // have a global indicator on the Document. Doing otherwise cost us too // much for little gain. return ownerDocument().changes(); }
/** Setup the default attributes. */ protected void setupDefaultAttributes() { NamedNodeMapImpl defaults = getDefaultAttributes(); if (defaults != null) { attributes = new AttributeMap(this, defaults); } }
/** Reconcile default attributes. */ protected void reconcileDefaultAttributes() { if (attributes != null) { NamedNodeMapImpl defaults = getDefaultAttributes(); attributes.reconcileDefaults(defaults); } }
/** Clone node. */ public Node cloneNode(boolean deep) { EntityReferenceImpl er = (EntityReferenceImpl)super.cloneNode(deep); er.setReadOnly(true, deep); return er; }
/** * Returns the node number */ protected int getNodeNumber() { int nodeNumber; CoreDocumentImpl cd = (CoreDocumentImpl)(this.getOwnerDocument()); nodeNumber = cd.getNodeNumber(this); return nodeNumber; }
public void addEventListener(String type, EventListener listener, boolean useCapture) { // simply forward to Document ownerDocument().addEventListener(this, type, listener, useCapture); }
/** * Synchronizes the node's children with the internal structure. * Fluffing the children at once solves a lot of work to keep * the two structures in sync. The problem gets worse when * editing the tree -- this makes it a lot easier. */ protected void synchronizeChildren() { DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) ownerDocument(); ownerDocument.synchronizeChildren(this, fNodeIndex); } // synchronizeChildren()
protected final void synchronizeChildren() { DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) ownerDocument(); ownerDocument.synchronizeChildren(this, fNodeIndex); } // synchronizeChildren()
/** * Synchronizes the node's children with the internal structure. * Fluffing the children at once solves a lot of work to keep * the two structures in sync. The problem gets worse when * editing the tree -- this makes it a lot easier. */ protected void synchronizeChildren() { DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) ownerDocument(); ownerDocument.synchronizeChildren(this, fNodeIndex); } // synchronizeChildren()
public void getName(int attrIndex, QName attrName) { if (fAttributes != null) { updateQName((Node)fAttributes.getItem(attrIndex), attrName); } }
/** * NON-DOM: Subclassed to flip the attributes' readonly switch as well. * @see NodeImpl#setReadOnly */ public void setReadOnly(boolean readOnly, boolean deep) { super.setReadOnly(readOnly,deep); if (attributes != null) { attributes.setReadOnly(readOnly,true); } }
/** Clone node. */ public Node cloneNode(boolean deep) { EntityImpl newentity = (EntityImpl)super.cloneNode(deep); newentity.setReadOnly(true, deep); return newentity; }