View Javadoc

1   package com.eviware.soapui.model.support;
2   
3   import org.apache.commons.beanutils.PropertyUtils;
4   
5   import com.eviware.soapui.SoapUI;
6   import com.eviware.soapui.model.testsuite.TestProperty;
7   
8   public class XPathReferenceImpl implements XPathReference
9   {
10  	private String label;
11  	private TestProperty targetProperty;
12  	private Object target;
13  	private String xpathPropertyName;
14  	private String xpath;
15  	
16  	public XPathReferenceImpl( String label, TestProperty targetProperty, Object target, String xpathPropertyName )
17  	{
18  		this.label = label;
19  		this.targetProperty = targetProperty;
20  		this.target = target;
21  		this.xpathPropertyName = xpathPropertyName;
22  		
23  		try
24  		{
25  			this.xpath = ( String ) PropertyUtils.getProperty( target, xpathPropertyName );
26  		}
27  		catch( Exception e )
28  		{
29  			SoapUI.logError( e );
30  		}
31  	}
32  
33  	public String getLabel()
34  	{
35  		return label;
36  	}
37  
38  	public TestProperty getTargetProperty()
39  	{
40  		return targetProperty;
41  	}
42  
43  	public String getXPath()
44  	{
45  		return xpath;
46  	}
47  
48  	public void setXPath( String xpath )
49  	{
50  		this.xpath = xpath;
51  	}
52  
53  	public void update()
54  	{
55  		try
56  		{
57  			PropertyUtils.setProperty( target, xpathPropertyName, xpath );
58  		}
59  		catch( Exception e )
60  		{
61  			SoapUI.logError( e );
62  		}
63  	}
64  }