KickJava   Java API By Example, From Geeks To Geeks.

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


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.SOAPFaultDetailImpl;
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 SOAP11FaultDetailImpl extends SOAPFaultDetailImpl {
34     public SOAP11FaultDetailImpl(SOAPFault parent) throws SOAPProcessingException {
35         super(parent, false);
36     }
37
38     public SOAP11FaultDetailImpl(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 // public void addDetailEntry(OMElement detailElement) {
49
// throw new UnsupportedOperationException();
50
// }
51
//
52
// public Iterator getAllDetailEntries() {
53
// throw new UnsupportedOperationException();
54
// }
55

56      public void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException {
57
58         // select the builder
59
short builderType = PULL_TYPE_BUILDER; // default is pull type
60
if (builder != null) {
61             builderType = this.builder.getBuilderType();
62         }
63         if ((builderType == PUSH_TYPE_BUILDER)
64                 && (builder.getRegisteredContentHandler() == null)) {
65             builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput));
66         }
67         XMLStreamWriter writer = omOutput.getXmlStreamWriter();
68         if (this.getNamespace() != null) {
69            String JavaDoc prefix = this.getNamespace().getPrefix();
70         String JavaDoc nameSpaceName = this.getNamespace().getName();
71         writer.writeStartElement(prefix, SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME,
72                                 nameSpaceName);
73         }else{
74             writer.writeStartElement(SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME);
75         }
76         OMSerializerUtil.serializeAttributes(this, omOutput);
77         OMSerializerUtil.serializeNamespaces(this, omOutput);
78
79
80         String JavaDoc text = this.getText();
81         writer.writeCharacters(text);
82
83
84         if (firstChild != null) {
85             firstChild.serialize(omOutput);
86         }
87         writer.writeEndElement();
88
89         //serilize siblings
90
if (this.nextSibling != null) {
91             nextSibling.serialize(omOutput);
92         }
93
94     }
95
96     
97 }
98
Popular Tags