-
Notifications
You must be signed in to change notification settings - Fork 15
/
DetailImpl.java
122 lines (103 loc) · 3.58 KB
/
DetailImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.xml.messaging.saaj.soap.impl;
import java.util.Iterator;
import java.util.NoSuchElementException;
import javax.xml.namespace.QName;
import jakarta.xml.soap.*;
import org.w3c.dom.Element;
import com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.messaging.saaj.soap.name.NameImpl;
public abstract class DetailImpl extends FaultElementImpl implements Detail {
protected DetailImpl(SOAPDocumentImpl ownerDoc, NameImpl detailName) {
super(ownerDoc, detailName);
}
protected DetailImpl(SOAPDocumentImpl ownerDoc, Element domElement) {
super(ownerDoc, domElement);
}
protected abstract DetailEntry createDetailEntry(Name name);
protected abstract DetailEntry createDetailEntry(QName name);
@Override
public DetailEntry addDetailEntry(Name name) throws SOAPException {
DetailEntry entry = createDetailEntry(name);
addNode(entry);
return entry;
}
@Override
public DetailEntry addDetailEntry(QName qname) throws SOAPException {
DetailEntry entry = createDetailEntry(qname);
addNode(entry);
return entry;
}
@Override
protected SOAPElement addElement(Name name) throws SOAPException {
return addDetailEntry(name);
}
@Override
protected SOAPElement addElement(QName name) throws SOAPException {
return addDetailEntry(name);
}
@Override
protected SOAPElement convertToSoapElement(Element element) {
final jakarta.xml.soap.Node soapNode = getSoapDocument().find(element);
if (soapNode instanceof DetailEntry) {
return (SOAPElement) soapNode;
} else {
DetailEntry detailEntry =
createDetailEntry(NameImpl.copyElementName(element));
return replaceElementWithSOAPElement(
element,
(ElementImpl) detailEntry);
}
}
@Override
public Iterator<DetailEntry> getDetailEntries() {
return new Iterator<DetailEntry>() {
Iterator<org.w3c.dom.Node> eachNode = getChildElementNodes();
SOAPElement next = null;
SOAPElement last = null;
@Override
public boolean hasNext() {
if (next == null) {
while (eachNode.hasNext()) {
next = (SOAPElement) eachNode.next();
if (next instanceof DetailEntry) {
break;
}
next = null;
}
}
return next != null;
}
@Override
public DetailEntry next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
last = next;
next = null;
return (DetailEntry) last;
}
@Override
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
SOAPElement target = last;
removeChild(target);
last = null;
}
};
}
@Override
protected boolean isStandardFaultElement() {
return true;
}
}