KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom > CommentImpl


1 /**
2  * org/ozone-db/xml/dom/CommentImpl.java
3  *
4  * The contents of this file are subject to the OpenXML Public
5  * License Version 1.0; you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at
7  * http://www.openxml.org/license.html
8  *
9  * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
10  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
11  * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
12  * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
13  * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
14  * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
15  *
16  * The Initial Developer of this code under the License is Assaf Arkin.
17  * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
18  * All Rights Reserved.
19  */

20
21 /**
22  * Changes for Persistent DOM running with ozone are
23  * Copyright 1999 by SMB GmbH. All rights reserved.
24  */

25
26 package org.ozoneDB.xml.dom;
27
28 import org.w3c.dom.*;
29
30
31 /**
32  * Implements a {@link org.w3c.dom.Comment} object. This is a text data object
33  * whose value can be manipulated using the {@link org.w3c.dom.CharacterData}\
34  * interface and does not support children.
35  * <P>
36  * Notes:
37  * <OL>
38  * <LI>Node type is {@link org.w3c.dom.Node#COMMENT_NODE}
39  * <LI>Node does not support childern
40  * <LI>Node name is always "#comment"
41  * </OL>
42  *
43  *
44  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
45  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
46  * @see org.w3c.dom.Comment
47  * @see CharacterDataImpl
48  */

49 public final class CommentImpl extends CharacterDataImpl implements CommentProxy {
50
51     final static long serialVersionUID = 1;
52
53
54     public short getNodeType() {
55         return COMMENT_NODE;
56     }
57
58
59     public final Object JavaDoc clone() {
60         CommentProxy clone = null;
61         try {
62             clone = (CommentProxy)database().createObject( CommentImpl.class.getName() );
63             clone.init( _ownerDocument, getNodeValue() );
64             cloneInto( clone, true );
65         } catch (Exception JavaDoc except) {
66             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
67         }
68         return clone;
69     }
70
71
72     public final Node cloneNode( boolean deep ) {
73         CommentProxy clone = null;
74         try {
75             clone = (CommentProxy)database().createObject( CommentImpl.class.getName() );
76             clone.init( _ownerDocument, getNodeValue() );
77             cloneInto( clone, deep );
78         } catch (Exception JavaDoc except) {
79             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
80         }
81         return clone;
82     }
83
84
85     public String JavaDoc toString() {
86         String JavaDoc value;
87
88         value = getData();
89         if (value.length() > 64) {
90             value = value.substring( 0, 64 ) + "..";
91         }
92         value = value.replace( '\n', '|' );
93         return "Comment node: [" + value + "]";
94     }
95
96
97     /**
98      * Hidden constructor.
99      *
100      * @param owner The owner of this document
101      * @param comment Comment text
102      */

103     public CommentImpl( DocumentImpl owner, String JavaDoc comment ) {
104         super();
105         super.init( owner, "#comment", comment );
106     }
107
108
109     public CommentImpl() {
110         super();
111     }
112
113
114     public final void init( DocumentProxy owner, String JavaDoc comment ) {
115         super.init( owner, "#comment", comment );
116     }
117
118 }
119
Popular Tags