1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.support;
14
15 import org.apache.commons.beanutils.PropertyUtils;
16
17 import com.eviware.soapui.model.testsuite.TestStep;
18
19 /***
20 * TestStepProperty implementation that maps to a standard javabean property
21 *
22 * @author Ole.Matzura
23 */
24
25 public class TestStepBeanProperty extends DefaultTestStepProperty
26 {
27 public TestStepBeanProperty(String name, boolean isReadOnly, Object targetObject, String targetName, TestStep testStep )
28 {
29 super(name, isReadOnly, new BeanPropertyHandler( targetObject, targetName ), testStep );
30 }
31
32 /***
33 * PropertyHandler for setting/getting bean properties
34 *
35 * @author Ole.Matzura
36 */
37
38 public static class BeanPropertyHandler implements PropertyHandler
39 {
40 private final Object target;
41 private final String targetName;
42
43 public BeanPropertyHandler(Object targetObject, String targetName)
44 {
45 this.target = targetObject;
46 this.targetName = targetName;
47 }
48
49 public String getValue()
50 {
51 try
52 {
53 Object property = PropertyUtils.getProperty(target, targetName );
54 return property == null ? null : property.toString();
55 }
56 catch (Exception e)
57 {
58 e.printStackTrace();
59 return null;
60 }
61 }
62
63 public void setValue(String value)
64 {
65 try
66 {
67 PropertyUtils.setProperty( target, targetName, value );
68 }
69 catch (Exception e)
70 {
71 e.printStackTrace();
72 }
73 }
74 }
75
76 }