KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > impl > llom > soap12 > SOAP12HeaderBlockImpl


1 package org.apache.axis2.soap.impl.llom.soap12;
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  */

27 public class SOAP12HeaderBlockImpl extends SOAPHeaderBlockImpl {
28     /**
29      * Eran Chinthaka (chinthaka@apache.org)
30      */

31     /**
32      * @param localName
33      * @param ns
34      */

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

48     public SOAP12HeaderBlockImpl(String JavaDoc localName, OMNamespace ns, SOAPHeader parent, OMXMLParserWrapper builder) {
49         super(localName, ns, parent, builder);
50         
51     }
52
53     protected void checkParent(OMElement parent) throws SOAPProcessingException {
54         if (!(parent instanceof SOAP12HeaderImpl)) {
55             throw new SOAPProcessingException("Expecting SOAP 1.2 implementation of SOAP Body as the parent. But received some other implementation");
56         }
57     }
58
59     public void setRole(String JavaDoc roleURI) {
60         setAttribute(SOAP12Constants.SOAP_ROLE, roleURI, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
61     }
62
63     public String JavaDoc getRole() {
64         return getAttribute(SOAP12Constants.SOAP_ROLE, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
65
66     }
67
68     public void setMustUnderstand(boolean mustUnderstand) {
69         setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand ? "1" : "0", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
70
71     }
72
73     public void setMustUnderstand(String JavaDoc mustUnderstand) throws SOAPProcessingException {
74         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)) {
75             setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
76         } else {
77             throw new SOAPProcessingException("mustUndertand should be one of \"true\", \"false\", \"0\" or \"1\" ");
78         }
79     }
80
81     public boolean getMustUnderstand() throws SOAPProcessingException{
82         String JavaDoc mustUnderstand = "";
83         if ((mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))
84                 != null) {
85             if (SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_1.equalsIgnoreCase(mustUnderstand)) {
86                 return true;
87             }else if (SOAPConstants.ATTR_MUSTUNDERSTAND_FALSE.equalsIgnoreCase(mustUnderstand) || SOAPConstants.ATTR_MUSTUNDERSTAND_0.equalsIgnoreCase(mustUnderstand)) {
88                 return false;
89             }else{
90                 throw new SOAPProcessingException("Invalid value found in mustUnderstand value of "+this.getLocalName() + " header block");
91             }
92         }
93         return false;
94
95     }
96 }
97
Popular Tags