1 /* 2 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. 3 * 4 * This software is open source. 5 * See the bottom of this file for the licence. 6 * 7 * $Id: AbstractCDATA.java,v 1.9 2004/06/25 08:03:41 maartenc Exp $ 8 */ 9 10 package org.dom4j.tree; 11 12 import java.io.IOException; 13 import java.io.Writer; 14 15 import org.dom4j.CDATA; 16 import org.dom4j.Visitor; 17 18 /*** <p><code>AbstractCDATA</code> is an abstract base class for 19 * tree implementors to use for implementation inheritence.</p> 20 * 21 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> 22 * @version $Revision: 1.9 $ 23 */ 24 public abstract class AbstractCDATA extends AbstractCharacterData implements CDATA { 25 26 public AbstractCDATA() { 27 } 28 29 public short getNodeType() { 30 return CDATA_SECTION_NODE; 31 } 32 33 public String toString() { 34 return super.toString() + " [CDATA: \"" + getText() + "\"]"; 35 } 36 37 public String asXML() { 38 return "<![CDATA[" + getText() + "]]>"; 39 } 40 41 public void write(Writer writer) throws IOException { 42 writer.write( "<![CDATA[" ); 43 writer.write( getText() ); 44 writer.write( "]]>" ); 45 } 46 47 public void accept(Visitor visitor) { 48 visitor.visit(this); 49 } 50 } 51 52 53 54 55 /* 56 * Redistribution and use of this software and associated documentation 57 * ("Software"), with or without modification, are permitted provided 58 * that the following conditions are met: 59 * 60 * 1. Redistributions of source code must retain copyright 61 * statements and notices. Redistributions must also contain a 62 * copy of this document. 63 * 64 * 2. Redistributions in binary form must reproduce the 65 * above copyright notice, this list of conditions and the 66 * following disclaimer in the documentation and/or other 67 * materials provided with the distribution. 68 * 69 * 3. The name "DOM4J" must not be used to endorse or promote 70 * products derived from this Software without prior written 71 * permission of MetaStuff, Ltd. For written permission, 72 * please contact dom4j-info@metastuff.com. 73 * 74 * 4. Products derived from this Software may not be called "DOM4J" 75 * nor may "DOM4J" appear in their names without prior written 76 * permission of MetaStuff, Ltd. DOM4J is a registered 77 * trademark of MetaStuff, Ltd. 78 * 79 * 5. Due credit should be given to the DOM4J Project - 80 * http://www.dom4j.org 81 * 82 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 83 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 84 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 85 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 86 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 87 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 88 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 89 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 90 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 91 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 92 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 93 * OF THE POSSIBILITY OF SUCH DAMAGE. 94 * 95 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. 96 * 97 * $Id: AbstractCDATA.java,v 1.9 2004/06/25 08:03:41 maartenc Exp $ 98 */