src/share/jaxws_classes/javax/xml/soap/SAAJResult.java

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/javax/xml/soap/SAAJResult.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,133 @@
     1.4 +/*
     1.5 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package javax.xml.soap;
    1.30 +
    1.31 +import javax.xml.transform.dom.DOMResult;
    1.32 +
    1.33 +/**
    1.34 + * Acts as a holder for the results of a JAXP transformation or a JAXB
    1.35 + * marshalling, in the form of a SAAJ tree. These results should be accessed
    1.36 + * by using the {@link #getResult()} method. The {@link DOMResult#getNode()}
    1.37 + * method should be avoided in almost all cases.
    1.38 + *
    1.39 + * @author XWS-Security Development Team
    1.40 + *
    1.41 + * @since SAAJ 1.3
    1.42 + */
    1.43 +public class SAAJResult extends DOMResult {
    1.44 +
    1.45 +    /**
    1.46 +     * Creates a <code>SAAJResult</code> that will present results in the form
    1.47 +     * of a SAAJ tree that supports the default (SOAP 1.1) protocol.
    1.48 +     * <p>
    1.49 +     * This kind of <code>SAAJResult</code> is meant for use in situations where the
    1.50 +     * results will be used as a parameter to a method that takes a parameter
    1.51 +     * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ
    1.52 +     * API. When used in a transformation, the results are populated into the
    1.53 +     * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created internally.
    1.54 +     * The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}
    1.55 +     * is not guaranteed to be well-formed.
    1.56 +     *
    1.57 +     * @throws SOAPException if there is a problem creating a <code>SOAPMessage</code>
    1.58 +     *
    1.59 +     * @since SAAJ 1.3
    1.60 +     */
    1.61 +    public SAAJResult() throws SOAPException {
    1.62 +        this(MessageFactory.newInstance().createMessage());
    1.63 +    }
    1.64 +
    1.65 +    /**
    1.66 +     * Creates a <code>SAAJResult</code> that will present results in the form
    1.67 +     * of a SAAJ tree that supports the specified protocol. The
    1.68 +     * <code>DYNAMIC_SOAP_PROTOCOL</code> is ambiguous in this context and will
    1.69 +     * cause this constructor to throw an <code>UnsupportedOperationException</code>.
    1.70 +     * <p>
    1.71 +     * This kind of <code>SAAJResult</code> is meant for use in situations where the
    1.72 +     * results will be used as a parameter to a method that takes a parameter
    1.73 +     * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ
    1.74 +     * API. When used in a transformation the results are populated into the
    1.75 +     * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created
    1.76 +     * internally. The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}
    1.77 +     * is not guaranteed to be well-formed.
    1.78 +     *
    1.79 +     * @param protocol - the name of the SOAP protocol that the resulting SAAJ
    1.80 +     *                      tree should support
    1.81 +     *
    1.82 +     * @throws SOAPException if a <code>SOAPMessage</code> supporting the
    1.83 +     *             specified protocol cannot be created
    1.84 +     *
    1.85 +     * @since SAAJ 1.3
    1.86 +     */
    1.87 +    public SAAJResult(String protocol) throws SOAPException {
    1.88 +        this(MessageFactory.newInstance(protocol).createMessage());
    1.89 +    }
    1.90 +
    1.91 +    /**
    1.92 +     * Creates a <code>SAAJResult</code> that will write the results into the
    1.93 +     * <code>SOAPPart</code> of the supplied <code>SOAPMessage</code>.
    1.94 +     * In the normal case these results will be written using DOM APIs and,
    1.95 +     * as a result, the finished <code>SOAPPart</code> will not be guaranteed
    1.96 +     * to be well-formed unless the data used to create it is also well formed.
    1.97 +     * When used in a transformation the validity of the <code>SOAPMessage</code>
    1.98 +     * after the transformation can be guaranteed only by means outside SAAJ
    1.99 +     * specification.
   1.100 +     *
   1.101 +     * @param message - the message whose <code>SOAPPart</code> will be
   1.102 +     *                  populated as a result of some transformation or
   1.103 +     *                  marshalling operation
   1.104 +     *
   1.105 +     * @since SAAJ 1.3
   1.106 +     */
   1.107 +    public SAAJResult(SOAPMessage message) {
   1.108 +        super(message.getSOAPPart());
   1.109 +    }
   1.110 +
   1.111 +    /**
   1.112 +     * Creates a <code>SAAJResult</code> that will write the results as a
   1.113 +     * child node of the <code>SOAPElement</code> specified. In the normal
   1.114 +     * case these results will be written using DOM APIs and as a result may
   1.115 +     * invalidate the structure of the SAAJ tree. This kind of
   1.116 +     * <code>SAAJResult</code> should only be used when the validity of the
   1.117 +     * incoming data can be guaranteed by means outside of the SAAJ
   1.118 +     * specification.
   1.119 +     *
   1.120 +     * @param rootNode - the root to which the results will be appended
   1.121 +     *
   1.122 +     * @since SAAJ 1.3
   1.123 +     */
   1.124 +    public SAAJResult(SOAPElement rootNode) {
   1.125 +        super(rootNode);
   1.126 +    }
   1.127 +
   1.128 +
   1.129 +    /**
   1.130 +     * @return the resulting Tree that was created under the specified root Node.
   1.131 +     * @since SAAJ 1.3
   1.132 +     */
   1.133 +    public javax.xml.soap.Node getResult() {
   1.134 +        return (javax.xml.soap.Node)super.getNode().getFirstChild();
   1.135 +     }
   1.136 +}

mercurial