KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > soap > SAAJResult


1 /*
2  * $Id: SAAJResult.java,v 1.4 2006/03/24 13:05:43 vj135062 Exp $
3  */

4
5 /*
6  * The contents of this file are subject to the terms
7  * of the Common Development and Distribution License
8  * (the License). You may not use this file except in
9  * compliance with the License.
10  *
11  * You can obtain a copy of the license at
12  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
13  * See the License for the specific language governing
14  * permissions and limitations under the License.
15  *
16  * When distributing Covered Code, include this CDDL
17  * Header Notice in each file and include the License file
18  * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
19  * If applicable, add the following below the CDDL Header,
20  * with the fields enclosed by brackets [] replaced by
21  * you own identifying information:
22  * "Portions Copyrighted [year] [name of copyright owner]"
23  *
24  * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
25  */

26
27 package javax.xml.soap;
28
29 import javax.xml.transform.dom.DOMResult JavaDoc;
30
31 /**
32  * Acts as a holder for the results of a JAXP transformation or a JAXB
33  * marshalling, in the form of a SAAJ tree. These results should be accessed
34  * by using the {@link #getResult()} method. The {@link DOMResult#getNode()}
35  * method should be avoided in almost all cases.
36  *
37  * @author XWS-Security Development Team
38  *
39  * @since SAAJ 1.3
40  */

41 public class SAAJResult extends DOMResult JavaDoc {
42     
43     /**
44      * Creates a <code>SAAJResult</code> that will present results in the form
45      * of a SAAJ tree that supports the default (SOAP 1.1) protocol.
46      * <p>
47      * This kind of <code>SAAJResult</code> is meant for use in situations where the
48      * results will be used as a parameter to a method that takes a parameter
49      * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ
50      * API. When used in a transformation, the results are populated into the
51      * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created internally.
52      * The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}
53      * is not guaranteed to be well-formed.
54      *
55      * @throws SOAPException if there is a problem creating a <code>SOAPMessage</code>
56      *
57      * @since SAAJ 1.3
58      */

59     public SAAJResult() throws SOAPException JavaDoc {
60         this(MessageFactory.newInstance().createMessage());
61     }
62     
63     /**
64      * Creates a <code>SAAJResult</code> that will present results in the form
65      * of a SAAJ tree that supports the specified protocol. The
66      * <code>DYNAMIC_SOAP_PROTOCOL</code> is ambiguous in this context and will
67      * cause this constructor to throw an <code>UnsupportedOperationException</code>.
68      * <p>
69      * This kind of <code>SAAJResult</code> is meant for use in situations where the
70      * results will be used as a parameter to a method that takes a parameter
71      * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ
72      * API. When used in a transformation the results are populated into the
73      * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created
74      * internally. The <code>SOAPPart</code> returned by {@link DOMResult#getNode()}
75      * is not guaranteed to be well-formed.
76      *
77      * @param protocol - the name of the SOAP protocol that the resulting SAAJ
78      * tree should support
79      *
80      * @throws SOAPException if a <code>SOAPMessage</code> supporting the
81      * specified protocol cannot be created
82      *
83      * @since SAAJ 1.3
84      */

85     public SAAJResult(String JavaDoc protocol) throws SOAPException JavaDoc {
86         this(MessageFactory.newInstance(protocol).createMessage());
87     }
88     
89     /**
90      * Creates a <code>SAAJResult</code> that will write the results into the
91      * <code>SOAPPart</code> of the supplied <code>SOAPMessage</code>.
92      * In the normal case these results will be written using DOM APIs and,
93      * as a result, the finished <code>SOAPPart</code> will not be guaranteed
94      * to be well-formed unless the data used to create it is also well formed.
95      * When used in a transformation the validity of the <code>SOAPMessage</code>
96      * after the transformation can be guaranteed only by means outside SAAJ
97      * specification.
98      *
99      * @param message - the message whose <code>SOAPPart</code> will be
100      * populated as a result of some transformation or
101      * marshalling operation
102      *
103      * @since SAAJ 1.3
104      */

105     public SAAJResult(SOAPMessage JavaDoc message) {
106         super(message.getSOAPPart());
107     }
108     
109     /**
110      * Creates a <code>SAAJResult</code> that will write the results as a
111      * child node of the <code>SOAPElement</code> specified. In the normal
112      * case these results will be written using DOM APIs and as a result may
113      * invalidate the structure of the SAAJ tree. This kind of
114      * <code>SAAJResult</code> should only be used when the validity of the
115      * incoming data can be guaranteed by means outside of the SAAJ
116      * specification.
117      *
118      * @param rootNode - the root to which the results will be appended
119      *
120      * @since SAAJ 1.3
121      */

122     public SAAJResult(SOAPElement JavaDoc rootNode) {
123         super(rootNode);
124     }
125     
126   
127     /**
128      * @return the resulting Tree that was created under the specified root Node.
129      * @since SAAJ 1.3
130      */

131     public javax.xml.soap.Node JavaDoc getResult() {
132         return (javax.xml.soap.Node JavaDoc)super.getNode().getFirstChild();
133      }
134 }
135
Popular Tags