/** * createTextNode method * * @return org.w3c.dom.Text * @param data * java.lang.String */ public Text createTextNode(String data) { TextImpl text = new TextImpl(); text.setOwnerDocument(this); text.setData(data); return text; }
/** * getData method * * @return java.lang.String */ public String getData() throws DOMException { if (this.fSource != null) return getData(this.fSource); String data = super.getData(); if (data != null) return data; return getData(getStructuredDocumentRegion()); }
/** * cloneNode method * * @return org.w3c.dom.Node * @param deep * boolean */ public Node cloneNode(boolean deep) { TextImpl cloned = new TextImpl(this); notifyUserDataHandlers(UserDataHandler.NODE_CLONED, cloned); return cloned; }
if (!isDataEditable()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); int length = getLength(); if (offset > length) { throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); Document document = getOwnerDocument(); if (document == null) return null; if (offset < length) { int count = length - offset; source = substringSource(offset, count); deleteData(offset, count); text.setTextSource(source); Node parent = getParentNode(); if (parent != null) parent.insertBefore(text, getNextSibling());
if (!isDataEditable()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); deleteData(offset, count); return; insertData(offset, arg); return; String source = getSource(); if (source == null || source.length() == 0) { throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); StringPair pair = substringSourceExcluded(source, offset, count); if (pair == null) return; // error if (first != null) buffer.append(first); source = getSource(arg); if (source != null) buffer.append(source); if (second != null) buffer.append(second); setTextSource(buffer.toString());
return null; IStructuredDocumentRegion flatNode = getStructuredDocumentRegion(); if (flatNode == null || !(flatNode instanceof StructuredDocumentRegionContainer)) return null; // error return this; // nothing to do Document document = getOwnerDocument(); if (document == null) return null; // error Node parent = getParentNode(); if (parent == null) return null; // error nextText.appendStructuredDocumentRegion(container.removeStructuredDocumentRegion(index)); setStructuredDocumentRegion(container.getStructuredDocumentRegion(0)); parent.insertBefore(nextText, getNextSibling()); return nextText;
IStructuredDocumentRegion flatNode = nextText.getStructuredDocumentRegion(); if (flatNode != null) prevText.appendStructuredDocumentRegion(flatNode); Node newNext = next.getNextSibling(); parent.removeChild(next); if (childText.getNextSibling() == null && childText.getPreviousSibling() == null) { if (parent.getNodeType() == Node.ELEMENT_NODE) { ElementImpl parentElement = (ElementImpl) parent; if (!parentElement.hasStartTag() && !parentElement.hasEndTag()) { if (childText.isWhitespace() || childText.isInvalid()) {
int start = impl.getStartOffset(); int end = impl.getEndOffset(); int offset = start; this.gapStructuredDocumentRegion = impl.getStructuredDocumentRegion(); IStructuredDocumentRegion newStructuredDocumentRegion = null; if (length > 0) newStructuredDocumentRegion = new StructuredDocumentRegionProxy(offset, length); impl.setStructuredDocumentRegion(newStructuredDocumentRegion);
@Override protected void setOwnerDocument(Document ownerDocument) { super.setOwnerDocument(ownerDocument); }
/** * insertText method Can be called from subclasses, not to be overrided or * re-implemented. * */ protected void insertText(IStructuredDocumentRegion flatNode) { TextImpl text = (TextImpl) this.context.findPreviousText(); if (text != null) { // existing text found text.appendStructuredDocumentRegion(flatNode); // notify the change text.notifyValueChanged(); return; } // new text text = (TextImpl) this.model.getDocument().createTextNode(null); if (text == null) return; text.setStructuredDocumentRegion(flatNode); insertNode(text); }
return null; if (nextStructuredDocumentRegion == null) return appendStructuredDocumentRegion(newStructuredDocumentRegion); IStructuredDocumentRegion flatNode = getStructuredDocumentRegion(); if (flatNode == null) return null; // error container.appendStructuredDocumentRegion(newStructuredDocumentRegion); container.appendStructuredDocumentRegion(flatNode); setStructuredDocumentRegion(container); return newStructuredDocumentRegion;
/** * generateText method * * @return java.lang.String * @param text * org.w3c.dom.Text */ public String generateText(Text text) { if (text == null) return null; TextImpl impl = (TextImpl) text; String source = impl.getTextSource(); if (source != null) return source; return generateTextData(text, impl.getData()); }
for (int i = 0; i < count; i++) { IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i); String data = getData(content); if (data == null) continue; String name = StructuredDocumentRegionUtil.getEntityRefName(flatNode, region); if (name != null) { DocumentImpl document = (DocumentImpl) getOwnerDocument(); if (document != null) { String value = document.getCharValue(name);
if (end > ref + 1) { String name = source.substring(ref + 1, end); String value = getCharValue(name); if (value != null) { if (buffer == null)
/** */ public boolean isWhitespace() { String data = getData(); if (data == null) return true; int length = data.length(); for (int i = 0; i < length; i++) { if (!Character.isWhitespace(data.charAt(i))) return false; } return true; }
/** * 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; } } }
protected void setOwnerDocument(Document ownerDocument) { super.setOwnerDocument(ownerDocument); }
if (text != null) { // existing text found text.appendStructuredDocumentRegion(flatNode); text.notifyValueChanged(); return; if (text == null) return; text.setStructuredDocumentRegion(flatNode); insertNode(text); return;
if (refEnd > ref + 1) { String name = source.substring(ref + 1, refEnd); if (getCharValue(name) != null) {
if (refEnd > ref + 1) { String name = source.substring(ref + 1, refEnd); if (getCharValue(name) != null) {