001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.dom;
019:
020: import java.io.IOException;
021: import java.io.NotSerializableException;
022: import java.io.ObjectInputStream;
023: import java.io.ObjectOutputStream;
024: import org.w3c.dom.DOMConfiguration;
025: import org.w3c.dom.UserDataHandler;
026: import org.w3c.dom.*;
027:
028: /**
029: * Our own document implementation, which knows how to create an element
030: * with PSVI information.
031: *
032: * @xerces.internal
033: *
034: * @author Sandy Gao, IBM
035: *
036: * @version $Id: PSVIDocumentImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
037: */
038: public class PSVIDocumentImpl extends DocumentImpl {
039:
040: /** Serialization version. */
041: static final long serialVersionUID = -8822220250676434522L;
042:
043: /**
044: * Create a document.
045: */
046: public PSVIDocumentImpl() {
047: super ();
048: }
049:
050: /**
051: * For DOM2 support.
052: * The createDocument factory method is in DOMImplementation.
053: */
054: public PSVIDocumentImpl(DocumentType doctype) {
055: super (doctype);
056: }
057:
058: /**
059: * Deep-clone a document, including fixing ownerDoc for the cloned
060: * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR
061: * protection. I've chosen to implement it by calling importNode
062: * which is DOM Level 2.
063: *
064: * @return org.w3c.dom.Node
065: * @param deep boolean, iff true replicate children
066: */
067: public Node cloneNode(boolean deep) {
068:
069: PSVIDocumentImpl newdoc = new PSVIDocumentImpl();
070: callUserDataHandlers(this , newdoc, UserDataHandler.NODE_CLONED);
071: cloneNode(newdoc, deep);
072:
073: // experimental
074: newdoc.mutationEvents = mutationEvents;
075:
076: return newdoc;
077:
078: } // cloneNode(boolean):Node
079:
080: /**
081: * Retrieve information describing the abilities of this particular
082: * DOM implementation. Intended to support applications that may be
083: * using DOMs retrieved from several different sources, potentially
084: * with different underlying representations.
085: */
086: public DOMImplementation getImplementation() {
087: // Currently implemented as a singleton, since it's hardcoded
088: // information anyway.
089: return PSVIDOMImplementationImpl.getDOMImplementation();
090: }
091:
092: /**
093: * Create an element with PSVI information
094: */
095: public Element createElementNS(String namespaceURI,
096: String qualifiedName) throws DOMException {
097: return new PSVIElementNSImpl(this , namespaceURI, qualifiedName);
098: }
099:
100: /**
101: * Create an element with PSVI information
102: */
103: public Element createElementNS(String namespaceURI,
104: String qualifiedName, String localpart) throws DOMException {
105: return new PSVIElementNSImpl(this , namespaceURI, qualifiedName,
106: localpart);
107: }
108:
109: /**
110: * Create an attribute with PSVI information
111: */
112: public Attr createAttributeNS(String namespaceURI,
113: String qualifiedName) throws DOMException {
114: return new PSVIAttrNSImpl(this , namespaceURI, qualifiedName);
115: }
116:
117: /**
118: * Create an attribute with PSVI information
119: */
120: public Attr createAttributeNS(String namespaceURI,
121: String qualifiedName, String localName) throws DOMException {
122: return new PSVIAttrNSImpl(this , namespaceURI, qualifiedName,
123: localName);
124: }
125:
126: /**
127: *
128: * The configuration used when <code>Document.normalizeDocument</code> is
129: * invoked.
130: * @since DOM Level 3
131: */
132: public DOMConfiguration getDomConfig() {
133: super .getDomConfig();
134: return fConfiguration;
135: }
136:
137: // REVISIT: Forbid serialization of PSVI DOM until
138: // we support object serialization of grammars -- mrglavas
139:
140: private void writeObject(ObjectOutputStream out) throws IOException {
141: throw new NotSerializableException(getClass().getName());
142: }
143:
144: private void readObject(ObjectInputStream in) throws IOException,
145: ClassNotFoundException {
146: throw new NotSerializableException(getClass().getName());
147: }
148:
149: } // class PSVIDocumentImpl
|