KickJava   Java API By Example, From Geeks To Geeks.

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


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.SOAPFaultSubCode;
10 import org.apache.axis2.soap.SOAPFaultValue;
11 import org.apache.axis2.soap.impl.llom.SOAPFaultCodeImpl;
12 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
13
14 import javax.xml.stream.XMLStreamException;
15 import javax.xml.stream.XMLStreamWriter;
16
17 /*
18  * Copyright 2004,2005 The Apache Software Foundation.
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License");
21  * you may not use this file except in compliance with the License.
22  * You may obtain a copy of the License at
23  *
24  * http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS,
28  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  *
32  * author : Eran Chinthaka (chinthaka@apache.org)
33  */

34
35 public class SOAP11FaultCodeImpl extends SOAPFaultCodeImpl{
36     /**
37      * Constructor OMElementImpl
38      *
39      * @param localName
40      * @param ns
41      * @param parent
42      * @param builder
43      */

44     public SOAP11FaultCodeImpl(SOAPFault parent, OMXMLParserWrapper builder) {
45         super(parent, builder);
46     }
47
48     /**
49      * @param parent
50      * @param parent
51      */

52     public SOAP11FaultCodeImpl(SOAPFault parent) throws SOAPProcessingException {
53         super(parent, false);
54     }
55
56
57     public void setSubCode(SOAPFaultSubCode subCode) throws SOAPProcessingException {
58         if (!(subCode instanceof SOAP11FaultSubCodeImpl)) {
59             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Sub Code. But received some other implementation");
60         }
61         super.setSubCode(subCode);
62     }
63
64     public void setValue(SOAPFaultValue value) throws SOAPProcessingException {
65         if (!(value instanceof SOAP11FaultValueImpl)) {
66             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Value. But received some other implementation");
67         }
68         super.setValue(value);
69     }
70
71      protected void checkParent(OMElement parent) throws SOAPProcessingException {
72         if (!(parent instanceof SOAP11FaultImpl)) {
73             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault as the parent. But received some other implementation");
74         }
75     }
76
77      protected void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException {
78
79         // select the builder
80
short builderType = PULL_TYPE_BUILDER; // default is pull type
81
if (builder != null) {
82             builderType = this.builder.getBuilderType();
83         }
84         if ((builderType == PUSH_TYPE_BUILDER)
85                 && (builder.getRegisteredContentHandler() == null)) {
86             builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput));
87         }
88
89         XMLStreamWriter writer = omOutput.getXmlStreamWriter();
90         if (this.getNamespace() != null) {
91            String JavaDoc prefix = this.getNamespace().getPrefix();
92         String JavaDoc nameSpaceName = this.getNamespace().getName();
93         writer.writeStartElement(prefix, SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME,
94                                 nameSpaceName);
95         }else{
96             writer.writeStartElement(SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME);
97         }
98
99         OMSerializerUtil.serializeAttributes(this, omOutput);
100         OMSerializerUtil.serializeNamespaces(this, omOutput);
101
102
103         String JavaDoc text = this.getValue().getText();
104         writer.writeCharacters(text);
105         writer.writeEndElement();
106
107         //serilize siblings
108
if (this.nextSibling != null) {
109                 nextSibling.serialize(omOutput);
110             } else if (this.parent != null) {
111                 if (!this.parent.isComplete()) {
112                     builder.setCache(cache);
113                     builder.next();
114                 }
115             }
116
117     }
118
119     
120 }
121
Popular Tags