KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * org/ozone-db/xml/dom/DocumentFragmentImpl.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 lightweight or minimal {@link org.w3c.dom.Document}.
33  * Primarily used to carry document parts from one document to another,
34  * or to hold impartial documents without maintaining any {@link
35  * org.w3c.dom.Document} consistency rules on them.
36  * <P>
37  * Notes:
38  * <OL>
39  * <LI>Node type is {@link org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE}
40  * <LI>Node supports childern
41  * <LI>Node name is always "#document-fragment"
42  * <LI>Node does not have a value
43  * <LI>Special rules apply when adding fragment to other nodes (see
44  * {@link org.w3c.dom.Node#appendChild}).
45  * </OL>
46  *
47  *
48  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
49  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
50  * @see org.w3c.dom.DocumentFragment
51  * @see NodeImpl
52  */

53 public final class DocumentFragmentImpl extends NodeImpl implements DocumentFragmentProxy {
54
55     final static long serialVersionUID = 1;
56
57
58     public short getNodeType() {
59         return DOCUMENT_FRAGMENT_NODE;
60     }
61
62
63     public final void setNodeValue( String JavaDoc value ) {
64         throw new DOMExceptionImpl( DOMException.NO_DATA_ALLOWED_ERR, "This node type does not support values." );
65     }
66
67
68     protected boolean supportsChildern() {
69         return true;
70     }
71
72
73     public final Object JavaDoc clone() {
74         TextProxy clone = null;
75         try {
76             clone = (TextProxy)database().createObject( TextImpl.class.getName() );
77             clone.init( _ownerDocument, getNodeValue() );
78             cloneInto( clone, true );
79         } catch (Exception JavaDoc except) {
80             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
81         }
82         return clone;
83     }
84
85
86     public final Node cloneNode( boolean deep ) {
87         TextProxy clone = null;
88         try {
89             clone = (TextProxy)database().createObject( TextImpl.class.getName() );
90             clone.init( _ownerDocument, getNodeValue() );
91             cloneInto( clone, deep );
92         } catch (Exception JavaDoc except) {
93             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
94         }
95         return clone;
96     }
97
98
99     public String JavaDoc toString() {
100         return "Document Fragment (" + getChildCount() + " nodes)";
101     }
102
103
104     /**
105      * Constructor requires only document owner.
106      */

107     DocumentFragmentImpl( DocumentImpl owner ) {
108         super( owner, "#document-fragment", null, false );
109     }
110
111
112     public DocumentFragmentImpl() {
113         super();
114     }
115
116
117     public final void init( DocumentProxy owner, String JavaDoc value ) {
118         super.init( owner, "#document-fragment", value, false );
119     }
120
121 }
122
Popular Tags