Thu, 12 Jan 2017 00:25:07 +0300
8159058: SAXParseException when sending soap message
Reviewed-by: lancea, coffeys
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.messaging.saaj.soap.impl;
28 import java.util.Iterator;
29 import java.util.NoSuchElementException;
31 import javax.xml.namespace.QName;
32 import javax.xml.soap.*;
34 import org.w3c.dom.Element;
36 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
37 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
39 public abstract class DetailImpl extends FaultElementImpl implements Detail {
40 public DetailImpl(SOAPDocumentImpl ownerDoc, NameImpl detailName) {
41 super(ownerDoc, detailName);
42 }
44 protected abstract DetailEntry createDetailEntry(Name name);
45 protected abstract DetailEntry createDetailEntry(QName name);
47 public DetailEntry addDetailEntry(Name name) throws SOAPException {
48 DetailEntry entry = createDetailEntry(name);
49 addNode(entry);
50 return entry;
51 }
53 public DetailEntry addDetailEntry(QName qname) throws SOAPException {
54 DetailEntry entry = createDetailEntry(qname);
55 addNode(entry);
56 return entry;
57 }
59 protected SOAPElement addElement(Name name) throws SOAPException {
60 return addDetailEntry(name);
61 }
63 protected SOAPElement addElement(QName name) throws SOAPException {
64 return addDetailEntry(name);
65 }
67 protected SOAPElement convertToSoapElement(Element element) {
68 if (element instanceof DetailEntry) {
69 return (SOAPElement) element;
70 } else {
71 DetailEntry detailEntry =
72 createDetailEntry(NameImpl.copyElementName(element));
73 return replaceElementWithSOAPElement(
74 element,
75 (ElementImpl) detailEntry);
76 }
77 }
79 public Iterator getDetailEntries() {
80 return new Iterator() {
81 Iterator eachNode = getChildElementNodes();
82 SOAPElement next = null;
83 SOAPElement last = null;
85 public boolean hasNext() {
86 if (next == null) {
87 while (eachNode.hasNext()) {
88 next = (SOAPElement) eachNode.next();
89 if (next instanceof DetailEntry) {
90 break;
91 }
92 next = null;
93 }
94 }
95 return next != null;
96 }
98 public Object next() {
99 if (!hasNext()) {
100 throw new NoSuchElementException();
101 }
102 last = next;
103 next = null;
104 return last;
105 }
107 public void remove() {
108 if (last == null) {
109 throw new IllegalStateException();
110 }
111 SOAPElement target = last;
112 removeChild(target);
113 last = null;
114 }
115 };
116 }
118 protected boolean isStandardFaultElement() {
119 return true;
120 }
122 }