Package org.pipservices3.commons.random
Class RandomString
java.lang.Object
org.pipservices3.commons.random.RandomString
Random generator for string values.
### Example ###
char value1 = RandomString.pickChar("ABC"); // Possible result: "C"
String value2 = RandomString.pick(new String {"A","B","C"}); // Possible result: "B"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Distorts a string by randomly replacing characters in it.static char
Generates random alpha characted [A-Za-z]static String
nextString
(int min, int max) Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols.static String
Picks a random string from an array of string.static char
Picks a random character from a string.
-
Constructor Details
-
RandomString
public RandomString()
-
-
Method Details
-
pickChar
Picks a random character from a string.- Parameters:
values
- a string to pick a char from- Returns:
- a randomly picked char.
-
pick
Picks a random string from an array of string.- Parameters:
values
- strings to pick from.- Returns:
- a randomly picked string.
-
distort
Distorts a string by randomly replacing characters in it.- Parameters:
value
- a string to distort.- Returns:
- a distored string.
-
nextAlphaChar
public static char nextAlphaChar()Generates random alpha characted [A-Za-z]- Returns:
- a random characted.
-
nextString
Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols.- Parameters:
min
- (optional) minimum string length.max
- maximum string length.- Returns:
- a random string.
-