KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > model > extensions > soap > impl > SOAPMessageBaseImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.wsdl.model.extensions.soap.impl;
21
22 import java.util.Collection JavaDoc;
23 import java.util.Collections JavaDoc;
24 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
25 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPMessageBase;
26 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPMessageBase.Use;
27 import org.netbeans.modules.xml.wsdl.model.impl.Util;
28 import org.w3c.dom.Element JavaDoc;
29
30 /**
31  *
32  * @author Nam Nguyen
33  */

34 public abstract class SOAPMessageBaseImpl extends SOAPComponentImpl implements SOAPMessageBase {
35     
36     /** Creates a new instance of SOAPMessageBaseImpl */
37     public SOAPMessageBaseImpl(WSDLModel model, Element JavaDoc e) {
38         super(model, e);
39     }
40
41     public Use getUse() {
42         String JavaDoc s = getAttribute(SOAPAttribute.USE);
43         return s == null ? null : getUseValueOf(s);
44     }
45     
46     public void setUse(Use use) {
47         setAttribute(USE_PROPERTY, SOAPAttribute.USE, use);
48     }
49
50     private Use getUseValueOf(String JavaDoc s) {
51         return s == null ? null : Use.valueOf(s.toUpperCase());
52     }
53     
54     protected Object JavaDoc getAttributeValueOf(SOAPAttribute attr, String JavaDoc s) {
55         if (attr == SOAPAttribute.USE) {
56             return getUseValueOf(s);
57         } else {
58             return super.getAttributeValueOf(attr, s);
59         }
60     }
61     
62     public String JavaDoc getNamespace() {
63         return getAttribute(SOAPAttribute.NAMESPACE);
64     }
65
66     public void setNamespace(String JavaDoc namespaceURI) {
67         setAttribute(NAMESPACE_PROPERTY, SOAPAttribute.NAMESPACE, namespaceURI);
68     }
69
70     public void removeEncodingStyle(String JavaDoc encodingStyle) {
71         Collection JavaDoc<String JavaDoc> styles = getEncodingStyles();
72         if (styles != null && styles.remove(encodingStyle)) {
73             setAttribute(ENCODING_STYLE_PROPERTY, SOAPAttribute.ENCODING_STYLE, Util.toString(styles));
74         }
75     }
76
77     public void addEncodingStyle(String JavaDoc encodingStyle) {
78         Collection JavaDoc<String JavaDoc> styles = getEncodingStyles();
79         if (styles != null) {
80             styles.add(encodingStyle);
81         } else {
82             styles = Collections.singleton(encodingStyle);
83         }
84         setAttribute(ENCODING_STYLE_PROPERTY, SOAPAttribute.ENCODING_STYLE, Util.toString(styles));
85     }
86
87     public java.util.Collection JavaDoc<String JavaDoc> getEncodingStyles() {
88         String JavaDoc s = getAttribute(SOAPAttribute.ENCODING_STYLE);
89         return s == null ? null : Util.parse(s);
90     }
91 }
92
Popular Tags