Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.jmeter.functions
Class XPath  view XPath download XPath.java

java.lang.Object
  extended byorg.apache.jmeter.functions.AbstractFunction
      extended byorg.apache.jmeter.functions.XPath
All Implemented Interfaces:
Function, java.io.Serializable

public class XPath
extends AbstractFunction
implements java.io.Serializable

The function represented by this class allows data to be read from XML files. Syntax is similar to the CVSRead function. The function allows the test to line-thru the nodes in the XML file - one node per each test. E.g. inserting the following in the test scripts : ${_XPath(c:/BOF/abcd.xml,/xpath/)} // match the (first) node of 'c:/BOF/abcd.xml' , return the 1st column ( represented by the '0'), ${_XPath(c:/BOF/abcd.xml,/xpath/)} // read (first) match of '/xpath/' expressions ${_XPath(c:/BOF/abcd.xml,/xpath/)} // Go to next match of '/xpath/' expressions NOTE: A single instance of each different file is opened and used for all threads.


Field Summary
private static java.util.List desc
           
private static java.lang.String KEY
           
private static Logger log
           
private  java.lang.Object[] values
           
 
Constructor Summary
XPath()
           
 
Method Summary
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 java.lang.String execute(org.apache.jmeter.samplers.SampleResult previousResult, org.apache.jmeter.samplers.Sampler currentSampler)
          Given the previous SampleResult and the current Sampler, return a string to use as a replacement value for the function call.
 java.util.List getArgumentDesc()
          Return a list of strings briefly describing each parameter your function takes.
 java.lang.String getReferenceKey()
          Return the name of your function.
 void setParameters(java.util.Collection parameters)
          A collection of the parameters used to configure your function.
 
Methods inherited from class org.apache.jmeter.functions.AbstractFunction
execute, getVariables
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final transient Logger log

KEY

private static final java.lang.String KEY
See Also:
Constant Field Values

desc

private static final java.util.List desc

values

private java.lang.Object[] values
Constructor Detail

XPath

public XPath()
Method Detail

clone

public java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 


execute

public java.lang.String execute(org.apache.jmeter.samplers.SampleResult previousResult,
                                org.apache.jmeter.samplers.Sampler currentSampler)
                         throws InvalidVariableException
Description copied from interface: Function
Given the previous SampleResult and the current Sampler, return a string to use as a replacement value for the function call. Assume "setParameter" was previously called. This method must be threadsafe - multiple threads will be using the same object.

Specified by:
execute in interface Function
Specified by:
execute in class AbstractFunction

getArgumentDesc

public java.util.List getArgumentDesc()
Description copied from interface: Function
Return a list of strings briefly describing each parameter your function takes. Please use JMeterUtils.getResString(resource_name) to grab a resource string. Otherwise, your help text will be difficult to internationalize. Add your strings to all org.apache.jmeter.resources.*.properties files. Do not worry about translating - that's someone else's responsibility. This list is not optional. If you don't wish to write help, you must at least return a List containing the correct number of blank strings, one for each argument.

Specified by:
getArgumentDesc in interface Function

getReferenceKey

public java.lang.String getReferenceKey()
Description copied from interface: Function
Return the name of your function. Convention is to prepend "__" to the name (ie "__regexFunction")

Specified by:
getReferenceKey in interface Function
Specified by:
getReferenceKey in class AbstractFunction

setParameters

public void setParameters(java.util.Collection parameters)
                   throws InvalidVariableException
Description copied from interface: Function
A collection of the parameters used to configure your function. Each parameter is a CompoundFunction and can be resolved by calling the execute() method of the CompoundFunction (which should be done at execution.)

Specified by:
setParameters in interface Function
Specified by:
setParameters in class AbstractFunction