1 7 8 package org.dom4j.tree; 9 10 import java.io.IOException ; 11 import java.io.StringWriter ; 12 import java.io.Writer ; 13 14 import org.dom4j.CDATA; 15 import org.dom4j.Visitor; 16 17 26 public abstract class AbstractCDATA extends AbstractCharacterData implements 27 CDATA { 28 public AbstractCDATA() { 29 } 30 31 public short getNodeType() { 32 return CDATA_SECTION_NODE; 33 } 34 35 public String toString() { 36 return super.toString() + " [CDATA: \"" + getText() + "\"]"; 37 } 38 39 public String asXML() { 40 StringWriter writer = new StringWriter (); 41 42 try { 43 write(writer); 44 } catch (IOException e) { 45 } 47 48 return writer.toString(); 49 } 50 51 public void write(Writer writer) throws IOException { 52 writer.write("<![CDATA["); 53 54 if (getText() != null) { 55 writer.write(getText()); 56 } 57 58 writer.write("]]>"); 59 } 60 61 public void accept(Visitor visitor) { 62 visitor.visit(this); 63 } 64 } 65 66 102 | Popular Tags |