Save This Page
Home » openjdk-7 » com.sun.org.apache.xerces.internal » dom » [javadoc | source]
    1   /*
    2    * reserved comment block
    3    * DO NOT REMOVE OR ALTER!
    4    */
    5   /*
    6    * Copyright 2002-2004 The Apache Software Foundation.
    7    *
    8    * Licensed under the Apache License, Version 2.0 (the "License");
    9    * you may not use this file except in compliance with the License.
   10    * You may obtain a copy of the License at
   11    *
   12    *      http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing, software
   15    * distributed under the License is distributed on an "AS IS" BASIS,
   16    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   17    * See the License for the specific language governing permissions and
   18    * limitations under the License.
   19    */
   20   
   21   package com.sun.org.apache.xerces.internal.dom;
   22   
   23   import java.io.IOException;
   24   import java.io.NotSerializableException;
   25   import java.io.ObjectInputStream;
   26   import java.io.ObjectOutputStream;
   27   import org.w3c.dom.DOMConfiguration;
   28   import org.w3c.dom.UserDataHandler;
   29   import org.w3c.dom;
   30   
   31   /**
   32    * Our own document implementation, which knows how to create an element
   33    * with PSVI information.
   34    *
   35    * @xerces.internal
   36    *
   37    * @author Sandy Gao, IBM
   38    *
   39    */
   40   public class PSVIDocumentImpl extends DocumentImpl {
   41   
   42       /** Serialization version. */
   43       static final long serialVersionUID = -8822220250676434522L;
   44   
   45       /**
   46        * Create a document.
   47        */
   48       public PSVIDocumentImpl() {
   49           super();
   50       }
   51   
   52       /**
   53        * For DOM2 support.
   54        * The createDocument factory method is in DOMImplementation.
   55        */
   56       public PSVIDocumentImpl(DocumentType doctype) {
   57           super(doctype);
   58       }
   59   
   60       /**
   61        * Deep-clone a document, including fixing ownerDoc for the cloned
   62        * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR
   63        * protection. I've chosen to implement it by calling importNode
   64        * which is DOM Level 2.
   65        *
   66        * @return org.w3c.dom.Node
   67        * @param deep boolean, iff true replicate children
   68        */
   69       public Node cloneNode(boolean deep) {
   70   
   71           PSVIDocumentImpl newdoc = new PSVIDocumentImpl();
   72           callUserDataHandlers(this, newdoc, UserDataHandler.NODE_CLONED);
   73           cloneNode(newdoc, deep);
   74   
   75           // experimental
   76           newdoc.mutationEvents = mutationEvents;
   77   
   78           return newdoc;
   79   
   80       } // cloneNode(boolean):Node
   81   
   82       /**
   83        * Retrieve information describing the abilities of this particular
   84        * DOM implementation. Intended to support applications that may be
   85        * using DOMs retrieved from several different sources, potentially
   86        * with different underlying representations.
   87        */
   88       public DOMImplementation getImplementation() {
   89           // Currently implemented as a singleton, since it's hardcoded
   90           // information anyway.
   91           return PSVIDOMImplementationImpl.getDOMImplementation();
   92       }
   93   
   94       /**
   95        * Create an element with PSVI information
   96        */
   97       public Element createElementNS(String namespaceURI, String qualifiedName)
   98           throws DOMException {
   99           return new PSVIElementNSImpl(this, namespaceURI, qualifiedName);
  100       }
  101   
  102       /**
  103        * Create an element with PSVI information
  104        */
  105       public Element createElementNS(String namespaceURI, String qualifiedName,
  106                                      String localpart) throws DOMException {
  107           return new PSVIElementNSImpl(this, namespaceURI, qualifiedName, localpart);
  108       }
  109   
  110       /**
  111        * Create an attribute with PSVI information
  112        */
  113       public Attr createAttributeNS(String namespaceURI, String qualifiedName)
  114           throws DOMException {
  115           return new PSVIAttrNSImpl(this, namespaceURI, qualifiedName);
  116       }
  117   
  118       /**
  119        * Create an attribute with PSVI information
  120        */
  121       public Attr createAttributeNS(String namespaceURI, String qualifiedName,
  122                                     String localName) throws DOMException {
  123           return new PSVIAttrNSImpl(this, namespaceURI, qualifiedName, 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)
  141           throws IOException {
  142           throw new NotSerializableException(getClass().getName());
  143           }
  144   
  145       private void readObject(ObjectInputStream in)
  146           throws IOException, ClassNotFoundException {
  147           throw new NotSerializableException(getClass().getName());
  148       }
  149   
  150   } // class PSVIDocumentImpl

Save This Page
Home » openjdk-7 » com.sun.org.apache.xerces.internal » dom » [javadoc | source]