KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > PSVIDocumentImpl


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.dom;
18
19 import java.io.IOException JavaDoc;
20 import java.io.NotSerializableException JavaDoc;
21 import java.io.ObjectInputStream JavaDoc;
22 import java.io.ObjectOutputStream JavaDoc;
23 import org.w3c.dom.DOMConfiguration JavaDoc;
24 import org.w3c.dom.UserDataHandler JavaDoc;
25 import org.w3c.dom.*;
26
27 /**
28  * Our own document implementation, which knows how to create an element
29  * with PSVI information.
30  *
31  * @xerces.internal
32  *
33  * @author Sandy Gao, IBM
34  *
35  * @version $Id: PSVIDocumentImpl.java,v 1.12 2005/05/02 22:03:58 mrglavas Exp $
36  */

37 public class PSVIDocumentImpl extends DocumentImpl {
38    
39     /** Serialization version. */
40     static final long serialVersionUID = -8822220250676434522L;
41
42     /**
43      * Create a document.
44      */

45     public PSVIDocumentImpl() {
46         super();
47     }
48
49     /**
50      * For DOM2 support.
51      * The createDocument factory method is in DOMImplementation.
52      */

53     public PSVIDocumentImpl(DocumentType doctype) {
54         super(doctype);
55     }
56     
57     /**
58      * Deep-clone a document, including fixing ownerDoc for the cloned
59      * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR
60      * protection. I've chosen to implement it by calling importNode
61      * which is DOM Level 2.
62      *
63      * @return org.w3c.dom.Node
64      * @param deep boolean, iff true replicate children
65      */

66     public Node cloneNode(boolean deep) {
67
68         PSVIDocumentImpl newdoc = new PSVIDocumentImpl();
69         callUserDataHandlers(this, newdoc, UserDataHandler.NODE_CLONED);
70         cloneNode(newdoc, deep);
71
72         // experimental
73
newdoc.mutationEvents = mutationEvents;
74
75         return newdoc;
76
77     } // cloneNode(boolean):Node
78

79     /**
80      * Retrieve information describing the abilities of this particular
81      * DOM implementation. Intended to support applications that may be
82      * using DOMs retrieved from several different sources, potentially
83      * with different underlying representations.
84      */

85     public DOMImplementation getImplementation() {
86         // Currently implemented as a singleton, since it's hardcoded
87
// information anyway.
88
return PSVIDOMImplementationImpl.getDOMImplementation();
89     }
90
91     /**
92      * Create an element with PSVI information
93      */

94     public Element createElementNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName)
95         throws DOMException {
96         return new PSVIElementNSImpl(this, namespaceURI, qualifiedName);
97     }
98
99     /**
100      * Create an element with PSVI information
101      */

102     public Element createElementNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName,
103                                    String JavaDoc localpart) throws DOMException {
104         return new PSVIElementNSImpl(this, namespaceURI, qualifiedName, localpart);
105     }
106
107     /**
108      * Create an attribute with PSVI information
109      */

110     public Attr createAttributeNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName)
111         throws DOMException {
112         return new PSVIAttrNSImpl(this, namespaceURI, qualifiedName);
113     }
114     
115     /**
116      * Create an attribute with PSVI information
117      */

118     public Attr createAttributeNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName,
119                                   String JavaDoc localName) throws DOMException {
120         return new PSVIAttrNSImpl(this, namespaceURI, qualifiedName, localName);
121     }
122     
123     /**
124      *
125      * The configuration used when <code>Document.normalizeDocument</code> is
126      * invoked.
127      * @since DOM Level 3
128      */

129     public DOMConfiguration JavaDoc getDomConfig(){
130         super.getDomConfig();
131         return fConfiguration;
132     }
133     
134     // REVISIT: Forbid serialization of PSVI DOM until
135
// we support object serialization of grammars -- mrglavas
136

137     private void writeObject(ObjectOutputStream JavaDoc out)
138         throws IOException JavaDoc {
139         throw new NotSerializableException JavaDoc(getClass().getName());
140     }
141
142     private void readObject(ObjectInputStream JavaDoc in)
143         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
144         throw new NotSerializableException JavaDoc(getClass().getName());
145     }
146     
147 } // class PSVIDocumentImpl
148
Popular Tags