1 package org.enhydra.xml; 2 3 import org.w3c.dom.DOMException ; 4 import org.w3c.dom.Node ; 5 import org.w3c.dom.Text ; 6 7 18 public class TextImpl extends CharacterDataImpl implements Text { 19 20 21 26 public TextImpl(TextImpl node) { 27 super((NodeImpl)node); 28 } 29 30 31 36 public TextImpl(String value) { 37 nodeValue = value; 38 type = Node.TEXT_NODE; 39 } 40 41 42 48 public TextImpl(Node node) { 49 super(node); 50 } 51 52 53 58 public short getNodeType() { 59 return Node.TEXT_NODE; 60 } 61 62 67 public String getNodeName() { 68 return "#text"; 69 } 70 71 72 77 public String getNodeValue() throws DOMException { 78 return nodeValue.trim(); 79 } 80 81 82 89 protected void beginToString(StringBuffer sb, Indent indent) { 90 sb.append(this.nodeValue.trim()); 91 } 92 93 96 protected void endToString(StringBuffer sb, Indent indent) { 97 } 98 99 100 118 public Text splitText(int offset) 119 throws DOMException { 120 121 if (offset < 0 || offset > nodeValue.length() ) { 122 throw new DOMException (DOMException.INDEX_SIZE_ERR, "Index out of bounds"); 123 } 124 125 TextImpl newText = new TextImpl(nodeValue.substring(offset)); 127 nodeValue = nodeValue.substring(0, offset); 128 129 Node parentNode = getParentNode(); 131 if (parentNode != null) { 132 parentNode.insertBefore(newText, nextSibling); 133 } 134 135 return newText; 136 137 } 138 139 140 143 public boolean isElementContentWhitespace() { 144 return false; 146 } 147 148 149 152 public String getWholeText() { 153 return null; 155 } 156 157 158 161 public Text replaceWholeText(String arg0) throws DOMException { 162 return null; 164 } 165 166 } 167 | Popular Tags |