001: /*
002: * Copyright 2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.ws.soap.axiom;
018:
019: import java.util.Iterator;
020: import javax.xml.namespace.QName;
021: import javax.xml.transform.Result;
022: import javax.xml.transform.sax.SAXResult;
023:
024: import org.apache.axiom.om.OMElement;
025: import org.apache.axiom.om.OMException;
026: import org.apache.axiom.soap.SOAPFactory;
027: import org.apache.axiom.soap.SOAPFaultDetail;
028: import org.springframework.ws.soap.SoapFaultDetail;
029: import org.springframework.ws.soap.SoapFaultDetailElement;
030:
031: /**
032: * Axiom-specific version of <code>org.springframework.ws.soap.SoapFaultDetail</code>.
033: *
034: * @author Arjen Poutsma
035: * @since 1.0.0
036: */
037: class AxiomSoapFaultDetail extends AxiomSoapElement implements
038: SoapFaultDetail {
039:
040: public AxiomSoapFaultDetail(SOAPFaultDetail axiomFaultDetail,
041: SOAPFactory axiomFactory) {
042: super (axiomFaultDetail, axiomFactory);
043: }
044:
045: public SoapFaultDetailElement addFaultDetailElement(QName name) {
046: try {
047: OMElement element = getAxiomFactory().createOMElement(name,
048: getAxiomFaultDetail());
049: return new AxiomSoapFaultDetailElement(element,
050: getAxiomFactory());
051: } catch (OMException ex) {
052: throw new AxiomSoapFaultException(ex);
053: }
054:
055: }
056:
057: public Iterator getDetailEntries() {
058: return new AxiomSoapFaultDetailElementIterator(
059: getAxiomFaultDetail().getChildElements());
060: }
061:
062: public Result getResult() {
063: return new SAXResult(new AxiomContentHandler(
064: getAxiomFaultDetail()));
065: }
066:
067: protected SOAPFaultDetail getAxiomFaultDetail() {
068: return (SOAPFaultDetail) getAxiomElement();
069: }
070:
071: private class AxiomSoapFaultDetailElementIterator implements
072: Iterator {
073:
074: private final Iterator axiomIterator;
075:
076: private AxiomSoapFaultDetailElementIterator(
077: Iterator axiomIterator) {
078: this .axiomIterator = axiomIterator;
079: }
080:
081: public boolean hasNext() {
082: return axiomIterator.hasNext();
083: }
084:
085: public Object next() {
086: try {
087: OMElement axiomElement = (OMElement) axiomIterator
088: .next();
089: return new AxiomSoapFaultDetailElement(axiomElement,
090: getAxiomFactory());
091: } catch (OMException ex) {
092: throw new AxiomSoapFaultException(ex);
093: }
094:
095: }
096:
097: public void remove() {
098: axiomIterator.remove();
099: }
100: }
101:
102: }
|