Class RandomString

java.lang.Object
org.pipservices3.commons.random.RandomString

public class RandomString extends Object
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 Details

    • RandomString

      public RandomString()
  • Method Details

    • pickChar

      public static char pickChar(String values)
      Picks a random character from a string.
      Parameters:
      values - a string to pick a char from
      Returns:
      a randomly picked char.
    • pick

      public static String pick(String[] values)
      Picks a random string from an array of string.
      Parameters:
      values - strings to pick from.
      Returns:
      a randomly picked string.
    • distort

      public static String distort(String value)
      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

      public 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.
      Parameters:
      min - (optional) minimum string length.
      max - maximum string length.
      Returns:
      a random string.