KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > soap > impl > llom > SOAPHeaderBlockImpl


1 /*
2  * Copyright 2004,2005 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.axis2.soap.impl.llom;
17
18 import org.apache.axis2.om.OMAttribute;
19 import org.apache.axis2.om.OMElement;
20 import org.apache.axis2.om.OMNamespace;
21 import org.apache.axis2.om.OMXMLParserWrapper;
22 import org.apache.axis2.om.impl.llom.OMAttributeImpl;
23 import org.apache.axis2.om.impl.llom.OMElementImpl;
24 import org.apache.axis2.om.impl.llom.OMNamespaceImpl;
25 import org.apache.axis2.soap.SOAPHeader;
26 import org.apache.axis2.soap.SOAPHeaderBlock;
27
28 import javax.xml.namespace.QName JavaDoc;
29
30 /**
31  * Class SOAPHeaderBlockImpl
32  */

33 public abstract class SOAPHeaderBlockImpl extends OMElementImpl
34         implements SOAPHeaderBlock {
35
36     private boolean processed = false;
37     /**
38      * @param localName
39      * @param ns
40      */

41     public SOAPHeaderBlockImpl(String JavaDoc localName, OMNamespace ns, SOAPHeader parent) throws SOAPProcessingException {
42         super(localName, ns, parent);
43         this.setNamespace(ns);
44     }
45
46     /**
47      * Constructor SOAPHeaderBlockImpl
48      *
49      * @param localName
50      * @param ns
51      * @param parent
52      * @param builder
53      */

54     public SOAPHeaderBlockImpl(String JavaDoc localName, OMNamespace ns,
55                                OMElement parent, OMXMLParserWrapper builder) {
56         super(localName, ns, parent, builder);
57         this.setNamespace(ns);
58     }
59
60     /**
61      * @param attributeName
62      * @param attrValue
63      */

64     protected void setAttribute(String JavaDoc attributeName, String JavaDoc attrValue, String JavaDoc soapEnvelopeNamespaceURI) {
65         OMAttribute omAttribute = this.getFirstAttribute(
66                 new QName JavaDoc(soapEnvelopeNamespaceURI, attributeName));
67         if (omAttribute != null) {
68             omAttribute.setValue(attrValue);
69         } else {
70             OMAttribute attribute = new OMAttributeImpl(
71                     attributeName,
72                     new OMNamespaceImpl(
73                             soapEnvelopeNamespaceURI,
74                             SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX), attrValue);
75             this.addAttribute(attribute);
76         }
77     }
78
79     /**
80      * Method getAttribute
81      *
82      * @param attrName
83      * @return
84      */

85     protected String JavaDoc getAttribute(String JavaDoc attrName, String JavaDoc soapEnvelopeNamespaceURI) {
86         OMAttribute omAttribute = this.getFirstAttribute(
87                 new QName JavaDoc(soapEnvelopeNamespaceURI, attrName));
88         return (omAttribute != null)
89                 ? omAttribute.getValue()
90                 : null;
91     }
92
93     public boolean isProcessed() {
94         return processed;
95     }
96
97     public void setProcessed() {
98         processed = true;
99     }
100 }
101
Popular Tags