KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > impl > llom > soap11 > SOAP11HeaderBlockImpl


1 package org.apache.axis2.soap.impl.llom.soap11;
2
3 import org.apache.axis2.om.OMElement;
4 import org.apache.axis2.om.OMNamespace;
5 import org.apache.axis2.om.OMXMLParserWrapper;
6 import org.apache.axis2.soap.SOAPHeader;
7 import org.apache.axis2.soap.impl.llom.SOAPConstants;
8 import org.apache.axis2.soap.impl.llom.SOAPHeaderBlockImpl;
9 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
10
11 /**
12  * Copyright 2001-2004 The Apache Software Foundation.
13  * <p/>
14  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
15  * use this file except in compliance with the License. You may obtain a copy of
16  * the License at
17  * <p/>
18  * http://www.apache.org/licenses/LICENSE-2.0
19  * <p/>
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
23  * License for the specific language governing permissions and limitations under
24  * the License.
25  * <p/>
26  * <p/>
27  * Eran Chinthaka (chinthaka@apache.org)
28  */

29 public class SOAP11HeaderBlockImpl extends SOAPHeaderBlockImpl {
30     /**
31      * @param localName
32      * @param ns
33      */

34     public SOAP11HeaderBlockImpl(String JavaDoc localName, OMNamespace ns, SOAPHeader parent) throws SOAPProcessingException {
35         super(localName, ns, parent);
36         checkParent(parent);
37     }
38
39     /**
40      * Constructor SOAPHeaderBlockImpl
41      *
42      * @param localName
43      * @param ns
44      * @param parent
45      * @param builder
46      */

47     public SOAP11HeaderBlockImpl(String JavaDoc localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
48         super(localName, ns, parent, builder);
49     }
50
51
52     protected void checkParent(OMElement parent) throws SOAPProcessingException {
53         if (!(parent instanceof SOAP11HeaderImpl)) {
54             throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Body as the parent. But received some other implementation");
55         }
56     }
57
58     public void setRole(String JavaDoc roleURI) {
59         setAttribute(SOAP11Constants.ATTR_ACTOR, roleURI, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
60
61     }
62
63     public String JavaDoc getRole() {
64         return getAttribute(SOAP11Constants.ATTR_ACTOR, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
65     }
66
67     public void setMustUnderstand(boolean mustUnderstand) {
68         setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand ? "1" : "0", SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
69     }
70
71     public void setMustUnderstand(String JavaDoc mustUnderstand) throws SOAPProcessingException {
72         if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equals(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equals(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_0.equals(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_1.equals(mustUnderstand)) {
73             setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
74         } else {
75             throw new SOAPProcessingException("mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" ");
76         }
77     }
78
79     /**
80      * Returns whether the mustUnderstand attribute for this
81      * <CODE>SOAPHeaderBlock</CODE> object is turned on.
82      *
83      * @return <CODE>true</CODE> if the mustUnderstand attribute of
84      * this <CODE>SOAPHeaderBlock</CODE> object is turned on;
85      * <CODE>false</CODE> otherwise
86      */

87     public boolean getMustUnderstand() throws SOAPProcessingException {
88         String JavaDoc mustUnderstand = "";
89         if ((mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI))
90                 != null) {
91             if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_1.equalsIgnoreCase(mustUnderstand)) {
92                 return true;
93             } else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_0.equalsIgnoreCase(mustUnderstand)) {
94                 return false;
95             } else {
96                 throw new SOAPProcessingException("Invalid value found in mustUnderstand value of " + this.getLocalName() + " header block");
97             }
98         }
99         return false;
100
101     }
102 }
103
Popular Tags