View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.model.support;
14  
15  import org.apache.commons.beanutils.PropertyUtils;
16  
17  import com.eviware.soapui.SoapUI;
18  import com.eviware.soapui.model.testsuite.TestProperty;
19  
20  public class XPathReferenceImpl implements XPathReference
21  {
22  	private String label;
23  	private TestProperty targetProperty;
24  	private Object target;
25  	private String xpathPropertyName;
26  	private String xpath;
27  	
28  	public XPathReferenceImpl( String label, TestProperty targetProperty, Object target, String xpathPropertyName )
29  	{
30  		this.label = label;
31  		this.targetProperty = targetProperty;
32  		this.target = target;
33  		this.xpathPropertyName = xpathPropertyName;
34  		
35  		try
36  		{
37  			this.xpath = ( String ) PropertyUtils.getProperty( target, xpathPropertyName );
38  		}
39  		catch( Exception e )
40  		{
41  			SoapUI.logError( e );
42  		}
43  	}
44  
45  	public String getLabel()
46  	{
47  		return label;
48  	}
49  
50  	public TestProperty getTargetProperty()
51  	{
52  		return targetProperty;
53  	}
54  
55  	public String getXPath()
56  	{
57  		return xpath;
58  	}
59  
60  	public void setXPath( String xpath )
61  	{
62  		this.xpath = xpath;
63  	}
64  
65  	public void update()
66  	{
67  		try
68  		{
69  			PropertyUtils.setProperty( target, xpathPropertyName, xpath );
70  		}
71  		catch( Exception e )
72  		{
73  			SoapUI.logError( e );
74  		}
75  	}
76  }