@ThreadSafe public class LeapCode extends Object
Long.MIN_VALUE]
log(16;2^63) = 63/4 = 15.75,正数long,最多16个字符。
| Modifier and Type | Field and Description |
|---|---|
static long |
MAX_NUMBER |
static long |
MIN_NUMBER |
| Constructor and Description |
|---|
LeapCode()
使用系统字符字典
|
LeapCode(@NotNull String seed) |
LeapCode(@NotNull String seed,
Random rand) |
LeapCode(@NotNull String seed,
Supplier<Random> rand)
自定义字典编码,要求字典不重复字符不少于编码字符数。
|
| Modifier and Type | Method and Description |
|---|---|
long |
decode(@Nullable String value)
解码出数值,
Long.MIN_VALUE解码失败 |
@NotNull String |
encode(int base,
long number,
int len)
以 26/32 字符编码,编码后字符串不少于len
|
@NotNull String |
encode26(long number)
以 26 字符编码
|
@NotNull String |
encode26(long number,
int len)
以 26 字符编码,编码后字符串不少于len
|
@NotNull String |
encode32(long number)
以 32 字符编码
|
@NotNull String |
encode32(long number,
int len)
以 32 字符编码,编码后字符串不少于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)
rand - 随机数seed - 混乱的26字母和10数字组合IllegalArgumentException - 字典内唯一字符数量位数不足26+10。@NotNull public @NotNull String encode26(long number)
number - 要编码的数字@NotNull public @NotNull String encode32(long number)
number - 要编码的数字@NotNull public @NotNull String encode26(long number, int len)
number - 要编码的数字len - 要编码的数字@NotNull public @NotNull String encode32(long number, int len)
number - 要编码的数字len - 要编码的数字@NotNull public @NotNull String encode(int base, long number, int len)
base - 编码的方式,26或32固定number - 要编码的数字len - 要编码的数字IllegalArgumentException - 如果base不是26或32public long decode(@Nullable
@Nullable String value)
Long.MIN_VALUE解码失败value - 编码后字符串Copyright © 2020. All rights reserved.