001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: AbstractCDATA.java,v 1.6 2001/05/11 14:01:34 jstrachan Exp $ 008 */ 009 010package org.dom4j.tree; 011 012import java.io.IOException; 013import java.io.Writer; 014 015import org.dom4j.CDATA; 016import org.dom4j.Visitor; 017 018/** <p><code>AbstractCDATA</code> is an abstract base class for 019 * tree implementors to use for implementation inheritence.</p> 020 * 021 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> 022 * @version $Revision: 1.6 $ 023 */ 024public abstract class AbstractCDATA extends AbstractCharacterData implements CDATA { 025 026 public AbstractCDATA() { 027 } 028 029 public short getNodeType() { 030 return CDATA_SECTION_NODE; 031 } 032 033 public String toString() { 034 return super.toString() + " [CDATA: \"" + getText() + "\"]"; 035 } 036 037 public String asXML() { 038 return "<![CDATA[" + getText() + "]]>"; 039 } 040 041 public void write(Writer writer) throws IOException { 042 writer.write( "<![CDATA[" ); 043 writer.write( getText() ); 044 writer.write( "]]>" ); 045 } 046 047 public void accept(Visitor visitor) { 048 visitor.visit(this); 049 } 050} 051 052 053 054 055/* 056 * Redistribution and use of this software and associated documentation 057 * ("Software"), with or without modification, are permitted provided 058 * that the following conditions are met: 059 * 060 * 1. Redistributions of source code must retain copyright 061 * statements and notices. Redistributions must also contain a 062 * copy of this document. 063 * 064 * 2. Redistributions in binary form must reproduce the 065 * above copyright notice, this list of conditions and the 066 * following disclaimer in the documentation and/or other 067 * materials provided with the distribution. 068 * 069 * 3. The name "DOM4J" must not be used to endorse or promote 070 * products derived from this Software without prior written 071 * permission of MetaStuff, Ltd. For written permission, 072 * please contact dom4j-info@metastuff.com. 073 * 074 * 4. Products derived from this Software may not be called "DOM4J" 075 * nor may "DOM4J" appear in their names without prior written 076 * permission of MetaStuff, Ltd. DOM4J is a registered 077 * trademark of MetaStuff, Ltd. 078 * 079 * 5. Due credit should be given to the DOM4J Project 080 * (http://dom4j.org/). 081 * 082 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 083 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 084 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 085 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 086 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 087 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 088 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 089 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 090 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 091 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 092 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 093 * OF THE POSSIBILITY OF SUCH DAMAGE. 094 * 095 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 096 * 097 * $Id: AbstractCDATA.java,v 1.6 2001/05/11 14:01:34 jstrachan Exp $ 098 */