Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJResult.java
38890 views
/*1* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.soap;2627import javax.xml.transform.dom.DOMResult;2829/**30* Acts as a holder for the results of a JAXP transformation or a JAXB31* marshalling, in the form of a SAAJ tree. These results should be accessed32* by using the {@link #getResult()} method. The {@link DOMResult#getNode()}33* method should be avoided in almost all cases.34*35* @author XWS-Security Development Team36*37* @since SAAJ 1.338*/39public class SAAJResult extends DOMResult {4041/**42* Creates a <code>SAAJResult</code> that will present results in the form43* of a SAAJ tree that supports the default (SOAP 1.1) protocol.44* <p>45* This kind of <code>SAAJResult</code> is meant for use in situations where the46* results will be used as a parameter to a method that takes a parameter47* whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ48* API. When used in a transformation, the results are populated into the49* <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created internally.50* The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}51* is not guaranteed to be well-formed.52*53* @throws SOAPException if there is a problem creating a <code>SOAPMessage</code>54*55* @since SAAJ 1.356*/57public SAAJResult() throws SOAPException {58this(MessageFactory.newInstance().createMessage());59}6061/**62* Creates a <code>SAAJResult</code> that will present results in the form63* of a SAAJ tree that supports the specified protocol. The64* <code>DYNAMIC_SOAP_PROTOCOL</code> is ambiguous in this context and will65* cause this constructor to throw an <code>UnsupportedOperationException</code>.66* <p>67* This kind of <code>SAAJResult</code> is meant for use in situations where the68* results will be used as a parameter to a method that takes a parameter69* whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ70* API. When used in a transformation the results are populated into the71* <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created72* internally. The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}73* is not guaranteed to be well-formed.74*75* @param protocol - the name of the SOAP protocol that the resulting SAAJ76* tree should support77*78* @throws SOAPException if a <code>SOAPMessage</code> supporting the79* specified protocol cannot be created80*81* @since SAAJ 1.382*/83public SAAJResult(String protocol) throws SOAPException {84this(MessageFactory.newInstance(protocol).createMessage());85}8687/**88* Creates a <code>SAAJResult</code> that will write the results into the89* <code>SOAPPart</code> of the supplied <code>SOAPMessage</code>.90* In the normal case these results will be written using DOM APIs and,91* as a result, the finished <code>SOAPPart</code> will not be guaranteed92* to be well-formed unless the data used to create it is also well formed.93* When used in a transformation the validity of the <code>SOAPMessage</code>94* after the transformation can be guaranteed only by means outside SAAJ95* specification.96*97* @param message - the message whose <code>SOAPPart</code> will be98* populated as a result of some transformation or99* marshalling operation100*101* @since SAAJ 1.3102*/103public SAAJResult(SOAPMessage message) {104super(message.getSOAPPart());105}106107/**108* Creates a <code>SAAJResult</code> that will write the results as a109* child node of the <code>SOAPElement</code> specified. In the normal110* case these results will be written using DOM APIs and as a result may111* invalidate the structure of the SAAJ tree. This kind of112* <code>SAAJResult</code> should only be used when the validity of the113* incoming data can be guaranteed by means outside of the SAAJ114* specification.115*116* @param rootNode - the root to which the results will be appended117*118* @since SAAJ 1.3119*/120public SAAJResult(SOAPElement rootNode) {121super(rootNode);122}123124125/**126* @return the resulting Tree that was created under the specified root Node.127* @since SAAJ 1.3128*/129public javax.xml.soap.Node getResult() {130return (javax.xml.soap.Node)super.getNode().getFirstChild();131}132}133134135