1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.applications.javaclass;
12
13 import org.astrogrid.applications.CeaException;
14 import org.astrogrid.applications.beans.v1.parameters.ParameterValue;
15 import org.astrogrid.applications.description.ParameterDescription;
16 import org.astrogrid.applications.parameter.DefaultParameterAdapter;
17 import org.astrogrid.applications.parameter.protocol.ExternalValue;
18
19 import org.apache.commons.beanutils.ConvertUtils;
20
21 /*** A {@link org.astrogrid.applications.parameter.ParameterAdapter} for a {@link org.astrogrid.applications.javaclass.JavaClassParameterDescription}
22 *
23 * <p>uses the additional information in the description to convert the parameter value from a string
24 * to an instance of the correct type for the java method parameter.
25 * @author Noel Winstanley nw@jb.man.ac.uk 08-Jun-2004
26 * @see org.apache.commons.beanutils.ConvertUtils
27 * @see org.astrogrid.applications.javaclass.JavaClassParameterDescription
28 *
29 */
30 public class JavaClassParameterAdapter extends DefaultParameterAdapter {
31
32 /*** Construct a new JavaClassParameterAdapter
33 * @param val
34 * @param description
35 */
36 public JavaClassParameterAdapter(ParameterValue val, ParameterDescription description, ExternalValue ipVal) {
37 super(val, description,ipVal);
38 }
39
40 /***
41 * Calls the super class implementation (which will always return a string), and then uses beanUtils library to convert to type expected by java method
42 * @see org.astrogrid.applications.parameter.ParameterAdapter#process()
43 * @todo add handling for other types - e.g. URI / URL / Document / Node.
44 */
45 public Object process() throws CeaException {
46 String result = (String)super.process();
47 Class targetClass = ((JavaClassParameterDescription)description).getTargetClass();
48 return ConvertUtils.convert(result.trim(),targetClass);
49 }
50
51 }
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81