Class RandomUtil


  • public class RandomUtil
    extends Object
    Util class for generating random Strings
    Since:
    1.0.0
    Author:
    imre.scheffer
    • Field Detail

      • DATE_2013_01_01

        public static long DATE_2013_01_01
        Constant DATE_2013_01_01=1356998400000l
      • MAX_NUM_SYS

        public static final int MAX_NUM_SYS
        Constant MAX_NUM_SYS=62
        See Also:
        Constant Field Values
      • LOWERCASE

        public static final char[] LOWERCASE
        Constant LOWERCASE
      • UPPERCASE

        public static final char[] UPPERCASE
        Constant UPPERCASE
      • ALL_LETTER

        public static final char[] ALL_LETTER
        Constant ALL_LETTER
      • ALL_LETTER_STRING

        public static final String ALL_LETTER_STRING
        Constant ALL_LETTER_STRING=""
      • generatedIndex

        public static int generatedIndex
        Constant generatedIndex=0
      • PID

        public static final int PID
        Constant PID=
      • PID62

        protected static final String PID62
        Constant PID62=""
      • PID36

        protected static final String PID36
        Constant PID36=""
    • Constructor Detail

      • RandomUtil

        public RandomUtil()
        Default constructor, constructs a new object.
    • Method Detail

      • generateId

        public static String generateId()
        Generates fix 16 length id.
        Returns:
        generated id
      • getNextIndex

        protected static int getNextIndex()
        Generates sequential index. Restarts sequence when value greater than 1295.
        Returns:
        next index
      • paddL

        protected static String paddL​(String str,
                                      int length,
                                      char padd)
        Applies left padding to given text.
        Parameters:
        str - text to pad
        length - pad length
        padd - pad charachter
        Returns:
        left-padded text
      • convertToRadix

        protected static String convertToRadix​(long inNum,
                                               long radix)
        Converts input long to any number system. Highest available number system is 62.
        Parameters:
        inNum - long to convert
        radix - radix of the number system
        Returns:
        converted number String
      • generateToken

        protected static String generateToken()
        Generating random String token
        Returns:
        generated token