Skip to content

Package: SOAPFactoryImpl

SOAPFactoryImpl

nameinstructionbranchcomplexitylinemethod
SOAPFactoryImpl()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
convertToSoapElement(Element)
M: 0 C: 70
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 18
100%
M: 0 C: 1
100%
createDetail()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createElement(Element)
M: 2 C: 6
75%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
createElement(Name)
M: 19 C: 7
27%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 2
50%
M: 0 C: 1
100%
createElement(QName)
M: 19 C: 7
27%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 2
50%
M: 0 C: 1
100%
createElement(String)
M: 19 C: 8
30%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 3
60%
M: 0 C: 1
100%
createElement(String, String, String)
M: 19 C: 9
32%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 2
50%
M: 0 C: 1
100%
createFault()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createFault(String, QName)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createName(String)
M: 19 C: 5
21%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 2
50%
M: 0 C: 1
100%
createName(String, String, String)
M: 19 C: 7
27%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 2
50%
M: 0 C: 1
100%
static {...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.messaging.saaj.soap;
12:
13: import java.util.logging.Logger;
14: import java.util.logging.Level;
15:
16: import javax.xml.namespace.QName;
17: import jakarta.xml.soap.*;
18:
19: import com.sun.xml.messaging.saaj.soap.impl.ElementFactory;
20: import com.sun.xml.messaging.saaj.soap.name.NameImpl;
21: import com.sun.xml.messaging.saaj.util.*;
22:
23: import org.w3c.dom.Element;
24: import org.w3c.dom.Document;
25: import org.w3c.dom.NodeList;
26: import org.w3c.dom.NamedNodeMap;
27: import org.w3c.dom.Attr;
28:
29: public abstract class SOAPFactoryImpl extends SOAPFactory {
30:
31: private static final Logger
32: log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
33: "com.sun.xml.messaging.saaj.soap.LocalStrings");
34:
35: protected SOAPFactoryImpl() {}
36:
37: protected abstract SOAPDocumentImpl createDocument();
38:
39: @Override
40: public SOAPElement createElement(String tagName) throws SOAPException {
41:• if (tagName == null) {
42: log.log(
43: Level.SEVERE,"SAAJ0567.soap.null.input",
44: new Object[] {"tagName","SOAPFactory.createElement"});
45: throw new SOAPException("Null tagName argument passed to createElement");
46: }
47: return ElementFactory.createElement(createDocument(),
48: NameImpl.createFromTagName(tagName));
49: }
50:
51: @Override
52: public SOAPElement createElement(Name name) throws SOAPException {
53: // @since SAAJ 1.3
54: // If the Name was null it would cause a NullPointerException in earlier release
55:• if (name == null) {
56: log.log(Level.SEVERE,"SAAJ0567.soap.null.input",
57: new Object[] {"name","SOAPFactory.createElement"});
58: throw new SOAPException("Null name argument passed to createElement");
59: }
60: return ElementFactory.createElement(createDocument(), name);
61: }
62:
63: @Override
64: public SOAPElement createElement(QName qname) throws SOAPException {
65:• if (qname == null) {
66: log.log(Level.SEVERE,"SAAJ0567.soap.null.input",
67: new Object[] {"qname","SOAPFactory.createElement"});
68: throw new SOAPException("Null qname argument passed to createElement");
69: }
70: return ElementFactory.createElement(createDocument(),qname);
71: }
72:
73: @Override
74: public SOAPElement createElement(
75: String localName,
76: String prefix,
77: String uri) throws SOAPException {
78:
79: // @since SAAJ 1.3
80: // if prefix !=null but localName== null then in earlier releases it would create
81: // a Qualified Name <prefix>:null which is not meaningful
82:• if (localName == null) {
83: log.log(Level.SEVERE,"SAAJ0567.soap.null.input",
84: new Object[] {"localName","SOAPFactory.createElement"});
85: throw new SOAPException("Null localName argument passed to createElement");
86: }
87: return ElementFactory.createElement(createDocument(), localName, prefix, uri);
88: }
89:
90: @Override
91: public Name createName(String localName, String prefix, String uri)
92: throws SOAPException {
93: // @since SAAJ 1.3
94: // if localName==null, earlier impl would create Name with localName=""
95: // which is absurd.
96:• if (localName == null) {
97: log.log(
98: Level.SEVERE,"SAAJ0567.soap.null.input",
99: new Object[] {"localName","SOAPFactory.createName"});
100: throw new SOAPException("Null localName argument passed to createName");
101: }
102: return NameImpl.create(localName, prefix, uri);
103: }
104:
105: @Override
106: public Name createName(String localName) throws SOAPException {
107: // @since SAAJ 1.3
108: // if localName==null, earlier impl would create Name with localName=null
109: // which is absurd.
110:• if (localName == null) {
111: log.log(
112: Level.SEVERE,"SAAJ0567.soap.null.input",
113: new Object[] {"localName","SOAPFactory.createName"});
114: throw new SOAPException("Null localName argument passed to createName");
115: }
116: return NameImpl.createFromUnqualifiedName(localName);
117: }
118:
119: // Note: the child elements might still be org.w3c.dom.Element's, but the
120: // getChildElements will do the conversion to SOAPElement when called.
121: @Override
122: public SOAPElement createElement(Element domElement) throws SOAPException {
123:• if (domElement == null) {
124: return null;
125: }
126: return convertToSoapElement(domElement);
127: }
128:
129: private SOAPElement convertToSoapElement(Element element) throws SOAPException {
130:
131:• if (element instanceof SOAPElement) {
132: return (SOAPElement) element;
133: }
134:
135: SOAPElement copy = createElement(
136: element.getLocalName(),
137: element.getPrefix(),
138: element.getNamespaceURI());
139:
140: Document ownerDoc = copy.getOwnerDocument();
141:
142: NamedNodeMap attrMap = element.getAttributes();
143:• for (int i=0; i < attrMap.getLength(); i++) {
144: Attr nextAttr = (Attr)attrMap.item(i);
145: Attr importedAttr = (Attr)ownerDoc.importNode(nextAttr, true);
146: copy.setAttributeNodeNS(importedAttr);
147: }
148:
149:
150: NodeList nl = element.getChildNodes();
151:• for (int i=0; i < nl.getLength(); i++) {
152: org.w3c.dom.Node next = nl.item(i);
153: org.w3c.dom.Node imported = ownerDoc.importNode(next, true);
154: copy.appendChild(imported);
155: }
156:
157: return copy;
158: }
159:
160: @Override
161: public Detail createDetail() throws SOAPException {
162: throw new UnsupportedOperationException();
163: }
164:
165: @Override
166: public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException {
167: throw new UnsupportedOperationException();
168: }
169:
170: @Override
171: public SOAPFault createFault() throws SOAPException {
172: throw new UnsupportedOperationException();
173: }
174:
175: }