Apache JMeter
1.9

org.apache.jmeter.util
Class JMeterUtils

java.lang.Object
  |
  +--org.apache.jmeter.util.JMeterUtils
All Implemented Interfaces:
org.apache.jorphan.test.UnitTestManager

public class JMeterUtils
extends Object
implements org.apache.jorphan.test.UnitTestManager

This class contains the static utility methods used by JMeter.

Version:
$Revision: 1.39 $ $Date: 2003/08/06 21:18:08 $
Author:
Stefano Mazzocchi

Field Summary
static String CLASSFINDER
           
static String ELEMENTS
           
static String ENGINE
           
static String FTP
           
static String GUI
           
static String HTTP
           
static String JAVA
           
static String JDBC
           
static String JMETER
           
static String PROPERTIES
           
static String TEST
           
static String UTIL
           
 
Constructor Summary
JMeterUtils()
           
 
Method Summary
static void addLocaleChangeListener(LocaleChangeListener listener)
           
static JButton createButton(String name, ActionListener listener)
          Create a button with the netscape style
static JButton createSimpleButton(String name, ActionListener listener)
          Create a button with the netscape style
static int findInArray(String[] array, String value)
          Finds a string in an array of strings and returns the
static Hashtable getAlias(Properties properties)
          Creates the vector of alias strings.
static Vector getControllers(Properties properties)
          Creates a vector of SampleController plugins.
static Hashtable getHashtable(Properties properties, String name)
          Creates a table of strings for all the properties that start with a common prefix.
static ImageIcon getImage(String name)
          This looks for the requested image in the classpath under org.apache.jmeter.images.
static String getJMeterHome()
           
static Properties getJMeterProperties()
          This gets the currently defined appProperties.
static String getJMeterVersion()
          Gets the JMeter Version.
static Locale getLocale()
          Gets the current locale.
static org.apache.oro.text.regex.Perl5Matcher getMatcher()
          Gets Perl5Matcher for this thread.
static org.apache.oro.text.PatternCacheLRU getPatternCache()
           
static boolean getPropDefault(String propName, boolean defaultVal)
          Get a boolean value with default if not present.
static int getPropDefault(String propName, int defaultVal)
          Get a int value with default if not present.
static long getPropDefault(String propName, long defaultVal)
          Get a long value with default if not present.
static String getPropDefault(String propName, String defaultVal)
          Get a String value with default if not present.
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.
static int getRandomInt(int r)
          Provide random numbers
static String getResourceFileAsText(String name)
           
static String getResString(String key)
          Gets the resource string for this key.
static String[] getSearchPaths()
           
static String[] getTestSamples(Properties properties, String name)
          Create a string of class names for a particular SamplerController
static Vector getTimers(Properties properties)
          Creates the vector of Timers plugins.
static Vector getVector(Properties properties, String name)
          Creates a vector of strings for all the properties that start with a common prefix.
static Vector getVisualizers(Properties properties)
          Creates the vector of visualizer plugins.
static org.xml.sax.XMLReader getXMLParser()
          Create an instance of an org.xml.sax.Parser based on the default props.
static org.xml.sax.XMLReader getXMLParser(Properties properties)
          Deprecated. use the plain version instead. We are using JAXP!
 void initializeProperties(String file)
           
static Object instantiate(String className, String impls)
          Instatiate an object and guarantee its class.
static Vector instantiate(Vector v, String className)
          Instantiate a vector of classes
static void removeLocaleChangeListener(LocaleChangeListener listener)
           
static void reportErrorToUser(String errorMsg)
          Report an error through a dialog box.
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.
static void setJMeterHome(String home)
           
static void setLocale(Locale loc)
          Changes the current locale: re-reads resource strings and notifies listeners.
static String[] split(String splittee, String splitChar, String def)
          Takes a String and a tokenizer character, and returns a new array of strings of the string split by the tokenizer character.
static Vector tokenize(String string, String separator)
          Tokenize a string into a vector of tokens
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.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JMETER

public static final String JMETER
See Also:
Constant Field Values

ENGINE

public static final String ENGINE
See Also:
Constant Field Values

ELEMENTS

public static final String ELEMENTS
See Also:
Constant Field Values

GUI

public static final String GUI
See Also:
Constant Field Values

UTIL

public static final String UTIL
See Also:
Constant Field Values

CLASSFINDER

public static final String CLASSFINDER
See Also:
Constant Field Values

TEST

public static final String TEST
See Also:
Constant Field Values

HTTP

public static final String HTTP
See Also:
Constant Field Values

JDBC

public static final String JDBC
See Also:
Constant Field Values

FTP

public static final String FTP
See Also:
Constant Field Values

JAVA

public static final String JAVA
See Also:
Constant Field Values

PROPERTIES

public static final String PROPERTIES
See Also:
Constant Field Values
Constructor Detail

JMeterUtils

public JMeterUtils()
Method Detail

getMatcher

public static org.apache.oro.text.regex.Perl5Matcher getMatcher()
Gets Perl5Matcher for this thread.


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.

Parameters:
file - the file to load
Returns:
the Properties from the file

getPatternCache

public static org.apache.oro.text.PatternCacheLRU getPatternCache()

initializeProperties

public void initializeProperties(String file)
Specified by:
initializeProperties in interface org.apache.jorphan.test.UnitTestManager

getSearchPaths

public static String[] getSearchPaths()

getRandomInt

public static int getRandomInt(int r)
Provide random numbers


setLocale

public static void setLocale(Locale loc)
Changes the current locale: re-reads resource strings and notifies listeners.


getLocale

public static Locale getLocale()
Gets the current locale.

Returns:
current locale

addLocaleChangeListener

public static void addLocaleChangeListener(LocaleChangeListener listener)

removeLocaleChangeListener

