001: /**
002: * org/ozone-db/xml/dom/CDATASectionImpl.java
003: *
004: * The contents of this file are subject to the OpenXML Public
005: * License Version 1.0; you may not use this file except in compliance
006: * with the License. You may obtain a copy of the License at
007: * http://www.openxml.org/license.html
008: *
009: * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
010: * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
011: * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
012: * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
013: * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
014: * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
015: *
016: * The Initial Developer of this code under the License is Assaf Arkin.
017: * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
018: * All Rights Reserved.
019: */
020:
021: /**
022: * Changes for Persistent DOM running with ozone are
023: * Copyright 1999 by SMB GmbH. All rights reserved.
024: */package org.ozoneDB.xml.dom;
025:
026: import org.w3c.dom.*;
027:
028: /**
029: * CDATA sections are used to escape blocks of text containing characters that
030: * would otherwise be regarded as markup. It is fully implemented by the {@link
031: * org.w3c.dom.Text} node type.
032: * <P>
033: * Notes:
034: * <OL>
035: * <LI>Node type is {@link org.w3c.dom.Node#COMMENT_NODE}
036: * <LI>Node does not support childern
037: * <LI>Node name is always "#comment"
038: * </OL>
039: *
040: *
041: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
042: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
043: * @see org.w3c.dom.CDATASection
044: * @see TextImpl
045: */
046: public final class CDATASectionImpl extends TextImpl implements
047: CDATASectionProxy {
048:
049: final static long serialVersionUID = 1;
050:
051: /**
052: */
053: public short getNodeType() {
054: return this .CDATA_SECTION_NODE;
055: }
056:
057: /**
058: */
059: public final Object clone() {
060: CDATASectionProxy clone = null;
061: try {
062: clone = (CDATASectionProxy) database().createObject(
063: CDATASectionImpl.class.getName());
064: clone.init(_ownerDocument, getNodeValue());
065: cloneInto((NodeProxy) clone, true);
066: } catch (Exception except) {
067: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
068: except.getMessage());
069: }
070: return clone;
071: }
072:
073: /**
074: */
075: public final Node cloneNode(boolean deep) {
076: CDATASectionProxy clone = null;
077: try {
078: clone = (CDATASectionProxy) database().createObject(
079: CDATASectionImpl.class.getName());
080: clone.init(_ownerDocument, getNodeValue());
081: cloneInto((NodeProxy) clone, deep);
082: } catch (Exception except) {
083: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
084: except.getMessage());
085: }
086: return clone;
087: }
088:
089: /**
090: */
091: public String toString() {
092: String value;
093:
094: value = getData();
095: if (value.length() > 64) {
096: value = value.substring(0, 64) + "..";
097: }
098: value = value.replace('\n', '|');
099: return "CDATA node: [" + value + "]";
100: }
101:
102: /**
103: * Hidden constructor.
104: *
105: * @param owner The owner of this document
106: * @param value Initial value or empty string
107: */
108: CDATASectionImpl(DocumentImpl owner, String value) {
109: super (owner, "#cdata-section", value);
110: }
111:
112: /**
113: */
114: public CDATASectionImpl() {
115: super ();
116: }
117:
118: /**
119: */
120: public final void init(DocumentProxy owner, String value) {
121: super .init(owner, "#cdata-section", value);
122: }
123:
124: }
|