@ThreadSafe public class LeapCode extends Object
Provides 26 chars (A-Z) and 32 chars (0-9A-Z, without UOIL. also called de-oiled U/OIL) encoding.
Supports padding, the encoded number in the range: [0,Long.MAX_VALUE]
log(16;2^63) = 63/4 = 15.75, positive long, up to 16 characters.
see base32
| Modifier and Type | Field and Description |
|---|---|
static long |
MAX_NUMBER |
static long |
MIN_NUMBER |
| Constructor and Description |
|---|
LeapCode()
default seed dict
|
LeapCode(@NotNull String seed) |
LeapCode(@NotNull String seed,
Random rand) |
LeapCode(@NotNull String seed,
Supplier<Random> rand)
Customize the seed dict, require that the dict
do not have repeat char
not less than the number of encode length.
|
| Modifier and Type | Method and Description |
|---|---|
long |
decode(@Nullable CharSequence value,
int off,
int len)
decode the number from offset, return
Long.MIN_VALUE if fail |
long |
decode(@Nullable String value)
decode the number, return
Long.MIN_VALUE if fail |
@NotNull String |
encode(int base,
long number,
int len)
encode in 26 or 32, and length no less than `len`
|
@NotNull String |
encode26(long number)
encode in 26 letters (A-Z)
|
@NotNull String |
encode26(long number,
int len)
encode in 26 letters (A-Z), and length no less than `len`
|
@NotNull String |
encode32(long number)
encode in 32 de-oiled (A-Z without UOIL)
|
@NotNull String |
encode32(long number,
int len)
encode in 32 de-oiled (A-Z without UOIL), and length no less than `len`
|
public static final long MAX_NUMBER
public static final long MIN_NUMBER
public LeapCode()
public LeapCode(@NotNull
@NotNull String seed)
public LeapCode(@NotNull
@NotNull String seed,
Supplier<Random> rand)
Customize the seed dict, require that the dict do not have repeat char not less than the number of encode length.
rand - randomseed - 26 letters and 10 numbers randomly in dictIllegalArgumentException - The count of unique chars in the dict is less than 26+10.@NotNull public @NotNull String encode26(long number)
@NotNull public @NotNull String encode32(long number)
@NotNull public @NotNull String encode26(long number, int len)
@NotNull public @NotNull String encode32(long number, int len)
@NotNull public @NotNull String encode(int base, long number, int len)
IllegalArgumentException - if `base` not 26 or 32public long decode(@Nullable
@Nullable String value)
Long.MIN_VALUE if failpublic long decode(@Nullable
@Nullable CharSequence value,
int off,
int len)
Long.MIN_VALUE if failvalue - Encoded string, case-insensitiveoff - offset to startlen - length ot decodeCopyright © 2023. All rights reserved.