01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.soap.saaj;
18:
19: import java.util.Iterator;
20: import javax.xml.namespace.QName;
21: import javax.xml.soap.Detail;
22: import javax.xml.soap.DetailEntry;
23: import javax.xml.soap.SOAPException;
24: import javax.xml.soap.SOAPFaultElement;
25: import javax.xml.transform.Result;
26:
27: import org.springframework.util.Assert;
28: import org.springframework.ws.soap.SoapFaultDetail;
29: import org.springframework.ws.soap.SoapFaultDetailElement;
30:
31: /**
32: * SAAJ-specific implementation of the <code>SoapFaultDetail</code> interface. Wraps a {@link
33: * javax.xml.soap.SOAPFaultElement}.
34: *
35: * @author Arjen Poutsma
36: * @since 1.0.0
37: */
38: class SaajSoapFaultDetail extends SaajSoapElement implements
39: SoapFaultDetail {
40:
41: public SaajSoapFaultDetail(SOAPFaultElement faultElement) {
42: super (faultElement);
43: }
44:
45: public Result getResult() {
46: return getImplementation().getResult(getSaajDetail());
47: }
48:
49: public SoapFaultDetailElement addFaultDetailElement(QName name) {
50: try {
51: DetailEntry detailEntry = getImplementation()
52: .addDetailEntry(getSaajDetail(), name);
53: return new SaajSoapFaultDetailElement(detailEntry);
54: } catch (SOAPException ex) {
55: throw new SaajSoapFaultException(ex);
56: }
57: }
58:
59: public Iterator getDetailEntries() {
60: Iterator iterator = getImplementation().getDetailEntries(
61: getSaajDetail());
62: return new SaajSoapFaultDetailElementIterator(iterator);
63: }
64:
65: protected Detail getSaajDetail() {
66: return (Detail) getSaajElement();
67: }
68:
69: private static class SaajSoapFaultDetailElementIterator implements
70: Iterator {
71:
72: private final Iterator iterator;
73:
74: private SaajSoapFaultDetailElementIterator(Iterator iterator) {
75: Assert.notNull(iterator, "No iterator given");
76: this .iterator = iterator;
77: }
78:
79: public boolean hasNext() {
80: return iterator.hasNext();
81: }
82:
83: public Object next() {
84: DetailEntry saajDetailEntry = (DetailEntry) iterator.next();
85: return new SaajSoapFaultDetailElement(saajDetailEntry);
86: }
87:
88: public void remove() {
89: iterator.remove();
90: }
91: }
92:
93: }
|