1 16 17 package org.jboss.axis.message; 18 19 import org.w3c.dom.DOMException ; 20 import org.w3c.dom.Text ; 21 22 31 public class TextImpl extends NodeImpl implements javax.xml.soap.Text 32 { 33 34 public TextImpl(org.w3c.dom.Node node) 35 { 36 super(node); 37 } 38 39 42 public boolean isComment() 43 { 44 String value = getNodeValue().trim(); 45 return value.startsWith("<!--") && value.endsWith("-->"); 46 } 47 48 public String getValue() 49 { 50 return getNodeValue(); 51 } 52 53 public void setValue(String value) 54 { 55 setNodeValue(value); 56 } 57 58 72 public org.w3c.dom.Text splitText(int offset) throws DOMException 73 { 74 75 if (offset < 0 || offset > getNodeValue().length()) 76 throw new IllegalArgumentException ("Invalid offset [" + offset + "] for '" + getNodeValue() + "'"); 77 78 String before = getNodeValue().substring(0, offset + 1); 79 setNodeValue(before); 80 81 String after = getNodeValue().substring(offset + 1); 82 TextImpl txtNode = new TextImpl(domNode.getOwnerDocument().createTextNode(after)); 83 84 org.w3c.dom.Node parent = getParentNode(); 85 if (parent != null) 86 { 87 org.w3c.dom.Node sibling = getNextSibling(); 88 if (sibling == null) 89 parent.appendChild(txtNode); 90 else 91 parent.insertBefore(txtNode, sibling); 92 } 93 94 return txtNode; 95 } 96 97 99 104 public int getLength() 105 { 106 return getNodeValue().length(); 107 } 108 109 124 public void deleteData(int offset, int count) throws DOMException 125 { 126 String value = getNodeValue().substring(0, offset + 1); 127 setNodeValue(value); 128 } 129 130 144 public String getData() throws DOMException 145 { 146 return getNodeValue(); 147 } 148 149 164 public String substringData(int offset, int count) throws DOMException 165 { 166 return getNodeValue().substring(offset, offset + count); 167 } 168 169 188 public void replaceData(int offset, int count, String arg) throws DOMException 189 { 190 StringBuffer buffer = new StringBuffer (getNodeValue()); 191 buffer.replace(offset, offset + count, arg); 192 setNodeValue(buffer.toString()); 193 } 194 195 205 public void insertData(int offset, String arg) throws DOMException 206 { 207 StringBuffer buffer = new StringBuffer (getNodeValue()); 208 buffer.insert(offset, arg); 209 setNodeValue(buffer.toString()); 210 } 211 212 220 public void appendData(String arg) throws DOMException 221 { 222 setNodeValue(getNodeValue() + arg); 223 } 224 225 239 public void setData(String data) throws DOMException 240 { 241 setNodeValue(data); 242 } 243 244 246 256 public boolean isElementContentWhitespace() 257 { 258 return false; 259 } 260 261 271 public String getWholeText() 272 { 273 return null; 274 } 275 276 320 public Text replaceWholeText(String content) 321 throws DOMException 322 { 323 return null; 324 } 325 326 } 327 | Popular Tags |