1 56 57 package org.jdom; 58 59 72 public class CDATA extends Text { 73 74 private static final String CVS_ID = 75 "@(#) $RCSfile: CDATA.java,v $ $Revision: 1.30 $ $Date: 2004/02/27 11:32:57 $ $Name: $"; 76 77 82 protected CDATA() { } 83 84 94 public CDATA(String str) { 95 setText(str); 96 } 97 98 108 public Text setText(String str) { 109 113 String reason; 114 115 if (str == null) { 116 value = EMPTY_STRING; 117 return this; 118 } 119 120 if ((reason = Verifier.checkCDATASection(str)) != null) { 121 throw new IllegalDataException(str, "CDATA section", reason); 122 } 123 value = str; 124 return this; 125 } 126 127 137 public void append(String str) { 138 142 String reason; 143 144 if (str == null) { 145 return; 146 } 147 if ((reason = Verifier.checkCDATASection(str)) != null) { 148 throw new IllegalDataException(str, "CDATA section", reason); 149 } 150 151 if (value == EMPTY_STRING) 152 value = str; 153 else value += str; 154 } 155 156 166 public String toString() { 167 return new StringBuffer (64) 168 .append("[CDATA: ") 169 .append(getText()) 170 .append("]") 171 .toString(); 172 } 173 } 174 | Popular Tags |