This class contains the static utility methods used by JMeter.
createButton
public static JButton createButton(String name,
ActionListener listener)
Create a button with the netscape style
name
- Description of Parameterlistener
- Description of Parameter
- Description of the Returned Value
createSimpleButton
public static JButton createSimpleButton(String name,
ActionListener listener)
Create a button with the netscape style
name
- Description of Parameterlistener
- Description of Parameter
- Description of the Returned Value
findFile
public static File findFile(String fileName)
Find a file in the current directory or in the JMeter bin directory.
findInArray
public static int findInArray(String[] array,
String value)
Finds a string in an array of strings and returns the
array
- Array of strings.value
- String to compare to array values.
- Index of value in array, or -1 if not in array.
getAlias
public static Hashtable getAlias(Properties properties)
Creates the vector of alias strings.
properties
- Description of Parameter
getControllers
public static Vector getControllers(Properties properties)
Creates a vector of SampleController plugins.
properties
- The properties with information about the samplers
getHashtable
public static Hashtable getHashtable(Properties properties,
String name)
Creates a table of strings for all the properties that start with a
common prefix.
properties
- Description of Parametername
- Description of Parameter
getImage
public static ImageIcon getImage(String name)
This looks for the requested image in the classpath under
org.apache.jmeter.images.
name
- Description of Parameter
getImage
public static ImageIcon getImage(String name,
String description)
This looks for the requested image in the classpath under
org.apache.jmeter.images. , and also sets the description
of the image, which is useful if the icon is going to be placed
on the clipboard.
name
- the name of the imagedescription
- the description of the image
getJMeterBinDir
public static String getJMeterBinDir()
Get the JMeter bin directory - does not include the trailing separator.
getJMeterCopyright
public static String getJMeterCopyright()
Gets the JMeter copyright.
- the JMeter copyright string
getJMeterHome
public static String getJMeterHome()
Get the JMeter home directory - does not include the trailing separator.
getJMeterProperties
public static Properties getJMeterProperties()
This gets the currently defined appProperties. It can only be called
after the
getProperties(String)
method is called.
- The JMeterProperties value
getJMeterVersion
public static String getJMeterVersion()
Gets the JMeter Version.
- the JMeter version string
getLocalHostFullName
public static String getLocalHostFullName()
Returns the cached result from calling
InetAddress.getLocalHost().getCanonicalHostName()
- local host name in canonical form
getLocalHostIP
public static String getLocalHostIP()
Returns the cached result from calling
InetAddress.getLocalHost().getHostAddress()
- String representation of local IP address
getLocalHostName
public static String getLocalHostName()
Returns the cached result from calling
InetAddress.getLocalHost().getHostName()
getLocale
public static Locale getLocale()
Gets the current locale.
getLocaleString
public static String getLocaleString(String locale)
Get the locale name as a resource.
Does not log an error if the resource does not exist.
This is needed to support additional locales, as they won't be in existing messages files.
- the locale display name as defined in the current Locale or the original string if not present
getMatcher
public static Perl5Matcher getMatcher()
Gets Perl5Matcher for this thread.
getPattern
public static Pattern getPattern(String expression)
Get a compiled expression from the pattern cache (READ_ONLY).
getPattern
public static Pattern getPattern(String expression,
int options)
Get a compiled expression from the pattern cache.
expression
- REoptions
- e.g. READ_ONLY_MASK
getPatternCache
public static PatternCacheLRU getPatternCache()
getPropDefault
public static String getPropDefault(String propName,
String defaultVal)
Get a String value with default if not present.
propName
- the name of the property.defaultVal
- the default value.
getPropDefault
public static boolean getPropDefault(String propName,
boolean defaultVal)
Get a boolean value with default if not present.
propName
- the name of the property.defaultVal
- the default value.
getPropDefault
public static int getPropDefault(String propName,
int defaultVal)
Get a int value with default if not present.
propName
- the name of the property.defaultVal
- the default value.
getPropDefault
public static long getPropDefault(String propName,
long defaultVal)
Get a long value with default if not present.
propName
- the name of the property.defaultVal
- the default value.
getProperties
public static Properties getProperties(String file)
This method is used by the init method to load the property file that may
even reside in the user space, or in the classpath under
org.apache.jmeter.jmeter.properties.
The method also initialises logging and sets up the default Locale
TODO - perhaps remove?
[still used
- the Properties from the file
getProperty
public static String getProperty(String propName)
Get the value of a JMeter property.
propName
- the name of the property.
- the value of the JMeter property, or null if not defined
getRandomInt
public static int getRandomInt(int r)
Provide random numbers
r
- -
the upper bound (exclusive)
getResString
public static String getResString(String key)
Gets the resource string for this key.
If the resource is not found, a warning is logged
key
- the key in the resource file
- the resource string if the key is found; otherwise, return
"[res_key="+key+"]"
getResString
public static String getResString(String key,
String defaultValue)
Only intended for use in development; use
getResString(String) normally
Gets the resource string for this key.
If the resource is not found, a warning is logged
key
- the key in the resource filedefaultValue
- -
the default value
- the resource string if the key is found; otherwise, return the
default
getResourceFileAsText
public static String getResourceFileAsText(String name)
getSearchPaths
public static String[] getSearchPaths()
getTestSamples
public static String[] getTestSamples(Properties properties,
String name)
Create a string of class names for a particular SamplerController
properties
- The properties with info about the samples.name
- The name of the sampler controller.
getTimers
public static Vector getTimers(Properties properties)
Creates the vector of Timers plugins.
properties
- Description of Parameter
getVector
public static Vector getVector(Properties properties,
String name)
Creates a vector of strings for all the properties that start with a
common prefix.
properties
- Description of Parametername
- Description of Parameter
getVisualizers
public static Vector getVisualizers(Properties properties)
Creates the vector of visualizer plugins.
properties
- Description of Parameter
getXMLParser
public static XMLReader getXMLParser()
Create an instance of an org.xml.sax.Parser based on the default props.
initLocale
public static void initLocale()
Initialise the JMeter Locale
initLogging
public static void initLogging()
Initialise JMeter logging
instantiate
public static Object instantiate(String className,
String impls)
Instatiate an object and guarantee its class.
className
- The name of the class to instantiate.impls
- The name of the class it subclases.
- Description of the Returned Value
instantiate
public static Vector instantiate(Vector v,
String className)
Instantiate a vector of classes
v
- Description of ParameterclassName
- Description of Parameter
- Description of the Returned Value
isExpertMode
public static boolean isExpertMode()
Determine whether we are in 'expert' mode. Certain features may be hidden
from user's view unless in expert mode.
- true iif we're in expert mode
loadJMeterProperties
public static void loadJMeterProperties(String file)
Load the JMeter properties file; if not found, then
default to "org/apache/jmeter/jmeter.properties" from the classpath
c.f. loadProperties
loadProperties
public static Properties loadProperties(String file)
This method loads a property file that may reside in the user space, or
in the classpath
- the Properties from the file
removeLocaleChangeListener
public static void removeLocaleChangeListener(LocaleChangeListener listener)
reportErrorToUser
public static void reportErrorToUser(String errorMsg)
Report an error through a dialog box.
Title defaults to "error_title" resource string
errorMsg
- - the error message.
reportErrorToUser
public static void reportErrorToUser(String errorMsg,
String titleMsg)
Report an error through a dialog box.
errorMsg
- - the error message.titleMsg
- - title string
selJComboBoxItem
public static void selJComboBoxItem(Properties properties,
JComboBox combo,
Vector namVec,
String name)
Sets the selection of the JComboBox to the Object 'name' from the list in
namVec.
setJMeterHome
public static void setJMeterHome(String home)
setLocale
public static void setLocale(Locale loc)
Changes the current locale: re-reads resource strings and notifies
listeners.
setProperty
public static Object setProperty(String propName,
String propValue)
Set a String value
propName
- the name of the property.propValue
- the value of the property
- the previous value of the property
tokenize
public static Vector tokenize(String string,
String separator)
Tokenize a string into a vector of tokens
string
- Description of Parameterseparator
- Description of Parameter
- Description of the Returned Value
unsplit
public static String unsplit(Object[] splittee,
Object splitChar)
Takes an array of strings and a tokenizer character, and returns a string
of all the strings concatenated with the tokenizer string in between each
one.
splittee
- Array of Objects to be concatenated.splitChar
- Object to unsplit the strings with.
unsplit
public static String unsplit(Object[] splittee,
Object splitChar,
String def)
Takes an array of strings and a tokenizer character, and returns a string
of all the strings concatenated with the tokenizer string in between each
one.
splittee
- Array of Objects to be concatenated.splitChar
- Object to unsplit the strings with.def
- Default value to replace null values in array.