001: /**
002: * org/ozone-db/xml/dom/CommentImpl.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 java.util.*;
027: import org.w3c.dom.*;
028:
029: /**
030: * Implements a {@link org.w3c.dom.Comment} object. This is a text data object
031: * whose value can be manipulated using the {@link org.w3c.dom.CharacterData}\
032: * interface and does not support children.
033: * <P>
034: * Notes:
035: * <OL>
036: * <LI>Node type is {@link org.w3c.dom.Node#COMMENT_NODE}
037: * <LI>Node does not support childern
038: * <LI>Node name is always "#comment"
039: * </OL>
040: *
041: *
042: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
043: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
044: * @see org.w3c.dom.Comment
045: * @see CharacterDataImpl
046: */
047: public final class CommentImpl extends CharacterDataImpl implements
048: CommentProxy {
049:
050: final static long serialVersionUID = 1;
051:
052: public short getNodeType() {
053: return COMMENT_NODE;
054: }
055:
056: public final Object clone() {
057: CommentProxy clone = null;
058: try {
059: clone = (CommentProxy) database().createObject(
060: CommentImpl.class.getName());
061: clone.init(_ownerDocument, getNodeValue());
062: cloneInto((NodeProxy) clone, true);
063: } catch (Exception except) {
064: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
065: except.getMessage());
066: }
067: return clone;
068: }
069:
070: public final Node cloneNode(boolean deep) {
071: CommentProxy clone = null;
072: try {
073: clone = (CommentProxy) database().createObject(
074: CommentImpl.class.getName());
075: clone.init(_ownerDocument, getNodeValue());
076: cloneInto((NodeProxy) clone, deep);
077: } catch (Exception except) {
078: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
079: except.getMessage());
080: }
081: return clone;
082: }
083:
084: public String toString() {
085: String value;
086:
087: value = getData();
088: if (value.length() > 64) {
089: value = value.substring(0, 64) + "..";
090: }
091: value = value.replace('\n', '|');
092: return "Comment node: [" + value + "]";
093: }
094:
095: /**
096: * Hidden constructor.
097: *
098: * @param owner The owner of this document
099: * @param comment Comment text
100: */
101: public CommentImpl(DocumentImpl owner, String comment) {
102: super ();
103: super .init(owner, "#comment", comment);
104: }
105:
106: public CommentImpl() {
107: super ();
108: }
109:
110: public final void init(DocumentProxy owner, String comment) {
111: super .init(owner, "#comment", comment);
112: }
113:
114: }
|