org.finra.jtaf.core.commands
Class RandomGenerator

java.lang.Object
  extended by org.finra.jtaf.core.model.invocationtarget.InvocationTarget
      extended by org.finra.jtaf.core.model.invocationtarget.Command
          extended by org.finra.jtaf.core.commands.RandomGenerator

public class RandomGenerator
extends Command

This class is used to generate a random string, phone number, regex, US state, or US state abbreviation.


Field Summary
static List<String> abbrevUSState
           
static String charsForRandomString
           
static List<String> USState
           
 
Fields inherited from class org.finra.jtaf.core.model.invocationtarget.Command
interpreter, recordResult
 
Fields inherited from class org.finra.jtaf.core.model.invocationtarget.InvocationTarget
globalContext
 
Constructor Summary
RandomGenerator(String name)
          This called when instantiating the command before it is executed by the interpreter.The recordResult variable is set to false because details about the RandomGenerator step aren't needed, unlike the commands within the RandomGenerator block.
 
Method Summary
protected  void execute(IInvocationContext ctx)
          This method should be overridden by every Command object.
static String generate(String method, String length, String lengthMin, String lengthMax, String min, String max, String regexp)
          Use a regular expression to generate a string or use methods to select US state name or abbreviations and generate phone numbers and strings.
static String generateAbbrevUSState()
          Randomly selects a US state abbreviation from the list.
static String generatePhone()
          Generates a random phone number.
static String generateRegexp(String regexp)
          Generate a string using a specified regular expression.
static String generateString(String chars, int length)
          This randomly generates a string given a set of characters and a desired length.
static String generateUSState()
          Randomly selects a US state from the list.
 
Methods inherited from class org.finra.jtaf.core.model.invocationtarget.Command
acceptInvocationTargetVisitor, clearContext, deinitialize, executeInvocation, getBooleanOrDefault, getContext, getFloatOrDefault, getIntegerOrDefault, getOptionalObject, getOptionalString, getRequiredBoolean, getRequiredFloat, getRequiredInteger, getRequiredObject, getRequiredString, getStringOrDefault, initialize, launch, recordResult
 
Methods inherited from class org.finra.jtaf.core.model.invocationtarget.InvocationTarget
addOptionalParameter, addProduction, addRequiredParameter, cleanGlobalContext, getAllParameters, getFromGlobalContext, getGlobalContext, getName, getOptionalParameters, getProductions, getRequiredParameters, getUsage, putToGlobalContext, setGlobalContext, setUsage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

abbrevUSState

public static final List<String> abbrevUSState

USState

public static final List<String> USState

charsForRandomString

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

RandomGenerator

public RandomGenerator(String name)
                throws NameFormatException
This called when instantiating the command before it is executed by the interpreter.The recordResult variable is set to false because details about the RandomGenerator step aren't needed, unlike the commands within the RandomGenerator block.

Parameters:
name - - name of the command
Throws:
NameFormatException
Method Detail

generate

public static String generate(String method,
                              String length,
                              String lengthMin,
                              String lengthMax,
                              String min,
                              String max,
                              String regexp)
Use a regular expression to generate a string or use methods to select US state name or abbreviations and generate phone numbers and strings.

Parameters:
method - - the method to be used. Either abbrevUSState, USState, phone, number, or string
length - - length of number or string to be generated. lengthMin, lengthMax, min, and max should not be specified when using this parameter.
lengthMin - - used to specify minimum length of random string generated
lengthMax - - used to specify maximum length of random string generated
min - - used to specify minimum length of random number generated
max - - used to specify maximum length of random number generated
regexp - - regular expression to be used for string generation. This should not be specified if method parameter is.
Returns:
the randomly generated string

generateRegexp

public static String generateRegexp(String regexp)
Generate a string using a specified regular expression.

Parameters:
regexp - - regular expression to be used to generate the string
Returns:
the randomly generated string

generatePhone

public static String generatePhone()
Generates a random phone number.

Returns:
the randomly generated phone number.

generateAbbrevUSState

public static String generateAbbrevUSState()
Randomly selects a US state abbreviation from the list.

Returns:
the randomly selected state abbreviation

generateUSState

public static String generateUSState()
Randomly selects a US state from the list.

Returns:
the randomly selected state

generateString

public static String generateString(String chars,
                                    int length)
This randomly generates a string given a set of characters and a desired length.

Parameters:
chars - - The characters to be used
length - - The length of the resulting string
Returns:
The generated string

execute

protected void execute(IInvocationContext ctx)
                throws Throwable
Description copied from class: Command
This method should be overridden by every Command object.

Specified by:
execute in class Command
Throws:
Exception
Throwable


Copyright © 2014. All rights reserved.