KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > soap > SOAPElement


1 /*
2  * $Id: SOAPElement.java,v 1.19 2005/12/13 09:20:25 vj135062 Exp $
3  * $Revision: 1.19 $
4  * $Date: 2005/12/13 09:20:25 $
5  */

6
7 /*
8  * The contents of this file are subject to the terms
9  * of the Common Development and Distribution License
10  * (the License). You may not use this file except in
11  * compliance with the License.
12  *
13  * You can obtain a copy of the license at
14  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
15  * See the License for the specific language governing
16  * permissions and limitations under the License.
17  *
18  * When distributing Covered Code, include this CDDL
19  * Header Notice in each file and include the License file
20  * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
21  * If applicable, add the following below the CDDL Header,
22  * with the fields enclosed by brackets [] replaced by
23  * you own identifying information:
24  * "Portions Copyrighted [year] [name of copyright owner]"
25  *
26  * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
27  */

28 package javax.xml.soap;
29
30 import java.util.Iterator JavaDoc;
31
32 import javax.xml.namespace.QName JavaDoc;
33
34 /**
35  * An object representing an element of a SOAP message that is allowed but not
36  * specifically prescribed by a SOAP specification. This interface serves as the
37  * base interface for those objects that are specifically prescribed by a SOAP
38  * specification.
39  * <p>
40  * Methods in this interface that are required to return SAAJ specific objects
41  * may "silently" replace nodes in the tree as required to successfully return
42  * objects of the correct type. See {@link #getChildElements()} and
43  * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
44  * for details.
45  */

