325N/A/*
325N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage javax.xml.soap;
325N/A
325N/Aimport java.util.Iterator;
325N/A
325N/Aimport javax.xml.namespace.QName;
325N/A
325N/A/**
325N/A * An object representing an element of a SOAP message that is allowed but not
325N/A * specifically prescribed by a SOAP specification. This interface serves as the
325N/A * base interface for those objects that are specifically prescribed by a SOAP
325N/A * specification.
325N/A * <p>
325N/A * Methods in this interface that are required to return SAAJ specific objects
325N/A * may "silently" replace nodes in the tree as required to successfully return
325N/A * objects of the correct type. See {@link #getChildElements()} and
325N/A * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
325N/A * for details.
325N/A */
325N/Apublic interface SOAPElement extends Node, org.w3c.dom.Element {
325N/A
325N/A /**
325N/A * Creates a new <code>SOAPElement</code> object initialized with the
325N/A * given <code>Name</code> object and adds the new element to this
325N/A * <code>SOAPElement</code> object.
325N/A * <P>
325N/A * This method may be deprecated in a future release of SAAJ in favor of
325N/A * addChildElement(javax.xml.namespace.QName)
325N/A *
325N/A * @param name a <code>Name</code> object with the XML name for the
325N/A * new element
325N/A *
325N/A * @return the new <code>SOAPElement</code> object that was created
325N/A * @exception SOAPException if there is an error in creating the
325N/A * <code>SOAPElement</code> object
325N/A * @see SOAPElement#addChildElement(javax.xml.namespace.QName)
325N/A */
325N/A public SOAPElement addChildElement(Name name) throws SOAPException;
325N/A
325N/A /**
325N/A * Creates a new <code>SOAPElement</code> object initialized with the given
325N/A * <code>QName</code> object and adds the new element to this <code>SOAPElement</code>
325N/A * object. The <i>namespace</i>, <i>localname</i> and <i>prefix</i> of the new
325N/A * <code>SOAPElement</code> are all taken from the <code>qname</code> argument.
325N/A *
325N/A * @param qname a <code>QName</code> object with the XML name for the
325N/A * new element
325N/A *
325N/A * @return the new <code>SOAPElement</code> object that was created
325N/A * @exception SOAPException if there is an error in creating the
325N/A * <code>SOAPElement</code> object
325N/A * @see SOAPElement#addChildElement(Name)
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SOAPElement addChildElement(QName qname) throws SOAPException;
325N/A
325N/A /**
325N/A * Creates a new <code>SOAPElement</code> object initialized with the
325N/A * specified local name and adds the new element to this
325N/A * <code>SOAPElement</code> object.
325N/A * The new <code>SOAPElement</code> inherits any in-scope default namespace.
325N/A *
325N/A * @param localName a <code>String</code> giving the local name for
325N/A * the element
325N/A * @return the new <code>SOAPElement</code> object that was created
325N/A * @exception SOAPException if there is an error in creating the
325N/A * <code>SOAPElement</code> object
325N/A */
325N/A public SOAPElement addChildElement(String localName) throws SOAPException;
325N/A
325N/A /**
325N/A * Creates a new <code>SOAPElement</code> object initialized with the
325N/A * specified local name and prefix and adds the new element to this
325N/A * <code>SOAPElement</code> object.
325N/A *
325N/A * @param localName a <code>String</code> giving the local name for
325N/A * the new element
325N/A * @param prefix a <code>String</code> giving the namespace prefix for
325N/A * the new element
325N/A *
325N/A * @return the new <code>SOAPElement</code> object that was created
325N/A * @exception SOAPException if the <code>prefix</code> is not valid in the
325N/A * context of this <code>SOAPElement</code> or if there is an error in creating the
325N/A * <code>SOAPElement</code> object
325N/A */
325N/A public SOAPElement addChildElement(String localName, String prefix)
325N/A throws SOAPException;
325N/A
325N/A /**
325N/A * Creates a new <code>SOAPElement</code> object initialized with the
325N/A * specified local name, prefix, and URI and adds the new element to this
325N/A * <code>SOAPElement</code> object.
325N/A *
325N/A * @param localName a <code>String</code> giving the local name for
325N/A * the new element
325N/A * @param prefix a <code>String</code> giving the namespace prefix for
325N/A * the new element
325N/A * @param uri a <code>String</code> giving the URI of the namespace
325N/A * to which the new element belongs
325N/A *
325N/A * @return the new <code>SOAPElement</code> object that was created
325N/A * @exception SOAPException if there is an error in creating the
325N/A * <code>SOAPElement</code> object
325N/A */
325N/A public SOAPElement addChildElement(String localName, String prefix,
325N/A String uri)
325N/A throws SOAPException;
325N/A
325N/A /**
325N/A * Add a <code>SOAPElement</code> as a child of this
325N/A * <code>SOAPElement</code> instance. The <code>SOAPElement</code>
325N/A * is expected to be created by a
325N/A * <code>SOAPFactory</code>. Callers should not rely on the
325N/A * element instance being added as is into the XML
325N/A * tree. Implementations could end up copying the content
325N/A * of the <code>SOAPElement</code> passed into an instance of
325N/A * a different <code>SOAPElement</code> implementation. For
325N/A * instance if <code>addChildElement()</code> is called on a
325N/A * <code>SOAPHeader</code>, <code>element</code> will be copied
325N/A * into an instance of a <code>SOAPHeaderElement</code>.
325N/A *
325N/A * <P>The fragment rooted in <code>element</code> is either added
325N/A * as a whole or not at all, if there was an error.
325N/A *
325N/A * <P>The fragment rooted in <code>element</code> cannot contain
325N/A * elements named "Envelope", "Header" or "Body" and in the SOAP
325N/A * namespace. Any namespace prefixes present in the fragment
325N/A * should be fully resolved using appropriate namespace
325N/A * declarations within the fragment itself.
325N/A *
325N/A * @param element the <code>SOAPElement</code> to be added as a
325N/A * new child
325N/A *
325N/A * @exception SOAPException if there was an error in adding this
325N/A * element as a child
325N/A *
325N/A * @return an instance representing the new SOAP element that was
325N/A * actually added to the tree.
325N/A */
325N/A public SOAPElement addChildElement(SOAPElement element)
325N/A throws SOAPException;
325N/A
325N/A /**
325N/A * Detaches all children of this <code>SOAPElement</code>.
325N/A * <p>
325N/A * This method is useful for rolling back the construction of partially
325N/A * completed <code>SOAPHeaders</code> and <code>SOAPBodys</code> in
325N/A * preparation for sending a fault when an error condition is detected. It
325N/A * is also useful for recycling portions of a document within a SOAP
325N/A * message.
325N/A *
325N/A * @since SAAJ 1.2
325N/A */
325N/A public abstract void removeContents();
325N/A
325N/A /**
325N/A * Creates a new <code>Text</code> object initialized with the given
325N/A * <code>String</code> and adds it to this <code>SOAPElement</code> object.
325N/A *
325N/A * @param text a <code>String</code> object with the textual content to be added
325N/A *
325N/A * @return the <code>SOAPElement</code> object into which
325N/A * the new <code>Text</code> object was inserted
325N/A * @exception SOAPException if there is an error in creating the
325N/A * new <code>Text</code> object or if it is not legal to
325N/A * attach it as a child to this
325N/A * <code>SOAPElement</code>
325N/A */
325N/A public SOAPElement addTextNode(String text) throws SOAPException;
325N/A
325N/A /**
325N/A * Adds an attribute with the specified name and value to this
325N/A * <code>SOAPElement</code> object.
325N/A *
325N/A * @param name a <code>Name</code> object with the name of the attribute
325N/A * @param value a <code>String</code> giving the value of the attribute
325N/A * @return the <code>SOAPElement</code> object into which the attribute was
325N/A * inserted
325N/A *
325N/A * @exception SOAPException if there is an error in creating the
325N/A * Attribute, or it is invalid to set
325N/A an attribute with <code>Name</code>
325N/A <code>name</code> on this SOAPElement.
325N/A * @see SOAPElement#addAttribute(javax.xml.namespace.QName, String)
325N/A */
325N/A public SOAPElement addAttribute(Name name, String value)
325N/A throws SOAPException;
325N/A
325N/A /**
325N/A * Adds an attribute with the specified name and value to this
325N/A * <code>SOAPElement</code> object.
325N/A *
325N/A * @param qname a <code>QName</code> object with the name of the attribute
325N/A * @param value a <code>String</code> giving the value of the attribute
325N/A * @return the <code>SOAPElement</code> object into which the attribute was
325N/A * inserted
325N/A *
325N/A * @exception SOAPException if there is an error in creating the
325N/A * Attribute, or it is invalid to set
325N/A an attribute with <code>QName</code>
325N/A <code>qname</code> on this SOAPElement.
325N/A * @see SOAPElement#addAttribute(Name, String)
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SOAPElement addAttribute(QName qname, String value)
325N/A throws SOAPException;
325N/A
325N/A /**
325N/A * Adds a namespace declaration with the specified prefix and URI to this
325N/A * <code>SOAPElement</code> object.
325N/A *
325N/A * @param prefix a <code>String</code> giving the prefix of the namespace
325N/A * @param uri a <code>String</code> giving the uri of the namespace
325N/A * @return the <code>SOAPElement</code> object into which this
325N/A * namespace declaration was inserted.
325N/A *
325N/A * @exception SOAPException if there is an error in creating the
325N/A * namespace
325N/A */
325N/A public SOAPElement addNamespaceDeclaration(String prefix, String uri)
325N/A throws SOAPException;
325N/A
325N/A /**
325N/A * Returns the value of the attribute with the specified name.
325N/A *
325N/A * @param name a <code>Name</code> object with the name of the attribute
325N/A * @return a <code>String</code> giving the value of the specified
325N/A * attribute, Null if there is no such attribute
325N/A * @see SOAPElement#getAttributeValue(javax.xml.namespace.QName)
325N/A */
325N/A public String getAttributeValue(Name name);
325N/A
325N/A /**
325N/A * Returns the value of the attribute with the specified qname.
325N/A *
325N/A * @param qname a <code>QName</code> object with the qname of the attribute
325N/A * @return a <code>String</code> giving the value of the specified
325N/A * attribute, Null if there is no such attribute
325N/A * @see SOAPElement#getAttributeValue(Name)
325N/A * @since SAAJ 1.3
325N/A */
325N/A public String getAttributeValue(QName qname);
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over all of the attribute
325N/A * <code>Name</code> objects in this
325N/A * <code>SOAPElement</code> object. The iterator can be used to get
325N/A * the attribute names, which can then be passed to the method
325N/A * <code>getAttributeValue</code> to retrieve the value of each
325N/A * attribute.
325N/A *
325N/A * @see SOAPElement#getAllAttributesAsQNames()
325N/A * @return an iterator over the names of the attributes
325N/A */
325N/A public Iterator getAllAttributes();
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over all of the attributes
325N/A * in this <code>SOAPElement</code> as <code>QName</code> objects.
325N/A * The iterator can be used to get the attribute QName, which can then
325N/A * be passed to the method <code>getAttributeValue</code> to retrieve
325N/A * the value of each attribute.
325N/A *
325N/A * @return an iterator over the QNames of the attributes
325N/A * @see SOAPElement#getAllAttributes()
325N/A * @since SAAJ 1.3
325N/A */
325N/A public Iterator getAllAttributesAsQNames();
325N/A
325N/A
325N/A /**
325N/A * Returns the URI of the namespace that has the given prefix.
325N/A *
325N/A * @param prefix a <code>String</code> giving the prefix of the namespace
325N/A * for which to search
325N/A * @return a <code>String</code> with the uri of the namespace that has
325N/A * the given prefix
325N/A */
325N/A public String getNamespaceURI(String prefix);
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over the namespace prefix
325N/A * <code>String</code>s declared by this element. The prefixes returned by
325N/A * this iterator can be passed to the method
325N/A * <code>getNamespaceURI</code> to retrieve the URI of each namespace.
325N/A *
325N/A * @return an iterator over the namespace prefixes in this
325N/A * <code>SOAPElement</code> object
325N/A */
325N/A public Iterator getNamespacePrefixes();
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over the namespace prefix
325N/A * <code>String</code>s visible to this element. The prefixes returned by
325N/A * this iterator can be passed to the method
325N/A * <code>getNamespaceURI</code> to retrieve the URI of each namespace.
325N/A *
325N/A * @return an iterator over the namespace prefixes are within scope of this
325N/A * <code>SOAPElement</code> object
325N/A *
325N/A * @since SAAJ 1.2
325N/A */
325N/A public Iterator getVisibleNamespacePrefixes();
325N/A
325N/A /**
325N/A * Creates a <code>QName</code> whose namespace URI is the one associated
325N/A * with the parameter, <code>prefix</code>, in the context of this
325N/A * <code>SOAPElement</code>. The remaining elements of the new
325N/A * <code>QName</code> are taken directly from the parameters,
325N/A * <code>localName</code> and <code>prefix</code>.
325N/A *
325N/A * @param localName
325N/A * a <code>String</code> containing the local part of the name.
325N/A * @param prefix
325N/A * a <code>String</code> containing the prefix for the name.
325N/A *
325N/A * @return a <code>QName</code> with the specified <code>localName</code>
325N/A * and <code>prefix</code>, and with a namespace that is associated
325N/A * with the <code>prefix</code> in the context of this
325N/A * <code>SOAPElement</code>. This namespace will be the same as
325N/A * the one that would be returned by
325N/A * <code>{@link #getNamespaceURI(String)}</code> if it were given
325N/A * <code>prefix</code> as it's parameter.
325N/A *
325N/A * @exception SOAPException if the <code>QName</code> cannot be created.
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/A public QName createQName(String localName, String prefix)
325N/A throws SOAPException;
325N/A /**
325N/A * Returns the name of this <code>SOAPElement</code> object.
325N/A *
325N/A * @return a <code>Name</code> object with the name of this
325N/A * <code>SOAPElement</code> object
325N/A */
325N/A public Name getElementName();
325N/A
325N/A /**
325N/A * Returns the qname of this <code>SOAPElement</code> object.
325N/A *
325N/A * @return a <code>QName</code> object with the qname of this
325N/A * <code>SOAPElement</code> object
325N/A * @see SOAPElement#getElementName()
325N/A * @since SAAJ 1.3
325N/A */
325N/A public QName getElementQName();
325N/A
325N/A /**
325N/A * Changes the name of this <code>Element</code> to <code>newName</code> if
325N/A * possible. SOAP Defined elements such as SOAPEnvelope, SOAPHeader, SOAPBody
325N/A * etc. cannot have their names changed using this method. Any attempt to do
325N/A * so will result in a SOAPException being thrown.
325N/A *<P>
325N/A * Callers should not rely on the element instance being renamed as is.
325N/A * Implementations could end up copying the content of the
325N/A * <code>SOAPElement</code> to a renamed instance.
325N/A *
325N/A * @param newName the new name for the <code>Element</code>.
325N/A *
325N/A * @exception SOAPException if changing the name of this <code>Element</code>
325N/A * is not allowed.
325N/A * @return The renamed Node
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SOAPElement setElementQName(QName newName) throws SOAPException;
325N/A
325N/A /**
325N/A * Removes the attribute with the specified name.
325N/A *
325N/A * @param name the <code>Name</code> object with the name of the
325N/A * attribute to be removed
325N/A * @return <code>true</code> if the attribute was
325N/A * removed successfully; <code>false</code> if it was not
325N/A * @see SOAPElement#removeAttribute(javax.xml.namespace.QName)
325N/A */
325N/A public boolean removeAttribute(Name name);
325N/A
325N/A /**
325N/A * Removes the attribute with the specified qname.
325N/A *
325N/A * @param qname the <code>QName</code> object with the qname of the
325N/A * attribute to be removed
325N/A * @return <code>true</code> if the attribute was
325N/A * removed successfully; <code>false</code> if it was not
325N/A * @see SOAPElement#removeAttribute(Name)
325N/A * @since SAAJ 1.3
325N/A */
325N/A public boolean removeAttribute(QName qname);
325N/A
325N/A /**
325N/A * Removes the namespace declaration corresponding to the given prefix.
325N/A *
325N/A * @param prefix a <code>String</code> giving the prefix for which
325N/A * to search
325N/A * @return <code>true</code> if the namespace declaration was
325N/A * removed successfully; <code>false</code> if it was not
325N/A */
325N/A public boolean removeNamespaceDeclaration(String prefix);
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over all the immediate child
325N/A * {@link Node}s of this element. This includes <code>javax.xml.soap.Text</code>
325N/A * objects as well as <code>SOAPElement</code> objects.
325N/A * <p>
325N/A * Calling this method may cause child <code>Element</code>,
325N/A * <code>SOAPElement</code> and <code>org.w3c.dom.Text</code> nodes to be
325N/A * replaced by <code>SOAPElement</code>, <code>SOAPHeaderElement</code>,
325N/A * <code>SOAPBodyElement</code> or <code>javax.xml.soap.Text</code> nodes as
325N/A * appropriate for the type of this parent node. As a result the calling
325N/A * application must treat any existing references to these child nodes that
325N/A * have been obtained through DOM APIs as invalid and either discard them or
325N/A * refresh them with the values returned by this <code>Iterator</code>. This
325N/A * behavior can be avoided by calling the equivalent DOM APIs. See
325N/A * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
325N/A * for more details.
325N/A *
325N/A * @return an iterator with the content of this <code>SOAPElement</code>
325N/A * object
325N/A */
325N/A public Iterator getChildElements();
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over all the immediate child
325N/A * {@link Node}s of this element with the specified name. All of these
325N/A * children will be <code>SOAPElement</code> nodes.
325N/A * <p>
325N/A * Calling this method may cause child <code>Element</code>,
325N/A * <code>SOAPElement</code> and <code>org.w3c.dom.Text</code> nodes to be
325N/A * replaced by <code>SOAPElement</code>, <code>SOAPHeaderElement</code>,
325N/A * <code>SOAPBodyElement</code> or <code>javax.xml.soap.Text</code> nodes as
325N/A * appropriate for the type of this parent node. As a result the calling
325N/A * application must treat any existing references to these child nodes that
325N/A * have been obtained through DOM APIs as invalid and either discard them or
325N/A * refresh them with the values returned by this <code>Iterator</code>. This
325N/A * behavior can be avoided by calling the equivalent DOM APIs. See
325N/A * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
325N/A * for more details.
325N/A *
325N/A * @param name a <code>Name</code> object with the name of the child
325N/A * elements to be returned
325N/A *
325N/A * @return an <code>Iterator</code> object over all the elements
325N/A * in this <code>SOAPElement</code> object with the
325N/A * specified name
325N/A * @see SOAPElement#getChildElements(javax.xml.namespace.QName)
325N/A */
325N/A public Iterator getChildElements(Name name);
325N/A
325N/A /**
325N/A * Returns an <code>Iterator</code> over all the immediate child
325N/A * {@link Node}s of this element with the specified qname. All of these
325N/A * children will be <code>SOAPElement</code> nodes.
325N/A * <p>
325N/A * Calling this method may cause child <code>Element</code>,
325N/A * <code>SOAPElement</code> and <code>org.w3c.dom.Text</code> nodes to be
325N/A * replaced by <code>SOAPElement</code>, <code>SOAPHeaderElement</code>,
325N/A * <code>SOAPBodyElement</code> or <code>javax.xml.soap.Text</code> nodes as
325N/A * appropriate for the type of this parent node. As a result the calling
325N/A * application must treat any existing references to these child nodes that
325N/A * have been obtained through DOM APIs as invalid and either discard them or
325N/A * refresh them with the values returned by this <code>Iterator</code>. This
325N/A * behavior can be avoided by calling the equivalent DOM APIs. See
325N/A * {@link <a HREF="package-summary.html#package_description">javax.xml.soap<a>}
325N/A * for more details.
325N/A *
325N/A * @param qname a <code>QName</code> object with the qname of the child
325N/A * elements to be returned
325N/A *
325N/A * @return an <code>Iterator</code> object over all the elements
325N/A * in this <code>SOAPElement</code> object with the
325N/A * specified qname
325N/A * @see SOAPElement#getChildElements(Name)
325N/A * @since SAAJ 1.3
325N/A */
325N/A public Iterator getChildElements(QName qname);
325N/A
325N/A /**
325N/A * Sets the encoding style for this <code>SOAPElement</code> object
325N/A * to one specified.
325N/A *
325N/A * @param encodingStyle a <code>String</code> giving the encoding style
325N/A *
325N/A * @exception IllegalArgumentException if there was a problem in the
325N/A * encoding style being set.
325N/A * @exception SOAPException if setting the encodingStyle is invalid for this SOAPElement.
325N/A * @see #getEncodingStyle
325N/A */
325N/A public void setEncodingStyle(String encodingStyle)
325N/A throws SOAPException;
325N/A /**
325N/A * Returns the encoding style for this <code>SOAPElement</code> object.
325N/A *
325N/A * @return a <code>String</code> giving the encoding style
325N/A *
325N/A * @see #setEncodingStyle
325N/A */
325N/A public String getEncodingStyle();
325N/A}