1 package net.sf.saxon.dom; 2 3 import net.sf.saxon.type.ComplexType; 4 import net.sf.saxon.type.SchemaType; 5 import net.sf.saxon.type.Type; 6 import net.sf.saxon.value.Whitespace; 7 import org.w3c.dom.Comment ; 8 import org.w3c.dom.DOMException ; 9 import org.w3c.dom.Text ; 10 11 15 16 public class TextOverNodeInfo extends NodeOverNodeInfo implements Text , Comment { 17 18 19 23 24 public String getData() { 25 return node.getStringValue(); 26 } 27 28 32 33 public void setData(String data) throws DOMException { 34 disallowUpdate(); 35 } 36 37 41 42 public int getLength() { 43 return node.getStringValue().length(); 44 } 45 46 59 60 public String substringData(int offset, int count) throws DOMException { 61 try { 62 return node.getStringValue().substring(offset, offset+count); 63 } catch (IndexOutOfBoundsException err2) { 64 throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR, 65 "substringData: index out of bounds"); 66 } 67 } 68 69 76 77 public void appendData(String arg) throws DOMException { 78 disallowUpdate(); 79 } 80 81 88 89 public void insertData(int offset, String arg) throws DOMException { 90 disallowUpdate(); 91 } 92 93 100 101 public void deleteData(int offset, int count) throws DOMException { 102 disallowUpdate(); 103 } 104 105 115 116 public void replaceData(int offset, 117 int count, 118 String arg) throws DOMException { 119 disallowUpdate(); 120 } 121 122 123 130 131 public Text splitText(int offset) throws DOMException { 132 disallowUpdate(); 133 return null; 134 } 135 136 178 public Text replaceWholeText(String content) throws DOMException { 179 disallowUpdate(); 180 return null; 181 } 182 183 192 public boolean isElementContentWhitespace() { 193 if (node.getNodeKind() != Type.TEXT) { 194 throw new UnsupportedOperationException ("Method is defined only on text nodes"); 195 } 196 int annotation = node.getParent().getTypeAnnotation(); 197 if (annotation == -1) { 198 return false; 199 } 200 if (!Whitespace.isWhite(node.getStringValue())) { 201 return false; 202 } 203 SchemaType type = node.getConfiguration().getSchemaType(annotation); 204 if (!type.isComplexType()) { 205 return false; 206 } 207 if (((ComplexType)type).isMixedContent()) { 208 return false; 209 } 210 return true; 211 } 212 213 222 public String getWholeText() { 223 if (node.getNodeKind() != Type.TEXT) { 224 throw new UnsupportedOperationException ("Method is defined only on text nodes"); 225 } 226 return node.getStringValue(); 227 } 228 229 230 } 231 232 | Popular Tags |