46 public interface SOAPElement extends Node JavaDoc, org.w3c.dom.Element JavaDoc {
47
48     /**
49      * Creates a new <code>SOAPElement</code> object initialized with the
50      * given <code>Name</code> object and adds the new element to this
51      * <code>SOAPElement</code> object.
52      * <P>
53      * This method may be deprecated in a future release of SAAJ in favor of
54      * addChildElement(javax.xml.namespace.QName)
55      *
56      * @param name a <code>Name</code> object with the XML name for the
57      * new element
58      *
59      * @return the new <code>SOAPElement</code> object that was created
60      * @exception SOAPException if there is an error in creating the
61      * <code>SOAPElement</code> object
62      * @see SOAPElement#addChildElement(javax.xml.namespace.QName)
63      */

64     public SOAPElement JavaDoc addChildElement(Name JavaDoc name) throws SOAPException JavaDoc;
65
66     /**
67      * Creates a new <code>SOAPElement</code> object initialized with the given
68      * <code>QName</code> object and adds the new element to this <code>SOAPElement</code>
69      * object. The <i>namespace</i>, <i>localname</i> and <i>prefix</i> of the new
70      * <code>SOAPElement</code> are all taken from the <code>qname</code> argument.
71      *
72      * @param qname a <code>QName</code> object with the XML name for the
73      * new element
74      *
75      * @return the new <code>SOAPElement</code> object that was created
76      * @exception SOAPException if there is an error in creating the
77      * <code>SOAPElement</code> object
78      * @see SOAPElement#addChildElement(Name)
79      * @since SAAJ 1.3
80      */

81     public SOAPElement JavaDoc addChildElement(QName JavaDoc qname) throws SOAPException JavaDoc;
82
83     /**
84      * Creates a new <code>SOAPElement</code> object initialized with the
85      * specified local name and adds the new element to this
86      * <code>SOAPElement</code> object.
87      * The new <code>SOAPElement</code> inherits any in-scope default namespace.
88      *
89      * @param localName a <code>String</code> giving the local name for
90      * the element
91      * @return the new <code>SOAPElement</code> object that was created
92      * @exception SOAPException if there is an error in creating the
93      * <code>SOAPElement</code> object
94      */

95     public SOAPElement JavaDoc addChildElement(String JavaDoc localName) throws SOAPException JavaDoc;
96
97     /**
98      * Creates a new <code>SOAPElement</code> object initialized with the
99      * specified local name and prefix and adds the new element to this
100      * <code>SOAPElement</code> object.
101      *
102      * @param localName a <code>String</code> giving the local name for
103      * the new element
104      * @param prefix a <code>String</code> giving the namespace prefix for
105      * the new element
106      *
107      * @return the new <code>SOAPElement</code> object that was created
108      * @exception SOAPException if the <code>prefix</code> is not valid in the
109      * context of this <code>SOAPElement</code> or if there is an error in creating the
110      * <code>SOAPElement</code> object
111      */

112     public SOAPElement JavaDoc addChildElement(String JavaDoc localName, String JavaDoc prefix)
113         throws SOAPException JavaDoc;
114
115     /**
116      * Creates a new <code>SOAPElement</code> object initialized with the
117      * specified local name, prefix, and URI and adds the new element to this
118      * <code>SOAPElement</code> object.
119      *
120      * @param localName a <code>String</code> giving the local name for
121      * the new element
122      * @param prefix a <code>String</code> giving the namespace prefix for
123      * the new element
124      * @param uri a <code>String</code> giving the URI of the namespace
125      * to which the new element belongs
126      *
127      * @return the new <code>SOAPElement</code> object that was created
128      * @exception SOAPException if there is an error in creating the
129      * <code>SOAPElement</code> object
130      */

131     public SOAPElement JavaDoc addChildElement(String JavaDoc localName, String JavaDoc prefix,
132                                        String JavaDoc uri)
133         throws SOAPException JavaDoc;
134
135     /**
136      * Add a <code>SOAPElement</code> as a child of this
137      * <code>SOAPElement</code> instance. The <code>SOAPElement</code>
138      * is expected to be created by a
139      * <code>SOAPFactory</code>. Callers should not rely on the
140      * element instance being added as is into the XML
141      * tree. Implementations could end up copying the content
142      * of the <code>SOAPElement</code> passed into an instance of
143      * a different <code>SOAPElement</code> implementation. For
144      * instance if <code>addChildElement()</code> is called on a
145      * <code>SOAPHeader</code>, <code>element</code> will be copied
146      * into an instance of a <code>SOAPHeaderElement</code>.
147      *
148      * <P>The fragment rooted in <code>element</code> is either added
149      * as a whole or not at all, if there was an error.
150      *
151      * <P>The fragment rooted in <code>element</code> cannot contain
152      * elements named "Envelope", "Header" or "Body" and in the SOAP
153      * namespace. Any namespace prefixes present in the fragment
154      * should be fully resolved using appropriate namespace
155      * declarations within the fragment itself.
156      *
157      * @param element the <code>SOAPElement</code> to be added as a
158      * new child
159      *
160      * @exception SOAPException if there was an error in adding this
161      * element as a child
162      *
163      * @return an instance representing the new SOAP element that was
164      * actually added to the tree.
165      */

166     public SOAPElement JavaDoc addChildElement(SOAPElement JavaDoc element)
167         throws SOAPException JavaDoc;
168
169     /**
170      * Detaches all children of this <code>SOAPElement</code>.
171      * <p>
172      * This method is useful for rolling back the construction of partially
173      * completed <code>SOAPHeaders</code> and <code>SOAPBodys</code> in
174      * preparation for sending a fault when an error condition is detected. It
175      * is also useful for recycling portions of a document within a SOAP
176      * message.
177      *
178      * @since SAAJ 1.2
179      */

180     public abstract void removeContents();
181
182     /**
183      * Creates a new <code>Text</code> object initialized with the given
184      * <code>String</code> and adds it to this <code>SOAPElement</code> object.
185      *
186      * @param text a <code>String</code> object with the textual content to be added
187      *
188      * @return the <code>SOAPElement</code> object into which
189      * the new <code>Text</code> object was inserted
190      * @exception SOAPException if there is an error in creating the
191      * new <code>Text</code> object or if it is not legal to
192      * attach it as a child to this
193      * <code>SOAPElement</code>
194      */

195     public SOAPElement JavaDoc addTextNode(String JavaDoc text) throws SOAPException JavaDoc;
196
197     /**
198      * Adds an attribute with the specified name and value to this
199      * <code>SOAPElement</code> object.
200      *
201      * @param name a <code>Name</code> object with the name of the attribute
202      * @param value a <code>String</code> giving the value of the attribute
203      * @return the <code>SOAPElement</code> object into which the attribute was
204      * inserted
205      *
206      * @exception SOAPException if there is an error in creating the
207      * Attribute, or it is invalid to set
208                                 an attribute with <code>Name</code>
209                                  <code>name</code> on this SOAPElement.
210      * @see SOAPElement#addAttribute(javax.xml.namespace.QName, String)
211      */

212     public SOAPElement JavaDoc addAttribute(Name JavaDoc name, String JavaDoc value)
213         throws SOAPException JavaDoc;
214
215     /**
216      * Adds an attribute with the specified name and value to this
217      * <code>SOAPElement</code> object.
218      *
219      * @param qname a <code>QName</code> object with the name of the attribute
220      * @param value a <code>String</code> giving the value of the attribute
221      * @return the <code>SOAPElement</code> object into which the attribute was
222      * inserted
223      *
224      * @exception SOAPException if there is an error in creating the
225      * Attribute, or it is invalid to set
226                                 an attribute with <code>QName</code>
227                                 <code>qname</code> on this SOAPElement.
228      * @see SOAPElement#addAttribute(Name, String)
229      * @since SAAJ 1.3
230      */

231     public SOAPElement JavaDoc addAttribute(QName JavaDoc qname, String JavaDoc value)
232         throws SOAPException JavaDoc;
233
234     /**
235      * Adds a namespace declaration with the specified prefix and URI to this
236      * <code>SOAPElement</code> object.
237      *
238      * @param prefix a <code>String</code> giving the prefix of the namespace
239      * @param uri a <code>String</code> giving the uri of the namespace
240      * @return the <code>SOAPElement</code> object into which this
241      * namespace declaration was inserted.
242      *
243      * @exception SOAPException if there is an error in creating the
244      * namespace
245      */

246     public SOAPElement JavaDoc addNamespaceDeclaration(String JavaDoc prefix, String JavaDoc uri)
247         throws SOAPException JavaDoc;
248
249     /**
250      * Returns the value of the attribute with the specified name.
251      *
252      * @param name a <code>Name</code> object with the name of the attribute
253      * @return a <code>String</code> giving the value of the specified
254      * attribute, Null if there is no such attribute
255      * @see SOAPElement#getAttributeValue(javax.xml.namespace.QName)
256      */

257     public String JavaDoc getAttributeValue(Name JavaDoc name);
258     
259     /**
260      * Returns the value of the attribute with the specified qname.
261      *
262      * @param qname a <code>QName</code> object with the qname of the attribute
263      * @return a <code>String</code> giving the value of the specified
264      * attribute, Null if there is no such attribute
265      * @see SOAPElement#getAttributeValue(Name)
266      * @since SAAJ 1.3
267      */

268     public String JavaDoc getAttributeValue(QName JavaDoc qname);
269
270     /**
271      * Returns an <code>Iterator</code> over all of the attribute
272      * <code>Name</code> objects in this
273      * <code>SOAPElement</code> object. The iterator can be used to get
274      * the attribute names, which can then be passed to the method
275      * <code>getAttributeValue</code> to retrieve the value of each
276      * attribute.
277      *
278      * @see SOAPElement#getAllAttributesAsQNames()
279      * @return an iterator over the names of the attributes
280      */

281     public Iterator JavaDoc getAllAttributes();
282
283     /**
284      * Returns an <code>Iterator</code> over all of the attributes
285      * in this <code>SOAPElement</code> as <code>QName</code> objects.
286      * The iterator can be used to get the attribute QName, which can then
287      * be passed to the method <code>getAttributeValue</code> to retrieve
288      * the value of each attribute.
289      *
290      * @return an iterator over the QNames of the attributes
291      * @see SOAPElement#getAllAttributes()
292      * @since SAAJ 1.3
293      */

294     public Iterator JavaDoc getAllAttributesAsQNames();
295
296     
297     /**
298      * Returns the URI of the namespace that has the given prefix.
299      *
300      * @param prefix a <code>String</code> giving the prefix of the namespace
301      * for which to search
302      * @return a <code>String</code> with the uri of the namespace that has
303      * the given prefix
304      */

305     public String JavaDoc getNamespaceURI(String JavaDoc prefix);
306
307     /**
308      * Returns an <code>Iterator</code> over the namespace prefix
309      * <code>String</code>s declared by this element. The prefixes returned by
310      * this iterator can be passed to the method
311      * <code>getNamespaceURI</code> to retrieve the URI of each namespace.
312      *
313      * @return an iterator over the namespace prefixes in this
314      * <code>SOAPElement</code> object
315      */

316     public Iterator JavaDoc getNamespacePrefixes();
317
318     /**
319      * Returns an <code>Iterator</code> over the namespace prefix
320      * <code>String</code>s visible to this element. The prefixes returned by
321      * this iterator can be passed to the method
322      * <code>getNamespaceURI</code> to retrieve the URI of each namespace.
323      *
324      * @return an iterator over the namespace prefixes are within scope of this
325      * <code>SOAPElement</code> object
326      *
327      * @since SAAJ 1.2
328      */

329     public Iterator JavaDoc getVisibleNamespacePrefixes();
330     
331     /**
332      * Creates a <code>QName</code> whose namespace URI is the one associated
333      * with the parameter, <code>prefix</code>, in the context of this
334      * <code>SOAPElement</code>. The remaining elements of the new
335      * <code>QName</code> are taken directly from the parameters,
336      * <code>localName</code> and <code>prefix</code>.
337      *
338      * @param localName
339      * a <code>String</code> containing the local part of the name.
340      * @param prefix
341      * a <code>String</code> containing the prefix for the name.
342      *
343      * @return a <code>QName</code> with the specified <code>localName</code>
344      * and <code>prefix</code>, and with a namespace that is associated
345      * with the <code>prefix</code> in the context of this
346      * <code>SOAPElement</code>. This namespace will be the same as
347      * the one that would be returned by
348      * <code>{@link #getNamespaceURI(String)}</code> if it were given
349      * <code>prefix</code> as it's parameter.
350      *
351      * @exception SOAPException if the <code>QName</code> cannot be created.
352      *
353      * @since SAAJ 1.3
354      */

355     public QName JavaDoc createQName(String JavaDoc localName, String JavaDoc prefix)
356         throws SOAPException JavaDoc;
357     /**
358      * Returns the name of this <code>SOAPElement</code> object.
359      *
360      * @return a <code>Name</code> object with the name of this
361      * <code>SOAPElement</code> object
362      */

363     public Name JavaDoc getElementName();
364     
365     /**
366      * Returns the qname of this <code>SOAPElement</code> object.
367      *
368      * @return a <code>QName</code> object with the qname of this
369      * <code>SOAPElement</code> object
370      * @see SOAPElement#getElementName()
371      * @since SAAJ 1.3
372      */

373     public QName JavaDoc getElementQName();
374
375     /**
376     * Changes the name of this <code>Element</code> to <code>newName</code> if
377     * possible. SOAP Defined elements such as SOAPEnvelope, SOAPHeader, SOAPBody
378     * etc. cannot have their names changed using this method. Any attempt to do
379     * so will result in a SOAPException being thrown.
380     *<P>
381     * Callers should not rely on the element instance being renamed as is.
382     * Implementations could end up copying the content of the
383     * <code>SOAPElement</code> to a renamed instance.
384     *
385     * @param newName the new name for the <code>Element</code>.
386     *
387     * @exception SOAPException if changing the name of this <code>Element</code>
388     * is not allowed.
389     * @return The renamed Node
390     *
391     * @since SAAJ 1.3
392     */

393    public SOAPElement JavaDoc setElementQName(QName JavaDoc newName) throws SOAPException JavaDoc;
394     
395    /**
396      * Removes the attribute with the specified name.
397      *
398      * @param name the <code>Name</code> object with the name of the
399      * attribute to be removed
400      * @return <code>true</code> if the attribute was
401      * removed successfully; <code>false</code> if it was not
402      * @see SOAPElement#removeAttribute(javax.xml.namespace.QName)
403      */

404     public boolean removeAttribute(Name JavaDoc name);
405
406     /**
407      * Removes the attribute with the specified qname.
408      *
409      * @param qname the <code>QName</code> object with the qname of the
410      * attribute to be removed
411      * @return <code>true</code> if the attribute was
412      * removed successfully; <code>false</code> if it was not
413      * @see SOAPElement#removeAttribute(Name)
414      * @since SAAJ 1.3
415      */

416     public boolean removeAttribute(QName JavaDoc qname);
417
418     /**
419      * Removes the namespace declaration corresponding to the given prefix.
420      *
421      * @param prefix a <code>String</code> giving the prefix for which
422      * to search
423      * @return <code>true</code> if the namespace declaration was
424      * removed successfully; <code>false</code> if it was not
425      */

426     public boolean removeNamespaceDeclaration(String JavaDoc prefix);
427
428     /**
429      * Returns an <code>Iterator</code> over all the immediate child
430      * {@link Node}s of this element. This includes <code>javax.xml.soap.Text</code>
431      * objects as well as <code>SOAPElement</code> objects.
432      * <p>
433      * Calling this method may cause child <code>Element</code>,
434      * <code>SOAPElement</code> and <code>org.w3c.dom.Text</code> nodes to be
435      * replaced by <code>SOAPElement</code>, <code>SOAPHeaderElement</code>,
436      * <code>SOAPBodyElement</code> or <code>javax.xml.soap.Text</code> nodes as
437      * appropriate for the type of this parent node. As a result the calling
438      * application must treat any existing references to these child nodes that
439      * have been obtained through DOM APIs as invalid and either discard them or
440      * refresh them with the values returned by this <code>Iterator</code>. This
441      * behavior can be avoided by calling the equivalent DOM APIs. See
442      * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
443      * for more details.
444      *
445      * @return an iterator with the content of this <code>SOAPElement</code>
446      * object
447      */

448     public Iterator JavaDoc getChildElements();
449
450     /**
451      * Returns an <code>Iterator</code> over all the immediate child
452      * {@link Node}s of this element with the specified name. All of these
453      * children will be <code>SOAPElement</code> nodes.
454      * <p>
455      * Calling this method may cause child <code>Element</code>,
456      * <code>SOAPElement</code> and <code>org.w3c.dom.Text</code> nodes to be
457      * replaced by <code>SOAPElement</code>, <code>SOAPHeaderElement</code>,
458      * <code>SOAPBodyElement</code> or <code>javax.xml.soap.Text</code> nodes as
459      * appropriate for the type of this parent node. As a result the calling
460      * application must treat any existing references to these child nodes that
461      * have been obtained through DOM APIs as invalid and either discard them or
462      * refresh them with the values returned by this <code>Iterator</code>. This
463      * behavior can be avoided by calling the equivalent DOM APIs. See
464      * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
465      * for more details.
466      *
467      * @param name a <code>Name</code> object with the name of the child
468      * elements to be returned
469      *
470      * @return an <code>Iterator</code> object over all the elements
471      * in this <code>SOAPElement</code> object with the
472      * specified name
473      * @see SOAPElement#getChildElements(javax.xml.namespace.QName)
474      */

475     public Iterator JavaDoc getChildElements(Name JavaDoc name);
476
477     /**
478      * Returns an <code>Iterator</code> over all the immediate child
479      * {@link Node}s of this element with the specified qname. All of these
480      * children will be <code>SOAPElement</code> nodes.
481      * <p>
482      * Calling this method may cause child <code>Element</code>,
483      * <code>SOAPElement</code> and <code>org.w3c.dom.Text</code> nodes to be
484      * replaced by <code>SOAPElement</code>, <code>SOAPHeaderElement</code>,
485      * <code>SOAPBodyElement</code> or <code>javax.xml.soap.Text</code> nodes as
486      * appropriate for the type of this parent node. As a result the calling
487      * application must treat any existing references to these child nodes that
488      * have been obtained through DOM APIs as invalid and either discard them or
489      * refresh them with the values returned by this <code>Iterator</code>. This
490      * behavior can be avoided by calling the equivalent DOM APIs. See
491      * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
492      * for more details.
493      *
494      * @param qname a <code>QName</code> object with the qname of the child
495      * elements to be returned
496      *
497      * @return an <code>Iterator</code> object over all the elements
498      * in this <code>SOAPElement</code> object with the
499      * specified qname
500      * @see SOAPElement#getChildElements(Name)
501      * @since SAAJ 1.3
502      */

503     public Iterator JavaDoc getChildElements(QName JavaDoc qname);
504
505     /**
506      * Sets the encoding style for this <code>SOAPElement</code> object
507      * to one specified.
508      *
509      * @param encodingStyle a <code>String</code> giving the encoding style
510      *
511      * @exception IllegalArgumentException if there was a problem in the
512      * encoding style being set.
513      * @exception SOAPException if setting the encodingStyle is invalid for this SOAPElement.
514      * @see #getEncodingStyle
515      */

516     public void setEncodingStyle(String JavaDoc encodingStyle)
517         throws SOAPException JavaDoc;
518     /**
519      * Returns the encoding style for this <code>SOAPElement</code> object.
520      *
521      * @return a <code>String</code> giving the encoding style
522      *
523      * @see #setEncodingStyle
524      */

525     public String JavaDoc getEncodingStyle();
526 }
527
Popular Tags