public abstract class ShortCodeUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static char[] |
URLSAFE_CHAR_TABLE
Url安全的自定义进制
不含分隔字符,见常量:
DEFAULT_SPLIT_CHAR |
static char |
URLSAFE_SPLIT_CHAR
Url安全的分隔字符(不能与
URLSAFE_CHAR_TABLE 中的字符重复) |
| 构造器和说明 |
|---|
ShortCodeUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
toCode(long id)
根据ID生成短字符串(最小长度6位)
|
static String |
toCode(long id,
char[] charTable,
char splitChar)
根据ID生成短字符串(最小长度5)
|
static String |
toCode(long id,
char[] charTable,
char splitChar,
int minLength)
根据ID生成短字符串
|
static String |
toCode(long id,
int minLength)
根据ID生成短字符串(最小长度6位)
|
static long |
toId(String code)
短字符串转为64位长整形ID
|
static long |
toId(String code,
char[] charsTable,
char splitChar)
短字符串转为64位长整形ID
|
public static final char[] URLSAFE_CHAR_TABLE
DEFAULT_SPLIT_CHARpublic static final char URLSAFE_SPLIT_CHAR
URLSAFE_CHAR_TABLE 中的字符重复)public static String toCode(long id, @NonNull char[] charTable, char splitChar, int minLength)
id - ID(必须大于等于0)charTable - 自定义进制字符集splitChar - 正式字符与补位字符之间的分隔符(该字符不与chars参数中的任意字符相同)minLength - 最小字符长度IllegalArgumentException - ID小于0 或 charTable为nullpublic static String toCode(long id, @NonNull char[] charTable, char splitChar)
id - ID(必须大于等于0)charTable - 自定义进制字符集splitChar - 正式字符与补位字符之间的分隔符(该字符不与chars参数中的任意字符相同)IllegalArgumentException - ID小于0 或 charTable为nullpublic static String toCode(long id, int minLength)
id - IDminLength - 最小字符长度IllegalArgumentException - ID小于0public static String toCode(long id)
id - IDIllegalArgumentException - ID小于0public static long toId(String code, @NonNull char[] charsTable, char splitChar)
code - 短字符串charsTable - 自定义进制splitChar - 分隔字符IllegalArgumentException - charTable为nullpublic static long toId(String code)
code - 短字符串Copyright © 2021 EasyJ寮�婧愮ぞ鍖�. All rights reserved.