KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > encoding > DeserializationContext


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55
56
57 package org.jboss.axis.encoding;
58
59 import org.jboss.axis.MessageContext;
60 import org.jboss.axis.message.IDResolver;
61 import org.jboss.axis.message.SAX2EventRecorder;
62 import org.jboss.axis.message.SOAPElementAxisImpl;
63 import org.jboss.axis.message.SOAPEnvelopeAxisImpl;
64 import org.jboss.axis.message.SOAPHandler;
65 import org.xml.sax.Attributes JavaDoc;
66 import org.xml.sax.SAXException JavaDoc;
67
68 import javax.xml.namespace.QName JavaDoc;
69 import java.util.ArrayList JavaDoc;
70
71 /**
72  * This interface describes the AXIS DeserializationContext, note that
73  * an AXIS compliant DeserializationContext must extend the org.xml.sax.helpers.DefaultHandler.
74  */

75
76 public interface DeserializationContext extends javax.xml.rpc.encoding.DeserializationContext JavaDoc
77 {
78
79    /**
80     * Create a parser and parse the inputSource
81     */

82    public void parse() throws SAXException JavaDoc;
83
84    /**
85     * Get current MessageElement
86     */

87    public SOAPElementAxisImpl getCurElement();
88
89    /**
90     * Set current MessageElement
91     */

92    public void setCurElement(SOAPElementAxisImpl el);
93
94    /**
95     * Get MessageContext
96     */

97    public MessageContext getMessageContext();
98
99    /**
100     * Get Envelope
101     */

102    public SOAPEnvelopeAxisImpl getEnvelope();
103
104    /**
105     * Get Event Recorder
106     */

107    public SAX2EventRecorder getRecorder();
108
109    /**
110     * Set Event Recorder
111     */

112    public void setRecorder(SAX2EventRecorder recorder);
113
114    /**
115     * Get the Namespace Mappings. Returns null if none are present.
116     */

117    public ArrayList JavaDoc getCurrentNSMappings();
118
119    /**
120     * Get the Namespace for a particular prefix
121     */

122    public String JavaDoc getNamespaceURI(String JavaDoc prefix);
123
124    /**
125     * Construct a QName from a string of the form <prefix>:<localName>
126     *
127     * @param qNameStr is the prefixed name from the xml text
128     * @return QName
129     */

130    public QName JavaDoc getQNameFromString(String JavaDoc qNameStr);
131
132    /**
133     * Create a QName for the type of the element defined by localName and
134     * namespace from the XSI type.
135     *
136     * @param namespace of the element
137     * @param localName is the local name of the element
138     * @param attrs are the attributes on the element
139     */

140    public QName JavaDoc getTypeFromXSITypeAttr(String JavaDoc namespace, String JavaDoc localName,
141                                        Attributes JavaDoc attrs);
142
143    /**
144     * Create a QName for the type of the element defined by localName and
145     * namespace with the specified attributes.
146     *
147     * @param namespace of the element
148     * @param localName is the local name of the element
149     * @param attrs are the attributes on the element
150     */

151    public QName JavaDoc getTypeFromAttributes(String JavaDoc namespace, String JavaDoc localName,
152                                       Attributes JavaDoc attrs);
153
154    /**
155     * Convenenience method that returns true if the value is nil
156     * (due to the xsi:nil) attribute.
157     *
158     * @param attrs are the element attributes.
159     * @return true if xsi:nil is true
160     */

161    public boolean isNil(Attributes JavaDoc attrs);
162
163    /**
164     * Get a Deserializer which can turn a given xml type into a given
165     * Java type
166     */

167    public Deserializer getDeserializer(Class JavaDoc cls, QName JavaDoc xmlType);
168
169    /**
170     * Convenience method to get the Deserializer for a specific
171     * xmlType.
172     *
173     * @param xmlType is QName for a type to deserialize
174     * @return Deserializer
175     */

176    public Deserializer getDeserializerForType(QName JavaDoc xmlType);
177
178    /**
179     * Convenience method to get the Deserializer for a specific
180     * java class from its meta data.
181     *
182     * @param cls is the Class used to find the deserializer
183     * @return Deserializer
184     */

185    public Deserializer getDeserializerForClass(Class JavaDoc cls);
186
187    /**
188     * Get the TypeMapping for this DeserializationContext
189     */

190    public TypeMapping getTypeMapping();
191
192    /**
193     * Get the TypeMappingRegistry we're using.
194     *
195     * @return TypeMapping or null
196     */

197    public TypeMappingRegistry getTypeMappingRegistry();
198
199    /**
200     * Get the MessageElement for the indicated id (where id is the #value of an href)
201     * If the MessageElement has not been processed, the MessageElement will
202     * be returned. If the MessageElement has been processed, the actual object
203     * value is stored with the id and this routine will return null.
204     *
205     * @param id is the value of an href attribute
206     * @return MessageElement or null
207     */

208    public SOAPElementAxisImpl getElementByID(String JavaDoc id);
209
210    /**
211     * Gets the MessageElement or actual Object value associated with the href value.
212     * The return of a MessageElement indicates that the referenced element has
213     * not been processed. If it is not a MessageElement, the Object is the
214     * actual deserialized value.
215     * In addition, this method is invoked to get Object values via Attachments.
216     *
217     * @param id is the value of an href attribute (or an Attachment id)
218     * @return MessageElement other Object or null
219     */

220    public Object JavaDoc getObjectByRef(String JavaDoc href);
221
222    /**
223     * Add the object associated with this id (where id is the value of an id= attribute,
224     * i.e. it does not start with #).
225     * This routine is called to associate the deserialized object
226     * with the id specified on the XML element.
227     *
228     * @param id (id name without the #)
229     * @param obj is the deserialized object for this id.
230     */

231    public void addObjectById(String JavaDoc _id, Object JavaDoc obj);
232
233    /**
234     * During deserialization, an element with an HREF=#id<int>
235     * may be encountered before the element defining id=id<int> is
236     * read. In these cases, the getObjectByRef method above will
237     * return null. The deserializer is placed in a table keyed
238     * by href (a fixup table). After the element id is processed,
239     * the deserializer is informed of the value so that it can
240     * update its target(s) with the value.
241     *
242     * @param href (#id syntax)
243     * @param dser is the deserializer of the element
244     */

245    public void registerFixup(String JavaDoc href, Deserializer dser);
246
247
248    /**
249     * Register the MessageElement with this id (where id is id= form without the #)
250     * This routine is called when the MessageElement with an id is read.
251     * If there is a Deserializer in our fixup list (described above),
252     * the 'fixup' deserializer is given to the MessageElement. When the
253     * MessageElement is completed, the 'fixup' deserializer is informed and
254     * it can set its targets.
255     *
256     * @param id (id name without the #)
257     * @param elem is the MessageElement
258     */

259    public void registerElementByID(String JavaDoc id, SOAPElementAxisImpl elem);
260
261    /**
262     * Each id can have its own kind of resolver. This registers a
263     * resolver for the id.
264     */

265    public void registerResolverForID(String JavaDoc id, IDResolver resolver);
266
267    /**
268     * Get the current position in the record.
269     */

270    public int getCurrentRecordPos();
271
272    /**
273     * Get the start of the mapping position
274     */

275    public int getStartOfMappingsPos();
276
277    /**
278     * Push the MessageElement into the recorder
279     */

280    public void pushNewElement(SOAPElementAxisImpl elem);
281
282    /**
283     * Handler management methods
284     */

285    public void pushElementHandler(SOAPHandler handler);
286
287    public void replaceElementHandler(SOAPHandler handler);
288
289    public SOAPHandler popElementHandler();
290
291    /**
292     * Return if done parsing document.
293     */

294    public boolean isDoneParsing();
295
296    /**
297     * Indicate if we're in the midst of processing an href target, in which
298     * case we shouldn't be pushing the element stack.
299     *
300     * @param ref
301     */

302    void setProcessingRef(boolean ref);
303
304    /**
305     * Are we in the midst of processing an href target? If so, we shouldn't
306     * be pushing the element stack...
307     *
308     * @return
309     */

310    boolean isProcessingRef();
311 }
312
313
314
Popular Tags