< prev index next >

src/java.xml.ws/share/classes/javax/xml/soap/SOAPElement.java

Print this page


   1 /*
   2  * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 260      *
 261      * @param qname a {@code QName} object with the qname of the attribute
 262      * @return a {@code String} giving the value of the specified
 263      *         attribute, Null if there is no such attribute
 264      * @see SOAPElement#getAttributeValue(Name)
 265      * @since 1.6, SAAJ 1.3
 266      */
 267     public String getAttributeValue(QName qname);
 268 
 269     /**
 270      * Returns an {@code Iterator} over all of the attribute
 271      * {@code Name} objects in this
 272      * {@code SOAPElement} object. The iterator can be used to get
 273      * the attribute names, which can then be passed to the method
 274      * {@code getAttributeValue} to retrieve the value of each
 275      * attribute.
 276      *
 277      * @see SOAPElement#getAllAttributesAsQNames()
 278      * @return an iterator over the names of the attributes
 279      */
 280     public Iterator getAllAttributes();
 281 
 282     /**
 283      * Returns an {@code Iterator} over all of the attributes
 284      * in this {@code SOAPElement}  as {@code QName} objects.
 285      * The iterator can be used to get the attribute QName, which can then
 286      * be passed to the method {@code getAttributeValue} to retrieve
 287      * the value of each attribute.
 288      *
 289      * @return an iterator over the QNames of the attributes
 290      * @see SOAPElement#getAllAttributes()
 291      * @since 1.6, SAAJ 1.3
 292      */
 293     public Iterator getAllAttributesAsQNames();
 294 
 295 
 296     /**
 297      * Returns the URI of the namespace that has the given prefix.
 298      *
 299      * @param prefix a {@code String} giving the prefix of the namespace
 300      *        for which to search
 301      * @return a {@code String} with the uri of the namespace that has
 302      *        the given prefix
 303      */
 304     public String getNamespaceURI(String prefix);
 305 
 306     /**
 307      * Returns an {@code Iterator} over the namespace prefix
 308      * {@code String}s declared by this element. The prefixes returned by
 309      * this iterator can be passed to the method
 310      * {@code getNamespaceURI} to retrieve the URI of each namespace.
 311      *
 312      * @return an iterator over the namespace prefixes in this
 313      *         {@code SOAPElement} object
 314      */
 315     public Iterator getNamespacePrefixes();
 316 
 317     /**
 318      * Returns an {@code Iterator} over the namespace prefix
 319      * {@code String}s visible to this element. The prefixes returned by
 320      * this iterator can be passed to the method
 321      * {@code getNamespaceURI} to retrieve the URI of each namespace.
 322      *
 323      * @return an iterator over the namespace prefixes are within scope of this
 324      *         {@code SOAPElement} object
 325      *
 326      * @since 1.6, SAAJ 1.2
 327      */
 328     public Iterator getVisibleNamespacePrefixes();
 329 
 330     /**
 331      * Creates a {@code QName} whose namespace URI is the one associated
 332      * with the parameter, {@code prefix}, in the context of this
 333      * {@code SOAPElement}. The remaining elements of the new
 334      * {@code QName} are taken directly from the parameters,
 335      * {@code localName} and {@code prefix}.
 336      *
 337      * @param localName
 338      *          a {@code String} containing the local part of the name.
 339      * @param prefix
 340      *          a {@code String} containing the prefix for the name.
 341      *
 342      * @return a {@code QName} with the specified {@code localName}
 343      *          and {@code prefix}, and with a namespace that is associated
 344      *          with the {@code prefix} in the context of this
 345      *          {@code SOAPElement}. This namespace will be the same as
 346      *          the one that would be returned by
 347      *          {@link #getNamespaceURI(String)} if it were given
 348      *          {@code prefix} as it's parameter.


 412      * @see SOAPElement#removeAttribute(Name)
 413      * @since 1.6, SAAJ 1.3
 414      */
 415     public boolean removeAttribute(QName qname);
 416 
 417     /**
 418      * Removes the namespace declaration corresponding to the given prefix.
 419      *
 420      * @param prefix a {@code String} giving the prefix for which
 421      *        to search
 422      * @return {@code true} if the namespace declaration was
 423      *         removed successfully; {@code false} if it was not
 424      */
 425     public boolean removeNamespaceDeclaration(String prefix);
 426 
 427     /**
 428      * Returns an {@code Iterator} over all the immediate child
 429      * {@link Node}s of this element. This includes {@code javax.xml.soap.Text}
 430      * objects as well as {@code SOAPElement} objects.
 431      * <p>
 432      * Calling this method may cause child {@code Element},
 433      * {@code SOAPElement} and {@code org.w3c.dom.Text} nodes to be
 434      * replaced by {@code SOAPElement}, {@code SOAPHeaderElement},
 435      * {@code SOAPBodyElement} or {@code javax.xml.soap.Text} nodes as
 436      * appropriate for the type of this parent node. As a result the calling
 437      * application must treat any existing references to these child nodes that
 438      * have been obtained through DOM APIs as invalid and either discard them or
 439      * refresh them with the values returned by this {@code Iterator}. This
 440      * behavior can be avoided by calling the equivalent DOM APIs. See
 441      * {@link javax.xml.soap}
 442      * for more details.
 443      *
 444      * @return an iterator with the content of this {@code SOAPElement}
 445      *         object
 446      */
 447     public Iterator getChildElements();
 448 
 449     /**
 450      * Returns an {@code Iterator} over all the immediate child
 451      * {@link Node}s of this element with the specified name. All of these
 452      * children will be {@code SOAPElement} nodes.
 453      * <p>
 454      * Calling this method may cause child {@code Element},
 455      * {@code SOAPElement} and {@code org.w3c.dom.Text} nodes to be
 456      * replaced by {@code SOAPElement}, {@code SOAPHeaderElement},
 457      * {@code SOAPBodyElement} or {@code javax.xml.soap.Text} nodes as
 458      * appropriate for the type of this parent node. As a result the calling
 459      * application must treat any existing references to these child nodes that
 460      * have been obtained through DOM APIs as invalid and either discard them or
 461      * refresh them with the values returned by this {@code Iterator}. This
 462      * behavior can be avoided by calling the equivalent DOM APIs. See
 463      * {@link javax.xml.soap}
 464      * for more details.
 465      *
 466      * @param name a {@code Name} object with the name of the child
 467      *        elements to be returned
 468      *
 469      * @return an {@code Iterator} object over all the elements
 470      *         in this {@code SOAPElement} object with the
 471      *         specified name
 472      * @see SOAPElement#getChildElements(javax.xml.namespace.QName)
 473      */
 474     public Iterator getChildElements(Name name);
 475 
 476     /**
 477      * Returns an {@code Iterator} over all the immediate child
 478      * {@link Node}s of this element with the specified qname. All of these
 479      * children will be {@code SOAPElement} nodes.
 480      * <p>
 481      * Calling this method may cause child {@code Element},
 482      * {@code SOAPElement} and {@code org.w3c.dom.Text} nodes to be
 483      * replaced by {@code SOAPElement}, {@code SOAPHeaderElement},
 484      * {@code SOAPBodyElement} or {@code javax.xml.soap.Text} nodes as
 485      * appropriate for the type of this parent node. As a result the calling
 486      * application must treat any existing references to these child nodes that
 487      * have been obtained through DOM APIs as invalid and either discard them or
 488      * refresh them with the values returned by this {@code Iterator}. This
 489      * behavior can be avoided by calling the equivalent DOM APIs. See
 490      * {@link javax.xml.soap}
 491      * for more details.
 492      *
 493      * @param qname a {@code QName} object with the qname of the child
 494      *        elements to be returned
 495      *
 496      * @return an {@code Iterator} object over all the elements
 497      *         in this {@code SOAPElement} object with the
 498      *         specified qname
 499      * @see SOAPElement#getChildElements(Name)
 500      * @since 1.6, SAAJ 1.3
 501      */
 502     public Iterator getChildElements(QName qname);
 503 
 504     /**
 505      * Sets the encoding style for this {@code SOAPElement} object
 506      * to one specified.
 507      *
 508      * @param encodingStyle a {@code String} giving the encoding style
 509      *
 510      * @exception IllegalArgumentException if there was a problem in the
 511      *            encoding style being set.
 512      * @exception SOAPException if setting the encodingStyle is invalid for this SOAPElement.
 513      * @see #getEncodingStyle
 514      */
 515     public void setEncodingStyle(String encodingStyle)
 516         throws SOAPException;
 517     /**
 518      * Returns the encoding style for this {@code SOAPElement} object.
 519      *
 520      * @return a {@code String} giving the encoding style
 521      *
 522      * @see #setEncodingStyle
   1 /*
   2  * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 260      *
 261      * @param qname a {@code QName} object with the qname of the attribute
 262      * @return a {@code String} giving the value of the specified
 263      *         attribute, Null if there is no such attribute
 264      * @see SOAPElement#getAttributeValue(Name)
 265      * @since 1.6, SAAJ 1.3
 266      */
 267     public String getAttributeValue(QName qname);
 268 
 269     /**
 270      * Returns an {@code Iterator} over all of the attribute
 271      * {@code Name} objects in this
 272      * {@code SOAPElement} object. The iterator can be used to get
 273      * the attribute names, which can then be passed to the method
 274      * {@code getAttributeValue} to retrieve the value of each
 275      * attribute.
 276      *
 277      * @see SOAPElement#getAllAttributesAsQNames()
 278      * @return an iterator over the names of the attributes
 279      */
 280     public Iterator<Name> getAllAttributes();
 281 
 282     /**
 283      * Returns an {@code Iterator} over all of the attributes
 284      * in this {@code SOAPElement}  as {@code QName} objects.
 285      * The iterator can be used to get the attribute QName, which can then
 286      * be passed to the method {@code getAttributeValue} to retrieve
 287      * the value of each attribute.
 288      *
 289      * @return an iterator over the QNames of the attributes
 290      * @see SOAPElement#getAllAttributes()
 291      * @since 1.6, SAAJ 1.3
 292      */
 293     public Iterator<QName> getAllAttributesAsQNames();
 294 
 295 
 296     /**
 297      * Returns the URI of the namespace that has the given prefix.
 298      *
 299      * @param prefix a {@code String} giving the prefix of the namespace
 300      *        for which to search
 301      * @return a {@code String} with the uri of the namespace that has
 302      *        the given prefix
 303      */
 304     public String getNamespaceURI(String prefix);
 305 
 306     /**
 307      * Returns an {@code Iterator} over the namespace prefix
 308      * {@code String}s declared by this element. The prefixes returned by
 309      * this iterator can be passed to the method
 310      * {@code getNamespaceURI} to retrieve the URI of each namespace.
 311      *
 312      * @return an iterator over the namespace prefixes in this
 313      *         {@code SOAPElement} object
 314      */
 315     public Iterator<String> getNamespacePrefixes();
 316 
 317     /**
 318      * Returns an {@code Iterator} over the namespace prefix
 319      * {@code String}s visible to this element. The prefixes returned by
 320      * this iterator can be passed to the method
 321      * {@code getNamespaceURI} to retrieve the URI of each namespace.
 322      *
 323      * @return an iterator over the namespace prefixes are within scope of this
 324      *         {@code SOAPElement} object
 325      *
 326      * @since 1.6, SAAJ 1.2
 327      */
 328     public Iterator<String> getVisibleNamespacePrefixes();
 329 
 330     /**
 331      * Creates a {@code QName} whose namespace URI is the one associated
 332      * with the parameter, {@code prefix}, in the context of this
 333      * {@code SOAPElement}. The remaining elements of the new
 334      * {@code QName} are taken directly from the parameters,
 335      * {@code localName} and {@code prefix}.
 336      *
 337      * @param localName
 338      *          a {@code String} containing the local part of the name.
 339      * @param prefix
 340      *          a {@code String} containing the prefix for the name.
 341      *
 342      * @return a {@code QName} with the specified {@code localName}
 343      *          and {@code prefix}, and with a namespace that is associated
 344      *          with the {@code prefix} in the context of this
 345      *          {@code SOAPElement}. This namespace will be the same as
 346      *          the one that would be returned by
 347      *          {@link #getNamespaceURI(String)} if it were given
 348      *          {@code prefix} as it's parameter.


 412      * @see SOAPElement#removeAttribute(Name)
 413      * @since 1.6, SAAJ 1.3
 414      */
 415     public boolean removeAttribute(QName qname);
 416 
 417     /**
 418      * Removes the namespace declaration corresponding to the given prefix.
 419      *
 420      * @param prefix a {@code String} giving the prefix for which
 421      *        to search
 422      * @return {@code true} if the namespace declaration was
 423      *         removed successfully; {@code false} if it was not
 424      */
 425     public boolean removeNamespaceDeclaration(String prefix);
 426 
 427     /**
 428      * Returns an {@code Iterator} over all the immediate child
 429      * {@link Node}s of this element. This includes {@code javax.xml.soap.Text}
 430      * objects as well as {@code SOAPElement} objects.
 431      * <p>
 432      * Calling this method must cause child {@code Element},
 433      * {@code SOAPElement} and {@code org.w3c.dom.Text} nodes to be
 434      * replaced by {@code SOAPElement}, {@code SOAPHeaderElement},
 435      * {@code SOAPBodyElement} or {@code javax.xml.soap.Text} nodes as
 436      * appropriate for the type of this parent node. As a result the calling
 437      * application must treat any existing references to these child nodes that
 438      * have been obtained through DOM APIs as invalid and either discard them or
 439      * refresh them with the values returned by this {@code Iterator}. This
 440      * behavior can be avoided by calling the equivalent DOM APIs. See
 441      * {@link javax.xml.soap}
 442      * for more details.
 443      *
 444      * @return an iterator with the content of this {@code SOAPElement}
 445      *         object
 446      */
 447     public Iterator<Node> getChildElements();
 448 
 449     /**
 450      * Returns an {@code Iterator} over all the immediate child
 451      * {@link Node}s of this element with the specified name. All of these
 452      * children will be {@code SOAPElement} nodes.
 453      * <p>
 454      * Calling this method must cause child {@code Element},
 455      * {@code SOAPElement} and {@code org.w3c.dom.Text} nodes to be
 456      * replaced by {@code SOAPElement}, {@code SOAPHeaderElement},
 457      * {@code SOAPBodyElement} or {@code javax.xml.soap.Text} nodes as
 458      * appropriate for the type of this parent node. As a result the calling
 459      * application must treat any existing references to these child nodes that
 460      * have been obtained through DOM APIs as invalid and either discard them or
 461      * refresh them with the values returned by this {@code Iterator}. This
 462      * behavior can be avoided by calling the equivalent DOM APIs. See
 463      * {@link javax.xml.soap}
 464      * for more details.
 465      *
 466      * @param name a {@code Name} object with the name of the child
 467      *        elements to be returned
 468      *
 469      * @return an {@code Iterator} object over all the elements
 470      *         in this {@code SOAPElement} object with the
 471      *         specified name
 472      * @see SOAPElement#getChildElements(javax.xml.namespace.QName)
 473      */
 474     public Iterator<Node> getChildElements(Name name);
 475 
 476     /**
 477      * Returns an {@code Iterator} over all the immediate child
 478      * {@link Node}s of this element with the specified qname. All of these
 479      * children will be {@code SOAPElement} nodes.
 480      * <p>
 481      * Calling this method must cause child {@code Element},
 482      * {@code SOAPElement} and {@code org.w3c.dom.Text} nodes to be
 483      * replaced by {@code SOAPElement}, {@code SOAPHeaderElement},
 484      * {@code SOAPBodyElement} or {@code javax.xml.soap.Text} nodes as
 485      * appropriate for the type of this parent node. As a result the calling
 486      * application must treat any existing references to these child nodes that
 487      * have been obtained through DOM APIs as invalid and either discard them or
 488      * refresh them with the values returned by this {@code Iterator}. This
 489      * behavior can be avoided by calling the equivalent DOM APIs. See
 490      * {@link javax.xml.soap}
 491      * for more details.
 492      *
 493      * @param qname a {@code QName} object with the qname of the child
 494      *        elements to be returned
 495      *
 496      * @return an {@code Iterator} object over all the elements
 497      *         in this {@code SOAPElement} object with the
 498      *         specified qname
 499      * @see SOAPElement#getChildElements(Name)
 500      * @since 1.6, SAAJ 1.3
 501      */
 502     public Iterator<Node> getChildElements(QName qname);
 503 
 504     /**
 505      * Sets the encoding style for this {@code SOAPElement} object
 506      * to one specified.
 507      *
 508      * @param encodingStyle a {@code String} giving the encoding style
 509      *
 510      * @exception IllegalArgumentException if there was a problem in the
 511      *            encoding style being set.
 512      * @exception SOAPException if setting the encodingStyle is invalid for this SOAPElement.
 513      * @see #getEncodingStyle
 514      */
 515     public void setEncodingStyle(String encodingStyle)
 516         throws SOAPException;
 517     /**
 518      * Returns the encoding style for this {@code SOAPElement} object.
 519      *
 520      * @return a {@code String} giving the encoding style
 521      *
 522      * @see #setEncodingStyle
< prev index next >