Class UUID58
java.lang.Object
de.s42.base.uuid.UUID58
UUID58 provides uuid base58 string encoding and decoding for UUIDs to shorten, improve readability and cinvalid input: '&p' support in
string form.
uuid58 strings look like: hxAGoWGvFPR35qxCG5fYuX, ouyeFFWJLjnNeJfjs9DcvY, cyAp8zexLqUQRGFxRVcBCF, ...
- Author:
- Benjamin Schiller
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigIntegerThe radix 58 as BigIntegerstatic final StringThis is the symbols used for the encodet string to improve readability avoiding similar chars like 0 and O or 1 and Istatic final char[]static final PatternThis pattern allows you to validate a uuid58 string pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UUIDfromString(String uuid58) Converts a uuid base58 string into a UUID.static booleanisUUID58Like(String string) Checks if the given string could be a valid uuid58 string.static StringConverts a UUID into a uuid base58 string.
-
Field Details
-
SYMBOLS
This is the symbols used for the encodet string to improve readability avoiding similar chars like 0 and O or 1 and I- See Also:
-
SYMBOLS_CHARS
public static final char[] SYMBOLS_CHARS -
UUID58_PATTERN
This pattern allows you to validate a uuid58 string pattern -
RADIX
The radix 58 as BigInteger
-
-
Constructor Details
-
UUID58
private UUID58()
-
-
Method Details
-
isUUID58Like
Checks if the given string could be a valid uuid58 string.- Parameters:
string-- Returns:
-
fromString
public static UUID fromString(String uuid58) throws IndexOutOfBoundsException, IllegalArgumentException, NullPointerException Converts a uuid base58 string into a UUID. ATTENTION: A uuid base58 string is often 22 signs, BUT can be as short as 18 chars if the uuid (i.e. v4) has many leading 0-- Parameters:
uuid58- A valid uuid base58 string- Returns:
- Restored UUID from uuid58 string
- Throws:
IllegalArgumentException- If the string is too longIndexOutOfBoundsException- If a character is contained which is not part of the SymbolsNullPointerException- If the parameter uuid58 is null
-
toString
Converts a UUID into a uuid base58 string.- Parameters:
uuid- The UUID to be converted- Returns:
- The uuid base58 string
- Throws:
NullPointerException- If the parameter uuid58 is null
-