KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */

16 package org.jboss.axis.message;
17
18
19 import org.jboss.axis.Constants;
20 import org.jboss.axis.encoding.Callback;
21 import org.jboss.axis.encoding.CallbackTarget;
22 import org.jboss.axis.encoding.DeserializationContext;
23 import org.jboss.axis.encoding.Deserializer;
24 import org.xml.sax.Attributes JavaDoc;
25 import org.xml.sax.SAXException JavaDoc;
26
27 import javax.xml.namespace.QName JavaDoc;
28 import java.util.ArrayList JavaDoc;
29
30
31 /**
32  * Parser for the fault Reason element and its associated Text elements.
33  *
34  * @author Glen Daniels (gdaniels@apache.org)
35  */

36
37 public class SOAPFaultReasonBuilder extends SOAPHandler implements Callback
38
39 {
40
41    /**
42     * Storage for the actual text
43     */

44
45    private ArrayList JavaDoc text = new ArrayList JavaDoc();
46
47    private SOAPFaultBuilder faultBuilder;
48
49
50    public SOAPFaultReasonBuilder(SOAPFaultBuilder faultBuilder)
51    {
52
53       this.faultBuilder = faultBuilder;
54
55    }
56
57
58    public SOAPHandler onStartChild(String JavaDoc namespace,
59
60                                    String JavaDoc name,
61
62                                    String JavaDoc prefix,
63
64                                    Attributes JavaDoc attributes,
65
66                                    DeserializationContext context)
67
68            throws SAXException JavaDoc
69
70    {
71
72       QName JavaDoc thisQName = new QName JavaDoc(namespace, name);
73
74       if (thisQName.equals(Constants.QNAME_TEXT_SOAP12))
75       {
76
77          Deserializer currentDeser = null;
78
79          currentDeser = context.getDeserializerForType(Constants.XSD_STRING);
80
81          if (currentDeser != null)
82          {
83
84             currentDeser.registerValueTarget(new CallbackTarget(faultBuilder, thisQName));
85
86          }
87
88          return (SOAPHandler)currentDeser;
89
90       }
91       else
92       {
93
94          return null;
95
96       }
97
98    }
99
100
101    /**
102     * Defined by Callback.
103     * <p/>
104     * This method gets control when the callback is invoked, which happens
105     * <p/>
106     * each time we get a deserialized Text string.
107     *
108     * @param value the deserialized value
109     * @param hint (unused) provides additional hint information.
110     */

111
112    public void setValue(Object JavaDoc value, Object JavaDoc hint)
113    {
114
115       text.add(value);
116
117    }
118
119
120    public ArrayList JavaDoc getText()
121    {
122
123       return text;
124
125    }
126
127 }
128
129
Popular Tags