KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > impl > llom > soap11 > SOAP11FaultReasonImpl


1 package org.apache.axis2.soap.impl.llom.soap11;
2
3 import org.apache.axis2.om.OMElement;
4 import org.apache.axis2.om.OMOutput;
5 import org.apache.axis2.om.OMXMLParserWrapper;
6 import org.apache.axis2.om.impl.llom.OMSerializerUtil;
7 import org.apache.axis2.om.impl.llom.serialize.StreamWriterToContentHandlerConverter;
8 import org.apache.axis2.soap.SOAPFault;
9 import org.apache.axis2.soap.SOAPFaultText;
10 import org.apache.axis2.soap.impl.llom.SOAPFaultReasonImpl;
11 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
12
13 import javax.xml.stream.XMLStreamException;
14 import javax.xml.stream.XMLStreamWriter;
15
16 /**
17  * Copyright 2001-2004 The Apache Software Foundation.
18  * <p/>
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
20  * use this file except in compliance with the License. You may obtain a copy of
21  * the License at
22  * <p/>
23  * http://www.apache.org/licenses/LICENSE-2.0
24  * <p/>
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
28  * License for the specific language governing permissions and limitations under
29  * the License.
30  * <p/>
31  */

32 public class SOAP11FaultReasonImpl extends SOAPFaultReasonImpl {
33     /**
34      * Eran Chinthaka (chinthaka@apache.org)
35      */

36
37     public SOAP11FaultReasonImpl(SOAPFault parent, OMXMLParserWrapper builder) {
38         super(parent, builder);
39     }
40
41     /**
42      * @param parent
43      */

44     public SOAP11FaultReasonImpl(SOAPFault parent) throws SOAPProcessingException {
45         super(parent, false);
46     }
47
48     public void setSOAPText(SOAPFaultText soapFaultText) throws SOAPProcessingException {
49         if (!(soapFaultText instanceof SOAP11FaultTextImpl)) {
50             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Text. But received some other implementation");
51         }
52         super.setSOAPText(soapFaultText);
53     }
54
55     protected void checkParent(OMElement parent) throws SOAPProcessingException {
56         if (!(parent instanceof SOAP11FaultImpl)) {
57             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault as the parent. But received some other implementation");
58         }
59     }
60
61     protected void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException {
62
63         // select the builder
64
short builderType = PULL_TYPE_BUILDER; // default is pull type
65
if (builder != null) {
66             builderType = this.builder.getBuilderType();
67         }
68         if ((builderType == PUSH_TYPE_BUILDER)
69                 && (builder.getRegisteredContentHandler() == null)) {
70             builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput));
71         }
72
73         XMLStreamWriter writer = omOutput.getXmlStreamWriter();
74         if (this.getNamespace() != null) {
75            String JavaDoc prefix = this.getNamespace().getPrefix();
76         String JavaDoc nameSpaceName = this.getNamespace().getName();
77         writer.writeStartElement(prefix, SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME,
78                                 nameSpaceName);
79         }else{
80             writer.writeStartElement(SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME);
81         }
82         OMSerializerUtil.serializeAttributes(this, omOutput);
83         OMSerializerUtil.serializeNamespaces(this, omOutput);
84
85         String JavaDoc text = this.getSOAPText().getText();
86         writer.writeCharacters(text);
87         writer.writeEndElement();
88
89         //serilize siblings
90
if (this.nextSibling != null) {
91             nextSibling.serialize(omOutput);
92         } else if (this.parent != null) {
93             if (!this.parent.isComplete()) {
94                 builder.setCache(cache);
95                 builder.next();
96             }
97         }
98
99     }
100
101    
102 }
103
Popular Tags