public static void removeLocaleChangeListener(LocaleChangeListener listener)

getResString

public static String getResString(String key)
Gets the resource string for this key.

Parameters:
key - the key in the resource file
Returns:
the resource string if the key is found; otherwise, return an empty string

getJMeterProperties

public static Properties getJMeterProperties()
This gets the currently defined appProperties. It can only be called after the getProperties(String) method is called.

Returns:
The JMeterProperties value

getImage

public static ImageIcon getImage(String name)
This looks for the requested image in the classpath under org.apache.jmeter.images.

Parameters:
name - Description of Parameter
Returns:
The Image value

getResourceFileAsText

public static String getResourceFileAsText(String name)

getTimers

public static Vector getTimers(Properties properties)
Creates the vector of Timers plugins.

Parameters:
properties - Description of Parameter
Returns:
The Timers value

getVisualizers

public static Vector getVisualizers(Properties properties)
Creates the vector of visualizer plugins.

Parameters:
properties - Description of Parameter
Returns:
The Visualizers value

getControllers

public static Vector getControllers(Properties properties)
Creates a vector of SampleController plugins.

Parameters:
properties - The properties with information about the samplers
Returns:
The Controllers value

getTestSamples

public static String[] getTestSamples(Properties properties,
                                      String name)
Create a string of class names for a particular SamplerController

Parameters:
properties - The properties with info about the samples.
name - The name of the sampler controller.
Returns:
The TestSamples value

getXMLParser

public static org.xml.sax.XMLReader getXMLParser(Properties properties)
Deprecated. use the plain version instead. We are using JAXP!

Create an instance of an org.xml.sax.Parser

Parameters:
properties - The properties file containing the parser's class name
Returns:
The XMLParser value

getXMLParser

public static org.xml.sax.XMLReader getXMLParser()
Create an instance of an org.xml.sax.Parser based on the default props.

Returns:
The XMLParser value

getAlias

public static Hashtable getAlias(Properties properties)
Creates the vector of alias strings.

Parameters:
properties - Description of Parameter
Returns:
The Alias value

getVector

public static Vector getVector(Properties properties,
                               String name)
Creates a vector of strings for all the properties that start with a common prefix.

Parameters:
properties - Description of Parameter
name - Description of Parameter
Returns:
The Vector value

getHashtable

public static Hashtable getHashtable(Properties properties,
                                     String name)
Creates a table of strings for all the properties that start with a common prefix.

Parameters:
properties - Description of Parameter
name - Description of Parameter
Returns:
The Hashtable value

getPropDefault

public static int getPropDefault(String propName,
                                 int defaultVal)
Get a int value with default if not present.

Parameters:
propName - the name of the property.
defaultVal - the default value.
Returns:
The PropDefault value

getPropDefault

public static boolean getPropDefault(String propName,
                                     boolean defaultVal)
Get a boolean value with default if not present.

Parameters:
propName - the name of the property.
defaultVal - the default value.
Returns:
The PropDefault value

getPropDefault

public static long getPropDefault(String propName,
                                  long defaultVal)
Get a long value with default if not present.

Parameters:
propName - the name of the property.
defaultVal - the default value.
Returns:
The PropDefault value

getPropDefault

public static String getPropDefault(String propName,
                                    String defaultVal)
Get a String value with default if not present.

Parameters:
propName - the name of the property.
defaultVal - the default value.
Returns:
The PropDefault value

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.


instantiate

public static Object instantiate(String className,
                                 String impls)
Instatiate an object and guarantee its class.

Parameters:
className - The name of the class to instantiate.
impls - The name of the class it subclases.
Returns:
Description of the Returned Value

instantiate

public static Vector instantiate(Vector v,
                                 String className)
Instantiate a vector of classes

Parameters:
v - Description of Parameter
className - Description of Parameter
Returns:
Description of the Returned Value

tokenize

public static Vector tokenize(String string,
                              String separator)
Tokenize a string into a vector of tokens

Parameters:
string - Description of Parameter
separator - Description of Parameter
Returns:
Description of the Returned Value

createButton

public static JButton createButton(String name,
                                   ActionListener listener)
Create a button with the netscape style

Parameters:
name - Description of Parameter
listener - Description of Parameter
Returns:
Description of the Returned Value

createSimpleButton

public static JButton createSimpleButton(String name,
                                         ActionListener listener)
Create a button with the netscape style

Parameters:
name - Description of Parameter
listener - Description of Parameter
Returns:
Description of the Returned Value

split

public static String[] split(String splittee,
                             String splitChar,
                             String def)
Takes a String and a tokenizer character, and returns a new array of strings of the string split by the tokenizer character.

Parameters:
splittee - String to be split
splitChar - Character to split the string on
def - Default value to place between two split chars that have nothing between them
Returns:
Array of all the tokens.

reportErrorToUser

public static void reportErrorToUser(String errorMsg)
Report an error through a dialog box.

Parameters:
errorMsg - the error message.

findInArray

public static int findInArray(String[] array,
                              String value)
Finds a string in an array of strings and returns the

Parameters:
array - Array of strings.
value - String to compare to array values.
Returns:
Index of value in array, or -1 if not in array.

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.

Parameters:
splittee - Array of Objects to be concatenated.
splitChar - Object to unsplit the strings with.
Returns:
Array of all the tokens.

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.

Parameters:
splittee - Array of Objects to be concatenated.
splitChar - Object to unsplit the strings with.
def - Default value to replace null values in array.
Returns:
Array of all the tokens.

getJMeterHome

public static String getJMeterHome()

setJMeterHome

public static void setJMeterHome(String home)

getJMeterVersion

public static String getJMeterVersion()
Gets the JMeter Version.


Apache JMeter
1.9

Copyright © 1998-2003 Apache Software Foundation. All Rights Reserved.