KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > XMLDocument


1 /**
2  * org/ozone-db/xml/XMLDocument.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;
27
28 import org.w3c.dom.*;
29 import org.ozoneDB.xml.dom.*;
30
31
32 /**
33  * Base class for user XML document. In addition to several API extensions, user
34  * XML documents can be used to map XML documents directly into application data
35  * structures, with the aid of user elements ({@link XMLElement}).
36  * <P>
37  * {@link XMLDocument} extends the DOM {@link org.w3c.dom.Document} with the
38  * following methods:
39  * <UL>
40  * <LI>{@link #setReadOnly} renders a full document read-only preventing any
41  * changes to it's documet contents
42  * <LI>{@link #registerElement} associates tag names with user element classes
43  * that derive from {@link XMLElement}
44  * </UL>
45  * <P>
46  * Documents of specific type can be created safely by passing the document class
47  * to {@link DOMFactory#createDocument}. They are supported by the built in XML
48  * parser, printer and processor. User documents are also supported by {@link
49  * org.openxml.source.Source} through use of the <TT>docClass</TT> property.
50  * <P>
51  * A user document derived from {@link XMLDocument} must be declared public and
52  * the constructor must be public. User elements should be registered in the
53  * constructor, and read-only status should be obeyed by calling {@link
54  * XMLDocument#isReadOnly}.
55  *
56  *
57  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
58  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
59  * @see org.w3c.dom.Document
60  * @see XMLElement
61  * @see org.ozoneDB.xml.core.XMLCollection
62  * @see XMLElementFactory
63  * @deprecated Alternative API will be introduced in OpenXML 1.1
64  */

65 public class XMLDocument extends DocumentImpl implements XMLDocumentProxy {
66
67
68     /**
69      * Default constructor.
70      */

71     public XMLDocument() {
72         super();
73         // this.registerElement( "MyTag", MyElement.class );
74
}
75
76
77     public Object JavaDoc clone() {
78         XMLDocumentProxy clone = null;
79         try {
80             clone = (XMLDocumentProxy)database().createObject( XMLDocument.class.getName() );
81             cloneInto( (NodeProxy)clone, true );
82         } catch (Exception JavaDoc except) {
83             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
84         }
85         return clone;
86     }
87
88
89     public Node cloneNode( boolean deep ) {
90         XMLDocumentProxy clone = null;
91         try {
92             clone = (XMLDocumentProxy)database().createObject( XMLDocument.class.getName() );
93             cloneInto( (NodeProxy)clone, deep );
94         } catch (Exception JavaDoc except) {
95             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
96         }
97         return clone;
98     }
99 }
100
Popular Tags