KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > message > SOAPFaultReasonBuilder


1 package org.apache.axis.message;
2
3 import org.apache.axis.Constants;
4 import org.apache.axis.encoding.Callback;
5 import org.apache.axis.encoding.CallbackTarget;
6 import org.apache.axis.encoding.DeserializationContext;
7 import org.apache.axis.encoding.Deserializer;
8 import org.xml.sax.Attributes JavaDoc;
9 import org.xml.sax.SAXException JavaDoc;
10
11 import javax.xml.namespace.QName JavaDoc;
12 import java.util.ArrayList JavaDoc;
13
14 /*
15  * Copyright 2002-2004 The Apache Software Foundation.
16  *
17  * Licensed under the Apache License, Version 2.0 (the "License");
18  * you may not use this file except in compliance with the License.
19  * You may obtain a copy of the License at
20  *
21  * http://www.apache.org/licenses/LICENSE-2.0
22  *
23  * Unless required by applicable law or agreed to in writing, software
24  * distributed under the License is distributed on an "AS IS" BASIS,
25  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26  * See the License for the specific language governing permissions and
27  * limitations under the License.
28  */

29
30 /**
31  * Parser for the fault Reason element and its associated Text elements.
32  *
33  * @author Glen Daniels (gdaniels@apache.org)
34  */

35 public class SOAPFaultReasonBuilder extends SOAPHandler implements Callback
36 {
37     /** Storage for the actual text */
38     private ArrayList JavaDoc text = new ArrayList JavaDoc();
39     private SOAPFaultBuilder faultBuilder;
40     
41     public SOAPFaultReasonBuilder(SOAPFaultBuilder faultBuilder) {
42         this.faultBuilder = faultBuilder;
43     }
44
45     public SOAPHandler onStartChild(String JavaDoc namespace,
46                                     String JavaDoc name,
47                                     String JavaDoc prefix,
48                                     Attributes JavaDoc attributes,
49                                     DeserializationContext context)
50         throws SAXException JavaDoc
51     {
52         QName JavaDoc thisQName = new QName JavaDoc(namespace, name);
53         if (thisQName.equals(Constants.QNAME_TEXT_SOAP12)) {
54             Deserializer currentDeser = null;
55             currentDeser = context.getDeserializerForType(Constants.XSD_STRING);
56             if (currentDeser != null) {
57                 currentDeser.registerValueTarget(
58                         new CallbackTarget(faultBuilder, thisQName));
59             }
60             return (SOAPHandler)currentDeser;
61         } else {
62             return null;
63         }
64     }
65
66     /**
67      * Defined by Callback.
68      * This method gets control when the callback is invoked, which happens
69      * each time we get a deserialized Text string.
70      *
71      * @param value the deserialized value
72      * @param hint (unused) provides additional hint information.
73      */

74     public void setValue(Object JavaDoc value, Object JavaDoc hint) {
75         text.add(value);
76     }
77
78     public ArrayList JavaDoc getText() {
79         return text;
80     }
81 }
82
Popular Tags