KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.netbeans.modules.xml.wsdl.model.Binding;
24 import org.netbeans.modules.xml.wsdl.model.BindingOperation;
25 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
26 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
27 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding;
28 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPOperation;
29 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding.Style;
30 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPComponent;
31 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPQName;
32 import org.netbeans.modules.xml.xam.Component;
33 import org.w3c.dom.Element JavaDoc;
34
35 /**
36  *
37  * @author Nam Nguyen
38  */

39 public class SOAPOperationImpl extends SOAPComponentImpl implements SOAPOperation {
40     
41     /** Creates a new instance of SOAPOperationImpl */
42     public SOAPOperationImpl(WSDLModel model, Element JavaDoc e) {
43         super(model, e);
44     }
45     
46     public SOAPOperationImpl(WSDLModel model){
47         this(model, createPrefixedElement(SOAPQName.OPERATION.getQName(), model));
48     }
49     
50     public void accept(SOAPComponent.Visitor visitor) {
51         visitor.visit(this);
52     }
53
54     public void setSoapAction(String JavaDoc soapActionURI) {
55         setAttribute(SOAP_ACTION_PROPERTY, SOAPAttribute.SOAP_ACTION, soapActionURI);
56     }
57
58     public String JavaDoc getSoapAction() {
59         return getAttribute(SOAPAttribute.SOAP_ACTION);
60     }
61    
62     public void setStyle(Style v) {
63         setAttribute(STYLE_PROPERTY, SOAPAttribute.STYLE, v);
64     }
65
66     public Style getStyle() {
67         String JavaDoc s = getAttribute(SOAPAttribute.STYLE);
68         if (s == null) {
69             WSDLComponent ancestor = getParent() == null? null : getParent().getParent();
70             if (ancestor instanceof Binding) {
71                 Binding b = (Binding) ancestor;
72                 Collection JavaDoc<SOAPBinding> sbs = b.getExtensibilityElements(SOAPBinding.class);
73                 if (sbs.size() > 0) {
74                     SOAPBinding sb = sbs.iterator().next();
75                     Style sbStyle = sb.getStyle();
76                     if (sbStyle != null) {
77                         return sbStyle;
78                     }
79                 }
80             }
81             return Style.DOCUMENT;
82         }
83
84         return Style.valueOf(s.toUpperCase());
85
86     }
87
88     @Override JavaDoc
89     public boolean canBeAddedTo(Component target) {
90         if (target instanceof BindingOperation) {
91             return true;
92         }
93         return false;
94     }
95 }
96
Popular Tags