JavaSamplerContext is used to provide context information to a
JavaSamplerClient implementation. This currently consists of the
initialization parameters which were specified in the GUI. Additional data
may be accessible through JavaSamplerContext in the future.
Method from org.apache.jmeter.protocol.java.sampler.JavaSamplerContext Detail: |
public boolean containsParameter(String name) {
return params.containsKey(name);
}
Determine whether or not a value has been specified for the parameter
with this name. |
public int getIntParameter(String name) throws NumberFormatException {
if (params == null || !params.containsKey(name)) {
throw new NumberFormatException("No value for parameter named '" + name + "'.");
}
return Integer.decode((String) params.get(name)).intValue();
}
Get the value of a specified parameter as an integer. An exception will
be thrown if the parameter is not specified or if it is not an integer.
The value may be specified in decimal, hexadecimal, or octal, as defined
by Integer.decode(). |
public int getIntParameter(String name,
int defaultValue) {
if (params == null || !params.containsKey(name)) {
return defaultValue;
}
try {
return Integer.decode((String) params.get(name)).intValue();
} catch (NumberFormatException e) {
log.warn("Value for parameter '" + name + "' not an integer: '" + params.get(name) + "'. Using default: '"
+ defaultValue + "'.", e);
return defaultValue;
}
}
Get the value of a specified parameter as an integer, or return the
specified default value if the value was not specified or is not an
integer. A warning will be logged if the value is not an integer. The
value may be specified in decimal, hexadecimal, or octal, as defined by
Integer.decode(). |
public long getLongParameter(String name) throws NumberFormatException {
if (params == null || !params.containsKey(name)) {
throw new NumberFormatException("No value for parameter named '" + name + "'.");
}
return Long.decode((String) params.get(name)).longValue();
}
Get the value of a specified parameter as a long. An exception will be
thrown if the parameter is not specified or if it is not a long. The
value may be specified in decimal, hexadecimal, or octal, as defined by
Long.decode(). |
public long getLongParameter(String name,
long defaultValue) {
if (params == null || !params.containsKey(name)) {
return defaultValue;
}
try {
return Long.decode((String) params.get(name)).longValue();
} catch (NumberFormatException e) {
log.warn("Value for parameter '" + name + "' not a long: '" + params.get(name) + "'. Using default: '"
+ defaultValue + "'.", e);
return defaultValue;
}
}
Get the value of a specified parameter as along, or return the specified
default value if the value was not specified or is not a long. A warning
will be logged if the value is not a long. The value may be specified in
decimal, hexadecimal, or octal, as defined by Long.decode(). |
public String getParameter(String name) {
return getParameter(name, null);
}
Get the value of a specific parameter as a String, or null if the value
was not specified. |
public String getParameter(String name,
String defaultValue) {
if (params == null || !params.containsKey(name)) {
return defaultValue;
}
return (String) params.get(name);
}
Get the value of a specified parameter as a String, or return the
specified default value if the value was not specified. |
public Iterator getParameterNamesIterator() {
return params.keySet().iterator();
}
Get an iterator of the parameter names. Each entry in the Iterator is a
String. |