/** * The deepest common ancestor container of the Range's two * boundary-points. * * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has * already been invoked on this object. */ public Node getCommonAncestorContainer() throws DOMException { if (this.startContainer == null) return null; return ((NodeImpl) this.startContainer).getCommonAncestor(this.endContainer); }
/** * notifyValueChanged method */ protected void notifyValueChanged() { DocumentImpl document = (DocumentImpl) getContainerDocument(); if (document == null) return; syncDataEditableState(); DOMModelImpl model = (DOMModelImpl) document.getModel(); if (model == null) return; model.valueChanged(this); }
/** * contains method * * @return boolean * @param offset * int */ public boolean contains(int offset) { return (offset >= getStartOffset() && offset < getEndOffset()); }
/** * Resets children values from IStructuredDocumentRegion. */ void resetStructuredDocumentRegions() { for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) { child.resetStructuredDocumentRegions(); } this.flatNode = null; }
/** */ protected void setOwnerDocument(Document ownerDocument, boolean deep) { this.ownerDocument = (DocumentImpl) ownerDocument; if (deep) { for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) { child.setOwnerDocument(ownerDocument, deep); } } }
while (this.parentNode != null) { if (this.nextNode != null) { if (this.nextNode.getStructuredDocumentRegion() == oldStructuredDocumentRegion) { ownerNode = this.nextNode; break; if (this.nextNode.getNodeType() == Node.TEXT_NODE) { TextImpl text = (TextImpl) this.nextNode; if (text.hasStructuredDocumentRegion(oldStructuredDocumentRegion)) { Node child = this.nextNode.getFirstChild(); if (child != null) { this.parentNode = this.nextNode; if (this.nextNode.getNodeType() == Node.ELEMENT_NODE) { this.parentNode = this.nextNode; this.nextNode = null; this.nextNode = (NodeImpl) this.nextNode.getNextSibling(); if (this.nextNode != null) continue; if (this.parentNode.getNodeType() == Node.ELEMENT_NODE) { ElementImpl element = (ElementImpl) this.parentNode; if (element.getEndStructuredDocumentRegion() == oldStructuredDocumentRegion) { this.nextNode = (NodeImpl) this.parentNode.getNextSibling(); this.parentNode = (NodeImpl) this.parentNode.getParentNode();
if (oldChild != null) { NodeImpl node = (NodeImpl) oldChild; start = node.getStartOffset(); end = node.getEndOffset(); if (oldChild.getNodeType() == Node.TEXT_NODE) { this.gapStructuredDocumentRegion = node.getStructuredDocumentRegion(); node.resetStructuredDocumentRegions(); // reset values from NodeImpl prev = (NodeImpl) newChild.getPreviousSibling(); if (prev != null) { start = prev.getEndOffset(); end = start; preTag = getCloseTag(prev); start = next.getStartOffset(); end = start; if (parentNode.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeType() == Node.ELEMENT_NODE) { ElementImpl element = (ElementImpl) node; if (element.preferEmptyTag()) node.setStructuredDocumentRegion(flatNode); NodeImpl child = (NodeImpl) node.getFirstChild(); if (child != null) { node = child;
NodeImpl prev = (NodeImpl) child.getPreviousSibling(); NodeImpl next = (NodeImpl) child.getNextSibling(); child.setEditable(true, true); // clear ReadOnly flags prev.setNextSibling(next); if (next == null) this.lastChild = prev; else next.setPreviousSibling(prev); child.setPreviousSibling(null); child.setNextSibling(null); child.setParentNode(null);
/** * getStartOffset method * * @return int */ public int getStartOffset() { if (this.flatNode != null) return this.flatNode.getStart(); NodeImpl prev = (NodeImpl) getPreviousSibling(); if (prev != null) return prev.getEndOffset(); Node parent = getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { ElementImpl element = (ElementImpl) parent; if (element.hasStartTag()) return element.getStartEndOffset(); return element.getStartOffset(); } // final fallback to look into first child NodeImpl child = (NodeImpl) getFirstChild(); while (child != null) { IStructuredDocumentRegion childStructuredDocumentRegion = child.getStructuredDocumentRegion(); if (childStructuredDocumentRegion != null) return childStructuredDocumentRegion.getStart(); child = (NodeImpl) child.getFirstChild(); } return 0; }
Node child = root.getFirstChild(); if (child != null) this.context.setNextNode(child); NodeImpl node = (NodeImpl) root.getNodeAt(offset); if (node == null) { if (offset == node.getStartOffset()) { this.context.setNextNode(node); return; if (node.getNodeType() == Node.TEXT_NODE) { TextImpl text = (TextImpl) node; Text nextText = text.splitText(startStructuredDocumentRegion); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { if (offset >= ((NodeImpl) child).getEndOffset()) continue; this.context.setNextNode(child);
int start = impl.getStartOffset(); int end = impl.getEndOffset(); this.gapStructuredDocumentRegion = impl.getStructuredDocumentRegion(); IStructuredDocumentRegion flatNode = null; if (length > 0) flatNode = new StructuredDocumentRegionProxy(start, length); impl.setStructuredDocumentRegion(flatNode);
public void setEditable(boolean editable, boolean deep) { if (deep) { IDOMNode node = (IDOMNode) getFirstChild(); while (node != null) { node.setEditable(editable, deep); node = (IDOMNode) node.getNextSibling(); } } setChildEditable(editable); setDataEditable(editable); }
/** */ private void changeAttrEqual(IStructuredDocumentRegion flatNode, ITextRegion region) { int offset = flatNode.getStart(); if (offset < 0) return; NodeImpl root = (NodeImpl) this.context.getRootNode(); if (root == null) return; Node node = root.getNodeAt(offset); if (node == null) return; if (node.getNodeType() != Node.ELEMENT_NODE) { if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { // just notify the change instead of setting data ProcessingInstructionImpl pi = (ProcessingInstructionImpl) node; pi.notifyValueChanged(); } return; } // actually, do nothing }
/** * normalize method */ public void normalize() { TextImpl prevText = null; for (Node child = getFirstChild(); child != null; child = child.getNextSibling()) { switch (child.getNodeType()) { case TEXT_NODE : { if (prevText == null) { prevText = (TextImpl) child; break; } Text text = (Text) child; removeChild(text); prevText.appendText(text); child = prevText; break; } case ELEMENT_NODE : { Element element = (Element) child; element.normalize(); prevText = null; break; } default : prevText = null; break; } } }
/** */ public String getSource() { StringBuffer buffer = new StringBuffer(); IStructuredDocumentRegion startStructuredDocumentRegion = getStartStructuredDocumentRegion(); if (startStructuredDocumentRegion != null) { String source = startStructuredDocumentRegion.getText(); if (source != null) buffer.append(source); } for (NodeImpl child = firstChild; child != null; child = (NodeImpl) child.getNextSibling()) { String source = child.getSource(); if (source != null) buffer.append(source); } IStructuredDocumentRegion endStructuredDocumentRegion = getEndStructuredDocumentRegion(); if (endStructuredDocumentRegion != null) { String source = endStructuredDocumentRegion.getText(); if (source != null) buffer.append(source); } return buffer.toString(); }
/** * Sets the end position to be before a node. * * @param refNodeRange * ends before <code>refNode</code> * @exception RangeException * INVALID_NODE_TYPE_ERR: Raised if the root container of * <code>refNode</code> is not an Attr, Document, or * DocumentFragment node or if <code>refNode</code> is a * Document, DocumentFragment, Attr, Entity, or Notation * node. * @exception DOMException * INVALID_STATE_ERR: Raised if <code>detach()</code> has * already been invoked on this object. */ public void setEndBefore(Node refNode) throws RangeException, DOMException { if (refNode == null) return; Node parent = refNode.getParentNode(); if (parent == null) return; int index = ((NodeImpl) refNode).getIndex(); if (index < 0) return; setEnd(parent, index); }
if (root == null) return; Node node = root.getNodeAt(offset); if (node == null) return; impl.notifyValueChanged();
this.nextNode = (NodeImpl) root.getFirstChild(); this.nextNode = (NodeImpl) root.getFirstChild(); this.nextNode = (NodeImpl) root.getFirstChild();
/** */ public FactoryRegistry getFactoryRegistry() { IDOMModel model = getModel(); if (model != null) { FactoryRegistry reg = model.getFactoryRegistry(); if (reg != null) return reg; } return null; }
/** * toString method * * @return java.lang.String */ public String toString() { return getNodeName(); }