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 javax.xml.transform.dom.DOMResult;
325N/A
325N/A/**
325N/A * Acts as a holder for the results of a JAXP transformation or a JAXB
325N/A * marshalling, in the form of a SAAJ tree. These results should be accessed
325N/A * by using the {@link #getResult()} method. The {@link DOMResult#getNode()}
325N/A * method should be avoided in almost all cases.
325N/A *
325N/A * @author XWS-Security Development Team
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/Apublic class SAAJResult extends DOMResult {
325N/A
325N/A /**
325N/A * Creates a <code>SAAJResult</code> that will present results in the form
325N/A * of a SAAJ tree that supports the default (SOAP 1.1) protocol.
325N/A * <p>
325N/A * This kind of <code>SAAJResult</code> is meant for use in situations where the
325N/A * results will be used as a parameter to a method that takes a parameter
325N/A * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ
325N/A * API. When used in a transformation, the results are populated into the
325N/A * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created internally.
325N/A * The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}
325N/A * is not guaranteed to be well-formed.
325N/A *
325N/A * @throws SOAPException if there is a problem creating a <code>SOAPMessage</code>
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SAAJResult() throws SOAPException {
325N/A this(MessageFactory.newInstance().createMessage());
325N/A }
325N/A
325N/A /**
325N/A * Creates a <code>SAAJResult</code> that will present results in the form
325N/A * of a SAAJ tree that supports the specified protocol. The
325N/A * <code>DYNAMIC_SOAP_PROTOCOL</code> is ambiguous in this context and will
325N/A * cause this constructor to throw an <code>UnsupportedOperationException</code>.
325N/A * <p>
325N/A * This kind of <code>SAAJResult</code> is meant for use in situations where the
325N/A * results will be used as a parameter to a method that takes a parameter
325N/A * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ
325N/A * API. When used in a transformation the results are populated into the
325N/A * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created
325N/A * internally. The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}
325N/A * is not guaranteed to be well-formed.
325N/A *
325N/A * @param protocol - the name of the SOAP protocol that the resulting SAAJ
325N/A * tree should support
325N/A *
325N/A * @throws SOAPException if a <code>SOAPMessage</code> supporting the
325N/A * specified protocol cannot be created
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SAAJResult(String protocol) throws SOAPException {
325N/A this(MessageFactory.newInstance(protocol).createMessage());
325N/A }
325N/A
325N/A /**
325N/A * Creates a <code>SAAJResult</code> that will write the results into the
325N/A * <code>SOAPPart</code> of the supplied <code>SOAPMessage</code>.
325N/A * In the normal case these results will be written using DOM APIs and,
325N/A * as a result, the finished <code>SOAPPart</code> will not be guaranteed
325N/A * to be well-formed unless the data used to create it is also well formed.
325N/A * When used in a transformation the validity of the <code>SOAPMessage</code>
325N/A * after the transformation can be guaranteed only by means outside SAAJ
325N/A * specification.
325N/A *
325N/A * @param message - the message whose <code>SOAPPart</code> will be
325N/A * populated as a result of some transformation or
325N/A * marshalling operation
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SAAJResult(SOAPMessage message) {
325N/A super(message.getSOAPPart());
325N/A }
325N/A
325N/A /**
325N/A * Creates a <code>SAAJResult</code> that will write the results as a
325N/A * child node of the <code>SOAPElement</code> specified. In the normal
325N/A * case these results will be written using DOM APIs and as a result may
325N/A * invalidate the structure of the SAAJ tree. This kind of
325N/A * <code>SAAJResult</code> should only be used when the validity of the
325N/A * incoming data can be guaranteed by means outside of the SAAJ
325N/A * specification.
325N/A *
325N/A * @param rootNode - the root to which the results will be appended
325N/A *
325N/A * @since SAAJ 1.3
325N/A */
325N/A public SAAJResult(SOAPElement rootNode) {
325N/A super(rootNode);
325N/A }
325N/A
325N/A
325N/A /**
325N/A * @return the resulting Tree that was created under the specified root Node.
325N/A * @since SAAJ 1.3
325N/A */
325N/A public javax.xml.soap.Node getResult() {
325N/A return (javax.xml.soap.Node)super.getNode().getFirstChild();
325N/A }
325N/A}