src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java

changeset 1
0961a4a21176
child 45
31822b475baa
equal deleted inserted replaced
-1:000000000000 1:0961a4a21176
1 /*
2 * $Id: SOAPDocumentImpl.java,v 1.15 2006/01/27 12:49:29 vj135062 Exp $
3 */
4
5 /*
6 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 *
9 * This code is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 only, as
11 * published by the Free Software Foundation. Sun designates this
12 * particular file as subject to the "Classpath" exception as provided
13 * by Sun in the LICENSE file that accompanied this code.
14 *
15 * This code is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * version 2 for more details (a copy is included in the LICENSE file that
19 * accompanied this code).
20 *
21 * You should have received a copy of the GNU General Public License version
22 * 2 along with this work; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
26 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * have any questions.
28 */
29
30 /**
31 *
32 * @author SAAJ RI Development Team
33 */
34 package com.sun.xml.internal.messaging.saaj.soap;
35
36 import java.util.logging.Logger;
37
38 import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
39 import org.w3c.dom.*;
40
41 import com.sun.xml.internal.messaging.saaj.soap.impl.*;
42 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
43 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
44
45 public class SOAPDocumentImpl extends DocumentImpl implements SOAPDocument {
46
47 protected static Logger log =
48 Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
49 "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
50
51 SOAPPartImpl enclosingSOAPPart;
52
53 public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) {
54 this.enclosingSOAPPart = enclosingDocument;
55 }
56
57 // public SOAPDocumentImpl(boolean grammarAccess) {
58 // super(grammarAccess);
59 // }
60 //
61 // public SOAPDocumentImpl(DocumentType doctype) {
62 // super(doctype);
63 // }
64 //
65 // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) {
66 // super(doctype, grammarAccess);
67 // }
68
69 public SOAPPartImpl getSOAPPart() {
70 if (enclosingSOAPPart == null) {
71 log.severe("SAAJ0541.soap.fragment.not.bound.to.part");
72 throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part.");
73 }
74 return enclosingSOAPPart;
75 }
76
77 public SOAPDocumentImpl getDocument() {
78 return this;
79 }
80
81 public DocumentType getDoctype() {
82 // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?)
83 return null;
84 }
85
86 public DOMImplementation getImplementation() {
87 return super.getImplementation();
88 }
89
90 public Element getDocumentElement() {
91 // This had better be an Envelope!
92 getSOAPPart().doGetDocumentElement();
93 return doGetDocumentElement();
94 }
95
96 protected Element doGetDocumentElement() {
97 return super.getDocumentElement();
98 }
99
100 public Element createElement(String tagName) throws DOMException {
101 return ElementFactory.createElement(
102 this,
103 NameImpl.getLocalNameFromTagName(tagName),
104 NameImpl.getPrefixFromTagName(tagName),
105 null);
106 }
107
108 public DocumentFragment createDocumentFragment() {
109 return new SOAPDocumentFragment(this);
110 }
111
112 public org.w3c.dom.Text createTextNode(String data) {
113 return new TextImpl(this, data);
114 }
115
116 public Comment createComment(String data) {
117 return new CommentImpl(this, data);
118 }
119
120 public CDATASection createCDATASection(String data) throws DOMException {
121 return new CDATAImpl(this, data);
122 }
123
124 public ProcessingInstruction createProcessingInstruction(
125 String target,
126 String data)
127 throws DOMException {
128 log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs");
129 throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents");
130 }
131
132 public Attr createAttribute(String name) throws DOMException {
133 return super.createAttribute(name);
134 }
135
136 public EntityReference createEntityReference(String name)
137 throws DOMException {
138 log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs");
139 throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents");
140 }
141
142 public NodeList getElementsByTagName(String tagname) {
143 return super.getElementsByTagName(tagname);
144 }
145
146 public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
147 throws DOMException {
148 return super.importNode(importedNode, deep);
149 }
150
151 public Element createElementNS(String namespaceURI, String qualifiedName)
152 throws DOMException {
153 return ElementFactory.createElement(
154 this,
155 NameImpl.getLocalNameFromTagName(qualifiedName),
156 NameImpl.getPrefixFromTagName(qualifiedName),
157 namespaceURI);
158 }
159
160 public Attr createAttributeNS(String namespaceURI, String qualifiedName)
161 throws DOMException {
162 return super.createAttributeNS(namespaceURI, qualifiedName);
163 }
164
165 public NodeList getElementsByTagNameNS(
166 String namespaceURI,
167 String localName) {
168 return super.getElementsByTagNameNS(namespaceURI, localName);
169 }
170
171 public Element getElementById(String elementId) {
172 return super.getElementById(elementId);
173 }
174
175 public Node cloneNode(boolean deep) {
176 SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode();
177 super.cloneNode(newSoapPart.getDocument(), deep);
178 return newSoapPart;
179 }
180
181 public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) {
182 super.cloneNode(newdoc, deep);
183 }
184 }

mercurial