Package ai.bizone.shortuuid
Class Base36Or62
java.lang.Object
ai.bizone.shortuuid.Base36Or62
Base36Or62 is a utility class that provides methods to encode and decode numbers using Base36 or Base62 encoding.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigIntegerprivate static final BigIntegerprivate static final Stringprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static BigIntegerDecodes a string using Base36 encoding.(package private) static Stringencode(BigInteger number, boolean base62) Encodes a number using Base36 encoding.
-
Field Details
-
BASE_62
-
DIGITS_62
- See Also:
-
DIGITS_62_REGEX
- See Also:
-
BASE_36
-
DIGITS_36
- See Also:
-
DIGITS_36_REGEX
- See Also:
-
-
Constructor Details
-
Base36Or62
public Base36Or62()
-
-
Method Details
-
encode
Encodes a number using Base36 encoding.- Parameters:
number- a positive integerbase62- whether to use Base62 or Base36- Returns:
- a Base36 string
- Throws:
IllegalArgumentException- ifnumberis a negative integer
-
decode
Decodes a string using Base36 encoding.- Parameters:
string- a Base36 stringbase62- whether to use Base62 or Base36bitLimit- amount of bits the number is allowed to have- Returns:
- a positive integer
- Throws:
IllegalArgumentException- ifstringis empty
-