1 57 58 package org.xquark.xpath.datamodel.xerces.dom; 59 60 import org.w3c.dom.*; 61 62 78 public class TextImpl 79 extends CharacterDataImpl 80 implements CharacterData, Text { 81 82 86 87 static final long serialVersionUID = -5294980852957403469L; 88 89 93 94 public TextImpl(DocumentImpl ownerDoc, String data) { 95 super(ownerDoc, data); 96 } 97 98 102 106 public short getNodeType() { 107 return Node.TEXT_NODE; 108 } 109 110 111 public String getNodeName() { 112 return "#text"; 113 } 114 115 118 public void setIgnorableWhitespace(boolean ignore) { 119 120 if (needsSyncData()) { 121 synchronizeData(); 122 } 123 isIgnorableWhitespace(ignore); 124 125 } 127 128 131 public boolean isIgnorableWhitespace() { 132 133 if (needsSyncData()) { 134 synchronizeData(); 135 } 136 return internalIsIgnorableWhitespace(); 137 138 } 140 144 160 public Text splitText(int offset) 161 throws DOMException { 162 163 if (isReadOnly()) { 164 throw new DOMException( 165 DOMException.NO_MODIFICATION_ALLOWED_ERR, 166 "DOM001 Modification not allowed"); 167 } 168 169 if (needsSyncData()) { 170 synchronizeData(); 171 } 172 if (offset < 0 || offset > data.length() ) { 173 throw new DOMException(DOMException.INDEX_SIZE_ERR, 174 "DOM004 Index out of bounds"); 175 } 176 177 Text newText = 179 getOwnerDocument().createTextNode(data.substring(offset)); 180 setNodeValue(data.substring(0, offset)); 181 182 Node parentNode = getParentNode(); 184 if (parentNode != null) { 185 parentNode.insertBefore(newText, nextSibling); 186 } 187 188 return newText; 189 190 } 192 } | Popular Tags |