001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the "License"). You may not use this file except
005: * in compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://jwsdp.dev.java.net/CDDLv1.0.html
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * HEADER in each file and include the License file at
014: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
015: * add the following below this CDDL HEADER, with the
016: * fields enclosed by brackets "[]" replaced with your
017: * own identifying information: Portions Copyright [yyyy]
018: * [name of copyright owner]
019: */
020: /*
021: * $Id: SOAPDocumentImpl.java,v 1.2 2007/07/16 16:41:22 ofung Exp $
022: */
023:
024: /*
025: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
026: *
027: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
028: *
029: * The contents of this file are subject to the terms of either the GNU
030: * General Public License Version 2 only ("GPL") or the Common Development
031: * and Distribution License("CDDL") (collectively, the "License"). You
032: * may not use this file except in compliance with the License. You can obtain
033: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
034: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
035: * language governing permissions and limitations under the License.
036: *
037: * When distributing the software, include this License Header Notice in each
038: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
039: * Sun designates this particular file as subject to the "Classpath" exception
040: * as provided by Sun in the GPL Version 2 section of the License file that
041: * accompanied this code. If applicable, add the following below the License
042: * Header, with the fields enclosed by brackets [] replaced by your own
043: * identifying information: "Portions Copyrighted [year]
044: * [name of copyright owner]"
045: *
046: * Contributor(s):
047: *
048: * If you wish your version of this file to be governed by only the CDDL or
049: * only the GPL Version 2, indicate your decision by adding "[Contributor]
050: * elects to include this software in this distribution under the [CDDL or GPL
051: * Version 2] license." If you don't indicate a single choice of license, a
052: * recipient has the option to distribute your version of this file under
053: * either the CDDL, the GPL Version 2 or to extend the choice of license to
054: * its licensees as provided above. However, if you add GPL Version 2 code
055: * and therefore, elected the GPL Version 2 license, then the option applies
056: * only if the new code is made subject to such option by the copyright
057: * holder.
058: */
059:
060: /**
061: *
062: * @author SAAJ RI Development Team
063: */package com.sun.xml.messaging.saaj.soap;
064:
065: import java.util.logging.Logger;
066:
067: import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
068: import org.w3c.dom.*;
069:
070: import com.sun.xml.messaging.saaj.soap.impl.*;
071: import com.sun.xml.messaging.saaj.soap.name.NameImpl;
072: import com.sun.xml.messaging.saaj.util.LogDomainConstants;
073:
074: public class SOAPDocumentImpl extends DocumentImpl implements
075: SOAPDocument {
076:
077: protected static Logger log = Logger.getLogger(
078: LogDomainConstants.SOAP_DOMAIN,
079: "com.sun.xml.messaging.saaj.soap.LocalStrings");
080:
081: SOAPPartImpl enclosingSOAPPart;
082:
083: public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) {
084: this .enclosingSOAPPart = enclosingDocument;
085: }
086:
087: // public SOAPDocumentImpl(boolean grammarAccess) {
088: // super(grammarAccess);
089: // }
090: //
091: // public SOAPDocumentImpl(DocumentType doctype) {
092: // super(doctype);
093: // }
094: //
095: // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) {
096: // super(doctype, grammarAccess);
097: // }
098:
099: public SOAPPartImpl getSOAPPart() {
100: if (enclosingSOAPPart == null) {
101: log.severe("SAAJ0541.soap.fragment.not.bound.to.part");
102: throw new RuntimeException(
103: "Could not complete operation. Fragment not bound to SOAP part.");
104: }
105: return enclosingSOAPPart;
106: }
107:
108: public SOAPDocumentImpl getDocument() {
109: return this ;
110: }
111:
112: public DocumentType getDoctype() {
113: // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?)
114: return null;
115: }
116:
117: public DOMImplementation getImplementation() {
118: return super .getImplementation();
119: }
120:
121: public Element getDocumentElement() {
122: // This had better be an Envelope!
123: getSOAPPart().doGetDocumentElement();
124: return doGetDocumentElement();
125: }
126:
127: protected Element doGetDocumentElement() {
128: return super .getDocumentElement();
129: }
130:
131: public Element createElement(String tagName) throws DOMException {
132: return ElementFactory.createElement(this , NameImpl
133: .getLocalNameFromTagName(tagName), NameImpl
134: .getPrefixFromTagName(tagName), null);
135: }
136:
137: public DocumentFragment createDocumentFragment() {
138: return new SOAPDocumentFragment(this );
139: }
140:
141: public org.w3c.dom.Text createTextNode(String data) {
142: return new TextImpl(this , data);
143: }
144:
145: public Comment createComment(String data) {
146: return new CommentImpl(this , data);
147: }
148:
149: public CDATASection createCDATASection(String data)
150: throws DOMException {
151: return new CDATAImpl(this , data);
152: }
153:
154: public ProcessingInstruction createProcessingInstruction(
155: String target, String data) throws DOMException {
156: log
157: .severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs");
158: throw new UnsupportedOperationException(
159: "Processing Instructions are not allowed in SOAP documents");
160: }
161:
162: public Attr createAttribute(String name) throws DOMException {
163: return super .createAttribute(name);
164: }
165:
166: public EntityReference createEntityReference(String name)
167: throws DOMException {
168: log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs");
169: throw new UnsupportedOperationException(
170: "Entity References are not allowed in SOAP documents");
171: }
172:
173: public NodeList getElementsByTagName(String tagname) {
174: return super .getElementsByTagName(tagname);
175: }
176:
177: public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
178: throws DOMException {
179: return super .importNode(importedNode, deep);
180: }
181:
182: public Element createElementNS(String namespaceURI,
183: String qualifiedName) throws DOMException {
184: return ElementFactory.createElement(this , NameImpl
185: .getLocalNameFromTagName(qualifiedName), NameImpl
186: .getPrefixFromTagName(qualifiedName), namespaceURI);
187: }
188:
189: public Attr createAttributeNS(String namespaceURI,
190: String qualifiedName) throws DOMException {
191: return super .createAttributeNS(namespaceURI, qualifiedName);
192: }
193:
194: public NodeList getElementsByTagNameNS(String namespaceURI,
195: String localName) {
196: return super .getElementsByTagNameNS(namespaceURI, localName);
197: }
198:
199: public Element getElementById(String elementId) {
200: return super .getElementById(elementId);
201: }
202:
203: public Node cloneNode(boolean deep) {
204: SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode();
205: super .cloneNode(newSoapPart.getDocument(), deep);
206: return newSoapPart;
207: }
208:
209: public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) {
210: super.cloneNode(newdoc, deep);
211: }
212: }
|