| 1 |  |  | 
| 2 |  |  | 
| 3 |  |  | 
| 4 |  |  | 
| 5 |  |  | 
| 6 |  |  | 
| 7 |  |  | 
| 8 |  | package org.dom4j.dom; | 
| 9 |  |  | 
| 10 |  | import org.dom4j.CDATA; | 
| 11 |  | import org.dom4j.Element; | 
| 12 |  | import org.dom4j.tree.DefaultCDATA; | 
| 13 |  |  | 
| 14 |  | import org.w3c.dom.DOMException; | 
| 15 |  | import org.w3c.dom.Document; | 
| 16 |  | import org.w3c.dom.NamedNodeMap; | 
| 17 |  | import org.w3c.dom.NodeList; | 
| 18 |  |  | 
| 19 |  |  | 
| 20 |  |  | 
| 21 |  |  | 
| 22 |  |  | 
| 23 |  |  | 
| 24 |  |  | 
| 25 |  |  | 
| 26 |  |  | 
| 27 |  |  | 
| 28 |  | public class DOMCDATA extends DefaultCDATA implements org.w3c.dom.CDATASection { | 
| 29 | 0 | public DOMCDATA(String text) { | 
| 30 | 0 | super(text); | 
| 31 |  | } | 
| 32 |  |  | 
| 33 | 0 | public DOMCDATA(Element parent, String text) { | 
| 34 | 0 | super(parent, text); | 
| 35 |  | } | 
| 36 |  |  | 
| 37 |  |  | 
| 38 |  |  | 
| 39 | 0 | public boolean supports(String feature, String version) { | 
| 40 | 0 | return DOMNodeHelper.supports(this, feature, version); | 
| 41 |  | } | 
| 42 |  |  | 
| 43 | 0 | public String getNamespaceURI() { | 
| 44 | 0 | return DOMNodeHelper.getNamespaceURI(this); | 
| 45 |  | } | 
| 46 |  |  | 
| 47 | 0 | public String getPrefix() { | 
| 48 | 0 | return DOMNodeHelper.getPrefix(this); | 
| 49 |  | } | 
| 50 |  |  | 
| 51 | 0 | public void setPrefix(String prefix) throws DOMException { | 
| 52 | 0 | DOMNodeHelper.setPrefix(this, prefix); | 
| 53 |  | } | 
| 54 |  |  | 
| 55 | 0 | public String getLocalName() { | 
| 56 | 0 | return DOMNodeHelper.getLocalName(this); | 
| 57 |  | } | 
| 58 |  |  | 
| 59 | 0 | public String getNodeName() { | 
| 60 | 0 | return "#cdata-section"; | 
| 61 |  | } | 
| 62 |  |  | 
| 63 |  |  | 
| 64 |  |  | 
| 65 |  |  | 
| 66 | 0 | public String getNodeValue() throws DOMException { | 
| 67 | 0 | return DOMNodeHelper.getNodeValue(this); | 
| 68 |  | } | 
| 69 |  |  | 
| 70 | 0 | public void setNodeValue(String nodeValue) throws DOMException { | 
| 71 | 0 | DOMNodeHelper.setNodeValue(this, nodeValue); | 
| 72 |  | } | 
| 73 |  |  | 
| 74 | 0 | public org.w3c.dom.Node getParentNode() { | 
| 75 | 0 | return DOMNodeHelper.getParentNode(this); | 
| 76 |  | } | 
| 77 |  |  | 
| 78 | 0 | public NodeList getChildNodes() { | 
| 79 | 0 | return DOMNodeHelper.getChildNodes(this); | 
| 80 |  | } | 
| 81 |  |  | 
| 82 | 0 | public org.w3c.dom.Node getFirstChild() { | 
| 83 | 0 | return DOMNodeHelper.getFirstChild(this); | 
| 84 |  | } | 
| 85 |  |  | 
| 86 | 0 | public org.w3c.dom.Node getLastChild() { | 
| 87 | 0 | return DOMNodeHelper.getLastChild(this); | 
| 88 |  | } | 
| 89 |  |  | 
| 90 | 0 | public org.w3c.dom.Node getPreviousSibling() { | 
| 91 | 0 | return DOMNodeHelper.getPreviousSibling(this); | 
| 92 |  | } | 
| 93 |  |  | 
| 94 | 0 | public org.w3c.dom.Node getNextSibling() { | 
| 95 | 0 | return DOMNodeHelper.getNextSibling(this); | 
| 96 |  | } | 
| 97 |  |  | 
| 98 | 0 | public NamedNodeMap getAttributes() { | 
| 99 | 0 | return null; | 
| 100 |  | } | 
| 101 |  |  | 
| 102 | 0 | public Document getOwnerDocument() { | 
| 103 | 0 | return DOMNodeHelper.getOwnerDocument(this); | 
| 104 |  | } | 
| 105 |  |  | 
| 106 | 0 | public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, | 
| 107 |  | org.w3c.dom.Node refChild) throws DOMException { | 
| 108 | 0 | checkNewChildNode(newChild); | 
| 109 |  |  | 
| 110 | 0 | return DOMNodeHelper.insertBefore(this, newChild, refChild); | 
| 111 |  | } | 
| 112 |  |  | 
| 113 | 0 | public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, | 
| 114 |  | org.w3c.dom.Node oldChild) throws DOMException { | 
| 115 | 0 | checkNewChildNode(newChild); | 
| 116 |  |  | 
| 117 | 0 | return DOMNodeHelper.replaceChild(this, newChild, oldChild); | 
| 118 |  | } | 
| 119 |  |  | 
| 120 | 0 | public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) | 
| 121 |  | throws DOMException { | 
| 122 | 0 | return DOMNodeHelper.removeChild(this, oldChild); | 
| 123 |  | } | 
| 124 |  |  | 
| 125 | 0 | public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) | 
| 126 |  | throws DOMException { | 
| 127 | 0 | checkNewChildNode(newChild); | 
| 128 |  |  | 
| 129 | 0 | return DOMNodeHelper.appendChild(this, newChild); | 
| 130 |  | } | 
| 131 |  |  | 
| 132 | 0 | private void checkNewChildNode(org.w3c.dom.Node newChild) | 
| 133 |  | throws DOMException { | 
| 134 | 0 | throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, | 
| 135 |  | "CDATASection nodes cannot have children"); | 
| 136 |  | } | 
| 137 |  |  | 
| 138 | 0 | public boolean hasChildNodes() { | 
| 139 | 0 | return DOMNodeHelper.hasChildNodes(this); | 
| 140 |  | } | 
| 141 |  |  | 
| 142 | 0 | public org.w3c.dom.Node cloneNode(boolean deep) { | 
| 143 | 0 | return DOMNodeHelper.cloneNode(this, deep); | 
| 144 |  | } | 
| 145 |  |  | 
| 146 | 0 | public void normalize() { | 
| 147 | 0 | DOMNodeHelper.normalize(this); | 
| 148 |  | } | 
| 149 |  |  | 
| 150 | 0 | public boolean isSupported(String feature, String version) { | 
| 151 | 0 | return DOMNodeHelper.isSupported(this, feature, version); | 
| 152 |  | } | 
| 153 |  |  | 
| 154 | 0 | public boolean hasAttributes() { | 
| 155 | 0 | return DOMNodeHelper.hasAttributes(this); | 
| 156 |  | } | 
| 157 |  |  | 
| 158 |  |  | 
| 159 |  |  | 
| 160 | 0 | public String getData() throws DOMException { | 
| 161 | 0 | return DOMNodeHelper.getData(this); | 
| 162 |  | } | 
| 163 |  |  | 
| 164 | 0 | public void setData(String data) throws DOMException { | 
| 165 | 0 | DOMNodeHelper.setData(this, data); | 
| 166 |  | } | 
| 167 |  |  | 
| 168 | 0 | public int getLength() { | 
| 169 | 0 | return DOMNodeHelper.getLength(this); | 
| 170 |  | } | 
| 171 |  |  | 
| 172 | 0 | public String substringData(int offset, int count) throws DOMException { | 
| 173 | 0 | return DOMNodeHelper.substringData(this, offset, count); | 
| 174 |  | } | 
| 175 |  |  | 
| 176 | 0 | public void appendData(String arg) throws DOMException { | 
| 177 | 0 | DOMNodeHelper.appendData(this, arg); | 
| 178 |  | } | 
| 179 |  |  | 
| 180 | 0 | public void insertData(int offset, String arg) throws DOMException { | 
| 181 | 0 | DOMNodeHelper.insertData(this, offset, arg); | 
| 182 |  | } | 
| 183 |  |  | 
| 184 | 0 | public void deleteData(int offset, int count) throws DOMException { | 
| 185 | 0 | DOMNodeHelper.deleteData(this, offset, count); | 
| 186 |  | } | 
| 187 |  |  | 
| 188 | 0 | public void replaceData(int offset, int count, String arg) | 
| 189 |  | throws DOMException { | 
| 190 | 0 | DOMNodeHelper.replaceData(this, offset, count, arg); | 
| 191 |  | } | 
| 192 |  |  | 
| 193 |  |  | 
| 194 |  |  | 
| 195 | 0 | public org.w3c.dom.Text splitText(int offset) throws DOMException { | 
| 196 | 0 | if (isReadOnly()) { | 
| 197 | 0 | throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, | 
| 198 |  | "CharacterData node is read only: " + this); | 
| 199 |  | } else { | 
| 200 | 0 | String text = getText(); | 
| 201 | 0 | int length = (text != null) ? text.length() : 0; | 
| 202 |  |  | 
| 203 | 0 | if ((offset < 0) || (offset >= length)) { | 
| 204 | 0 | throw new DOMException(DOMException.INDEX_SIZE_ERR, | 
| 205 |  | "No text at offset: " + offset); | 
| 206 |  | } else { | 
| 207 | 0 | String start = text.substring(0, offset); | 
| 208 | 0 | String rest = text.substring(offset); | 
| 209 | 0 | setText(start); | 
| 210 |  |  | 
| 211 | 0 | Element parent = getParent(); | 
| 212 | 0 | CDATA newText = createCDATA(rest); | 
| 213 |  |  | 
| 214 | 0 | if (parent != null) { | 
| 215 | 0 | parent.add(newText); | 
| 216 |  | } | 
| 217 |  |  | 
| 218 | 0 | return DOMNodeHelper.asDOMText(newText); | 
| 219 |  | } | 
| 220 |  | } | 
| 221 |  | } | 
| 222 |  |  | 
| 223 |  |  | 
| 224 |  |  | 
| 225 | 0 | protected CDATA createCDATA(String text) { | 
| 226 | 0 | return new DOMCDATA(text); | 
| 227 |  | } | 
| 228 |  | } | 
| 229 |  |  | 
| 230 |  |  | 
| 231 |  |  | 
| 232 |  |  | 
| 233 |  |  | 
| 234 |  |  | 
| 235 |  |  | 
| 236 |  |  | 
| 237 |  |  | 
| 238 |  |  | 
| 239 |  |  | 
| 240 |  |  | 
| 241 |  |  | 
| 242 |  |  | 
| 243 |  |  | 
| 244 |  |  | 
| 245 |  |  | 
| 246 |  |  | 
| 247 |  |  | 
| 248 |  |  | 
| 249 |  |  | 
| 250 |  |  | 
| 251 |  |  | 
| 252 |  |  | 
| 253 |  |  | 
| 254 |  |  | 
| 255 |  |  | 
| 256 |  |  | 
| 257 |  |  | 
| 258 |  |  | 
| 259 |  |  | 
| 260 |  |  | 
| 261 |  |  | 
| 262 |  |  | 
| 263 |  |  | 
| 264 |  |  | 
| 265 |  |  |