Package art.cutils.string
Class StringIncubator
- java.lang.Object
-
- art.cutils.string.StringIncubator
-
- All Implemented Interfaces:
Serializable
public class StringIncubator extends Object implements Serializable
You can use this class if you need to Generate Random String/Alpha-numeric string for Tickets, Session, ID etc. To generate random string you can use the default the constructor that suit your purpose or the default option which will generate string of 64 characters.Example/Usage:
StringIncubator gen = new StringIncubator(12); StringIncubator session = new StringIncubator();StringIncubator gen = new StringIncubator(12, ThreadLocalRandom.current());
String symbol = StringIncubator.DIGITS + "ACEFGHJKLMNPQRUVWXYabcdefhijkprstuvwx"; StringIncubator tickets = new StringIncubator(23, new SecureRandom(), symbol);- Since:
- 1.0
- Author:
- , Bobai Kato, Erickson (https://stackoverflow.com/users/3474/erickson)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringIncubator()
Create session identifiers, default length of 64.StringIncubator(int length)
Create an alphanumeric string from a secure generator.StringIncubator(int length, String symbols)
Create an alphanumeric string from a secure generator.StringIncubator(int length, ThreadLocalRandom random)
Constructor to hatch an alphanumeric string generator.StringIncubator(int length, Random random)
Constructor to hatch an alphanumeric string generator.StringIncubator(int length, Random random, String symbols)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
getLower()
Lower-case Alphabets.static String
getUpper()
Upper-case Alphabets.String
hatch()
Generate and returns random string.static void
setLower(@NotNull String lowercaseValue)
Use this method to set Lower-case characters.static void
setUpper(@NotNull String uppercaseValue)
Use this set the Upper case characters.
-
-
-
Field Detail
-
DIGITS
public static final String DIGITS
Digits variable.- Since:
- 1.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StringIncubator
public StringIncubator(int length, ThreadLocalRandom random)
Constructor to hatch an alphanumeric string generator.- Parameters:
length
- of hatched string/valuerandom
- any instance ofThreadLocalRandom
as required- Since:
- 1.0
-
StringIncubator
public StringIncubator(int length, Random random, String symbols)
Constructor which take the require hatch length, instance ofRandom
andString
from which to hatch the random values.- Parameters:
length
- of hatched string/valuerandom
- any instance ofRandom
as requiredsymbols
- String to generate the hatched values- Since:
- 1.0
-
StringIncubator
public StringIncubator(int length, String symbols)
Create an alphanumeric string from a secure generator.- Parameters:
symbols
- String to generate the hatched valueslength
- of hatched string/value- Since:
- 1.0
-
StringIncubator
public StringIncubator()
Create session identifiers, default length of 64.- Since:
- 1.0
-
StringIncubator
public StringIncubator(int length)
Create an alphanumeric string from a secure generator.- Parameters:
length
- of hatched string/value- Since:
- 1.0
-
-
Method Detail
-
getUpper
@Contract(pure=true) public static String getUpper()
Upper-case Alphabets.- Since:
- 1.0
-
setUpper
public static void setUpper(@NotNull @NotNull String uppercaseValue)
Use this set the Upper case characters.- Parameters:
uppercaseValue
- the upper case values.
-
getLower
@Contract(pure=true) public static String getLower()
Lower-case Alphabets.- Since:
- 1.0
-
setLower
public static void setLower(@NotNull @NotNull String lowercaseValue)
Use this method to set Lower-case characters.- Parameters:
lowercaseValue
- the lower case values.
-
hatch
public String hatch()
Generate and returns random string.- Since:
- 1.0
-
-