KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > message > SOAPBodyElement


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis.message;
17
18 import org.apache.axis.AxisFault;
19 import org.apache.axis.InternalException;
20 import org.apache.axis.components.logger.LogFactory;
21 import org.apache.axis.encoding.DeserializationContext;
22 import org.apache.axis.utils.Messages;
23 import org.apache.axis.utils.XMLUtils;
24 import org.apache.commons.logging.Log;
25 import org.w3c.dom.Element JavaDoc;
26 import org.xml.sax.Attributes JavaDoc;
27
28 import javax.xml.namespace.QName JavaDoc;
29 import javax.xml.soap.Name JavaDoc;
30 import javax.xml.soap.SOAPElement JavaDoc;
31 import javax.xml.soap.SOAPException JavaDoc;
32 import java.io.InputStream JavaDoc;
33
34 /**
35  * A Body element.
36  */

37 public class SOAPBodyElement extends MessageElement
38     implements javax.xml.soap.SOAPBodyElement JavaDoc {
39
40     private static Log log =
41         LogFactory.getLog(SOAPBodyElement.class.getName());
42
43     public SOAPBodyElement(String JavaDoc namespace,
44                            String JavaDoc localPart,
45                            String JavaDoc prefix,
46                            Attributes JavaDoc attributes,
47                            DeserializationContext context)
48         throws AxisFault
49     {
50         super(namespace, localPart, prefix, attributes, context);
51     }
52
53     public SOAPBodyElement(Name JavaDoc name)
54     {
55         super(name);
56     }
57
58     public SOAPBodyElement(QName JavaDoc qname)
59     {
60         super(qname);
61     }
62
63     public SOAPBodyElement(QName JavaDoc qname, Object JavaDoc value)
64     {
65         super(qname, value);
66     }
67
68     public SOAPBodyElement(Element JavaDoc elem)
69     {
70         super(elem);
71     }
72     
73     public SOAPBodyElement()
74     {
75     }
76
77     public SOAPBodyElement(InputStream JavaDoc input)
78     {
79         super( getDocumentElement(input) );
80     }
81
82     public SOAPBodyElement(String JavaDoc namespace, String JavaDoc localPart)
83     {
84         super(namespace, localPart);
85     }
86
87     private static Element JavaDoc getDocumentElement(InputStream JavaDoc input)
88     {
89         try {
90             return XMLUtils.newDocument(input).getDocumentElement();
91         } catch (Exception JavaDoc e) {
92             throw new InternalException(e);
93         }
94     }
95
96     public void setParentElement(SOAPElement JavaDoc parent) throws SOAPException JavaDoc {
97         if(parent == null) {
98             throw new IllegalArgumentException JavaDoc(Messages.getMessage("nullParent00"));
99         }
100         // migration aid
101
if (parent instanceof SOAPEnvelope) {
102             log.warn(Messages.getMessage("bodyElementParent"));
103             parent = ((SOAPEnvelope)parent).getBody();
104         }
105         if (!(parent instanceof SOAPBody) && !(parent instanceof RPCElement)) {
106             throw new IllegalArgumentException JavaDoc(Messages.getMessage("illegalArgumentException00"));
107         }
108         
109         super.setParentElement(parent);
110     }
111
112 }
113
Popular Tags