KickJava   Java API By Example, From Geeks To Geeks.

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


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

32
33 public class SOAP11FaultRoleImpl extends SOAPFaultRoleImpl {
34     public SOAP11FaultRoleImpl(SOAPFault parent) throws SOAPProcessingException {
35         super(parent, false);
36     }
37
38     public SOAP11FaultRoleImpl(SOAPFault parent, OMXMLParserWrapper builder) {
39         super(parent, builder);
40     }
41
42     protected void checkParent(OMElement parent) throws SOAPProcessingException {
43         if (!(parent instanceof SOAP11FaultImpl)) {
44             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault as the parent. But received some other implementation");
45         }
46     }
47
48     protected void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException {
49
50         // select the builder
51
short builderType = PULL_TYPE_BUILDER; // default is pull type
52
if (builder != null) {
53             builderType = this.builder.getBuilderType();
54         }
55         if ((builderType == PUSH_TYPE_BUILDER)
56                 && (builder.getRegisteredContentHandler() == null)) {
57             builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput));
58         }
59
60         XMLStreamWriter writer = omOutput.getXmlStreamWriter();
61         if (this.getNamespace() != null) {
62             String JavaDoc prefix = this.getNamespace().getPrefix();
63             String JavaDoc nameSpaceName = this.getNamespace().getName();
64             writer.writeStartElement(prefix, SOAP11Constants.SOAP_FAULT_ACTOR_LOCAL_NAME,
65                     nameSpaceName);
66         } else {
67             writer.writeStartElement(SOAP11Constants.SOAP_FAULT_ACTOR_LOCAL_NAME);
68         }
69         OMSerializerUtil.serializeAttributes(this,omOutput);
70         OMSerializerUtil.serializeNamespaces(this, omOutput);
71
72         String JavaDoc text = this.getText();
73         writer.writeCharacters(text);
74         writer.writeEndElement();
75
76         //serilize siblings
77
if (this.nextSibling != null) {
78             nextSibling.serialize(omOutput);
79         } else if (this.parent != null) {
80             if (!this.parent.isComplete()) {
81                 builder.setCache(cache);
82                 builder.next();
83             }
84         }
85
86     }
87
88    
89 }
90
Popular Tags