View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.webservice.generator;
9   
10  import java.lang.reflect.Method;
11  import java.util.ArrayList;
12  import java.util.HashSet;
13  import java.util.List;
14  import java.util.Set;
15  
16  import org.apache.commons.lang.builder.EqualsBuilder;
17  import org.apache.commons.lang.builder.ReflectionToStringBuilder;
18  
19  /**
20   * This class provides the object representation of a method's signature.
21   */
22  public class MethodSignature {
23  
24      /**
25       * The name of the method.
26       */
27      private String methodName = null;
28  
29      /**
30       * The data type used to return the method result.
31       * (In general is not a full qualified java name).
32       */
33      private String returnType = null;
34  
35      /**
36       * The name of the return element used in the wsdl.
37       */
38      private String returnName = null;
39  
40      /**
41       * The list of parameters.
42       * The position in the list represent the position of the parameter.
43       */
44      private List<Param> parameters = new ArrayList<Param>();
45  
46      /**
47       * The list of Exceptions raised by the method.
48       * The list member is the full qualified name of the class of the exception.
49       */
50      private List<String> exceptionsType = new ArrayList<String>();
51  
52      /**
53       * true for an asynchronous method (The Oneway annotation will be added).
54       */
55      private boolean oneway = false;
56  
57      /**
58       * True if this signature contains a <code>Holder</code>.
59       */
60      private boolean containsHolder = false;
61      
62      /** The operations class Name */ 
63      private String className = null;
64      
65      /** The operations class Type */ 
66      private Class classType = null;
67      
68      /** The method object */ 
69      private Method method = null;
70      
71      /** The changed method object (can be null if no holder parames are included)*/ 
72      private Method changedMethod = null;
73      
74      private Set<String> methodUnionTypes =new HashSet<String>();
75      
76      
77      private Set<String> methodInterfaceTypes=new HashSet<String>();
78      
79      private Set<String> methodAnyTypes=new HashSet<String>(); 
80  
81      /**
82       * Default constructor.
83       */
84      public MethodSignature() {
85          // NOP
86      }
87  
88      // Basic
89  
90      /**
91       * @return  This object as String.
92       */
93      public String toString() {
94          return ReflectionToStringBuilder.toString(this);
95      }
96  
97      /**
98       * @param   obj   An object.
99       * @return  true, if this object is equal to the obj parameter.
100      */
101     public boolean equals(Object obj) {
102         return EqualsBuilder.reflectionEquals(this, obj);
103     }
104 
105     // Getter And Setter
106 
107     /**
108      * getter.
109      *
110      * @return  The current value
111      */
112     public String getMethodName() {
113         return methodName;
114     }
115 
116     /**
117      * setter.
118      *
119      * @param methodName  the value to set.
120      */
121     public void setMethodName(String methodName) {
122         this.methodName = methodName;
123     }
124 
125     /**
126      * getter.
127      *
128      * @return  The current value
129      */
130     public String getReturnType() {
131         return returnType;
132     }
133 
134     /**
135      * setter.
136      *
137      * @param returnType  the value to set.
138      */
139     public void setReturnType(String returnType) {
140         this.returnType = returnType;
141     }
142 
143     /**
144      * getter.
145      *
146      * @return    The current value
147      */
148     public String getReturnName() {
149         return returnName;
150     }
151 
152     /**
153      * setter.
154      *
155      * @param        returnName    The value to set.
156      */
157     public void setReturnName(String returnName) {
158         this.returnName = returnName;
159     }
160 
161     /**
162      * A getter.
163      *
164      * @return  The current exceptionsType attribute.
165      */
166     public List<String> getExceptionsType() {
167         return exceptionsType;
168     }
169 
170     /**
171      * A setter.
172      * @param   exceptionsType    The new exceptionsType attribute.
173      */
174     public void setExceptionsType(List<String> exceptionsType) {
175         this.exceptionsType = exceptionsType;
176     }
177 
178     /**
179      * getter.
180      *
181      * @return    The current value of the property.
182      */
183     public boolean isOneway() {
184         return oneway;
185     }
186 
187     /**
188      * setter.
189      *
190      * @param   oneway  The new value of the property.
191      */
192     public void setOneway(boolean oneway) {
193         this.oneway = oneway;
194     }
195 
196     public List<Param> getParameters() {
197         return parameters;
198     }
199 
200     public void setParameters(List<Param> parameters) {
201         this.parameters = parameters;
202     }
203 
204     public boolean isContainsHolder() {
205         return containsHolder;
206     }
207 
208     public void setContainsHolder(boolean containsHolder) {
209         this.containsHolder = containsHolder;
210     }
211 
212     public String getClassName() {
213         return className;
214     }
215 
216     public void setClassName(String classNameStr) {
217         this.className = classNameStr;
218     }
219 
220     public Class getClassType() {
221         return classType;
222     }
223 
224     public void setClassType(Class classType) {
225         this.classType = classType;
226     }
227 
228     public Method getMethod() {
229         return method;
230     }
231 
232     public void setMethod(Method method) {
233         this.method = method;
234     }
235 
236     public Method getChangedMethod() {
237         return changedMethod;
238     }
239 
240     public void setChangedMethod(Method changedMethod) {
241         this.changedMethod = changedMethod;
242     }
243 
244     public Set<String> getMethodUnionTypes() {
245 		return methodUnionTypes;
246     }
247 
248     public void setMethodUnionTypes(Set<String> methodUnionTypes) {
249 		this.methodUnionTypes = methodUnionTypes;
250     }    
251     
252     public Set<String> getMethodInterfaceTypes() {
253 		return methodInterfaceTypes;
254     }
255  
256     public void setMethodInterfaceTypes(Set<String> methodInterfaceTypes) {
257 		this.methodInterfaceTypes = methodInterfaceTypes;
258     }     
259     
260      public Set<String> getMethodAnyTypes() {
261 		return methodInterfaceTypes;
262     }
263  
264     public void setMethodAnyTypes(Set<String> methodInterfaceTypes) {
265 		this.methodInterfaceTypes = methodInterfaceTypes;
266     }     
267     
268     //It return true if the method contains param or return type that contains a Corba Type
269     public boolean hasCorbaTypes()
270     {   
271         
272     	if (!methodInterfaceTypes.isEmpty() || !methodUnionTypes.isEmpty() || !methodAnyTypes.isEmpty())
273     		return true;
274     	return false;
275     }
276         
277 }