public class TString extends Object
Voovan Framework80797d4b533dc83bb73457eb5194d13a45779258eaf3a2c07f041a98b329f79d. WebSite: https://github.com/helyho/Voovan Licence: Apache v2 License
Modifier and Type | Field and Description |
---|---|
static char[] |
chars |
static String |
TOKEN_EMPTY |
static String |
TOKEN_EMPTY_REGEX |
static String |
TOKEN_PREFIX |
static String |
TOKEN_PREFIX_REGEX |
static String |
TOKEN_SUFFIX |
static String |
TOKEN_SUFFIX_REGEX |
static Map<Character,Integer> |
unChars |
Constructor and Description |
---|
TString() |
Modifier and Type | Method and Description |
---|---|
static String |
assembly(Object... items)
字符串快捷拼装方法
|
static String |
camelToUnderline(String param)
驼峰命名转下划线命名
|
static String |
convertEscapeChar(String source)
将系统转义字符,转义成可在字符串表达的转义字符
例如:将字符串中的 \" 转转成 \\\"
|
static Matcher |
doRegex(String source,
String regex)
执行正则运算
|
static Matcher |
doRegex(String source,
String regex,
Integer flags)
执行正则运算
|
static String |
fastReplaceAll(String source,
String regex,
String replacement)
快速字符串替换算法
默认正在 flag = 0, quoteReplacement = true
|
static String |
fastReplaceAll(String source,
String regex,
String replacement,
boolean quoteReplacement)
快速字符串替换算法
默认正在 flag = 0
|
static String |
fastReplaceAll(String source,
String regex,
String replacement,
Integer flags,
boolean quoteReplacement)
快速字符串替换算法
|
static String |
fastReplaceFirst(String source,
String regex,
String replacement)
快速字符串替换算法
默认正在 flag = 0, quoteReplacement = true
|
static String |
fastReplaceFirst(String source,
String regex,
String replacement,
boolean quoteReplacement)
快速字符串替换算法
默认正在 flag = 0
|
static String |
fastReplaceFirst(String source,
String regex,
String replacement,
Integer flags,
boolean quoteReplacement)
快速字符串替换算法
|
static String |
formatBytes(long byteCount)
格式化计算机字节单位的存储容量为文本
|
static String |
formatNumber(long value,
String unit)
按数学技术格式化数字为文本
|
static String |
fromUnicode(String source)
Unicode 转 字符串
|
static String |
generateId()
快速生成短ID
|
static String |
generateId(Object obj)
快速生成短ID
|
static String |
generateId(Object obj,
String sign)
快速生成短ID
|
static String |
generateShortUUID()
生成短 UUID
|
static String |
indent(String source,
int indentCount)
缩进字符串
|
static String |
insert(String source,
int position,
String value)
在字符串中插入字符
|
static boolean |
isBoolean(String booleanString)
判断是否是布尔值
|
static boolean |
isDecimal(String decimalString)
判断是否是浮点数
|
static boolean |
isInteger(String integerString)
判断是否是整形数
|
static boolean |
isNullOrEmpty(String source)
判断字符串空指针或者内容为空
|
static boolean |
isNumber(String numberString,
int radix)
判断是否是指定进制的数字字符串
|
static String |
leftPad(String source,
int len,
char c)
左补齐
|
static int |
maxLineLength(String source)
获取字符串中最长一行的长度
|
static String |
oneTokenReplace(String source,
String tokenName,
String tokenValue)
按照标识符进行替换
tokenName 为 null 则使用 {} 进行替换
如果为 tokenName 为数字 可以不在标识中填写数字标识,会自动按照标识的先后顺序进行替换
|
static String |
radixBigConvert(BigDecimal n_num,
int n_radix) |
static BigDecimal |
radixBigUnConvert(String str,
int n_radix) |
static String |
radixConvert(long num,
int radix) |
static long |
radixUnConvert(String str,
int radix) |
static String |
readLine(String str,
int beginIndex)
从指定位置读取一行字符串
|
static int |
regexMatch(String source,
String regex)
正则匹配
|
static int |
regexMatch(String source,
String regex,
Integer flags)
正则匹配
|
static String |
removePrefix(String source)
移除字符串前缀
|
static String |
removeSuffix(String source)
移除字符串后缀
|
static String |
replaceFirst(String source,
String mark,
String replacement)
替换第一个标志字符串
|
static String |
replaceLast(String source,
String mark,
String replacement)
替换最后一个标志字符串
|
static int |
retract(String source)
获取字符串的缩进
|
static String |
reverse(String source)
翻转字符串 输入1234 输出4321
|
static String |
rightPad(String source,
int len,
char c)
右补齐
|
static String[] |
searchByRegex(String source,
String regex)
正则表达式查找
匹配的被提取出来做数组
|
static String[] |
searchByRegex(String source,
String regex,
Integer flags)
正则表达式查找
匹配的被提取出来做数组
|
static void |
setChars(char[] argChars) |
static String[] |
split(String source,
String regex)
根据分割符把字符串分割成一个数组
|
static byte[] |
toAsciiBytes(String str)
将字符串转化成 Ascii 的 byte[]
|
static String |
toAsciiString(byte[] bytes,
int offset,
int length)
byte 转字符串
|
static String |
tokenReplace(String source,
List<Object> list)
按照标识符 Map 进行替换
|
static String |
tokenReplace(String source,
Map<String,?> tokens)
按照标识符 Map 进行替换
|
static String |
tokenReplace(String source,
Object... args)
按位置格式化字符串
TString.tokenReplace("aaaa{1}bbbb{2}cccc{3}", "1","2","3")
或者TString.tokenReplace("aaaa{}bbbb{}cccc{}", "1","2","3")
输出aaaa1bbbb2cccc3
|
static <T> T |
toObject(String value,
Type type)
字符串转换为 Java 基本类型
|
static <T> T |
toObject(String value,
Type type,
boolean ignoreCase)
字符串转换为 Java 基本类型
|
static String |
toUnicode(String source)
字符串转 Unicode
|
static String |
trimEndLF(String source)
移除字符串尾部的换行符
|
static String |
unConvertEscapeChar(String source)
将可在字符串中表达的转义字符,转义成系统转义字符
例如:将字符串中的 \\\" 转转成 \"
|
static String |
underlineToCamel(String param)
下划线命名转驼峰命名
|
static String |
upperCaseHead(String source)
单词首字母大写
|
public static String TOKEN_PREFIX
public static String TOKEN_SUFFIX
public static String TOKEN_EMPTY
public static String TOKEN_PREFIX_REGEX
public static String TOKEN_SUFFIX_REGEX
public static String TOKEN_EMPTY_REGEX
public static char[] chars
public static String upperCaseHead(String source)
source
- 字符串public static String removePrefix(String source)
source
- 目标字符串public static String removeSuffix(String source)
source
- 目标字符串public static String leftPad(String source, int len, char c)
source
- 目标字符串len
- 补齐后字符串的长度c
- 用于补齐的字符串public static String rightPad(String source, int len, char c)
source
- 目标字符串len
- 补齐后字符串的长度c
- 用于补齐的字符串public static boolean isNumber(String numberString, int radix)
numberString
- 目标字符串radix
- 进制public static boolean isInteger(String integerString)
integerString
- 数字字符串public static boolean isDecimal(String decimalString)
decimalString
- 浮点数字符串public static boolean isBoolean(String booleanString)
booleanString
- 布尔值字符串public static Matcher doRegex(String source, String regex)
source
- 目标字符串regex
- 正则表达式public static Matcher doRegex(String source, String regex, Integer flags)
source
- 目标字符串regex
- 正则表达式flags
- 正则匹配标记 CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS, COMMENTSpublic static String[] searchByRegex(String source, String regex)
source
- 目标字符串regex
- 正则表达式public static String[] searchByRegex(String source, String regex, Integer flags)
source
- 目标字符串regex
- 正则表达式flags
- 正则匹配标记 CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS, COMMENTSpublic static int regexMatch(String source, String regex)
source
- 目标字符串regex
- 正则表达式public static int regexMatch(String source, String regex, Integer flags)
source
- 目标字符串regex
- 正则表达式flags
- 正则匹配标记 CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS, COMMENTSpublic static String fastReplaceAll(String source, String regex, String replacement)
source
- 源字符串regex
- 正则字符串replacement
- 替换字符串public static String fastReplaceAll(String source, String regex, String replacement, boolean quoteReplacement)
source
- 源字符串regex
- 正则字符串replacement
- 替换字符串quoteReplacement
- 对 replacement 是否进行转移public static String fastReplaceAll(String source, String regex, String replacement, Integer flags, boolean quoteReplacement)
source
- 源字符串regex
- 正则字符串replacement
- 替换字符串flags
- 正则匹配标记 CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS, COMMENTSquoteReplacement
- 对 replacement 是否进行转移public static String fastReplaceFirst(String source, String regex, String replacement)
source
- 源字符串regex
- 正则字符串replacement
- 替换字符串public static String fastReplaceFirst(String source, String regex, String replacement, boolean quoteReplacement)
source
- 源字符串regex
- 正则字符串replacement
- 替换字符串quoteReplacement
- 对 replacement 是否进行转移public static String fastReplaceFirst(String source, String regex, String replacement, Integer flags, boolean quoteReplacement)
source
- 源字符串regex
- 正则字符串replacement
- 替换字符串flags
- 正则匹配标记 CASE_INSENSITIVE, MULTILINE, DOTALL, UNICODE_CASE, CANON_EQ, UNIX_LINES, LITERAL, UNICODE_CHARACTER_CLASS, COMMENTSquoteReplacement
- 对 replacement 是否进行转移public static boolean isNullOrEmpty(String source)
source
- 字符串public static String tokenReplace(String source, Map<String,?> tokens)
source
- 源字符串,标识符使用"{标识}"进行包裹,这些标识符将会被替换tokens
- 标识符 Map, 包含匹配字符串和替换字符串public static String tokenReplace(String source, List<Object> list)
source
- 源字符串,标识符使用"{标识}"进行包裹,这些标识符将会被替换list
- 数据 List 集合public static String tokenReplace(String source, Object... args)
source
- 字符串args
- 多个参数public static String oneTokenReplace(String source, String tokenName, String tokenValue)
source
- 源字符串,标识符使用"{标识}"进行包裹tokenName
- 标识符tokenValue
- 标志符值public static String replaceFirst(String source, String mark, String replacement)
source
- 字符串mark
- 标志字符replacement
- 替换字符public static String replaceLast(String source, String mark, String replacement)
source
- 字符串mark
- 标志字符replacement
- 替换字符public static String indent(String source, int indentCount)
source
- 待缩进的字符串indentCount
- 缩进数(空格的数目)public static String reverse(String source)
source
- 字符串public static String convertEscapeChar(String source)
source
- 源字符串public static String unConvertEscapeChar(String source)
source
- 源字符串public static String toUnicode(String source)
source
- 字符串public static String fromUnicode(String source)
source
- unicode 字符串public static <T> T toObject(String value, Type type, boolean ignoreCase)
T
- 范型value
- 字符串字面值type
- Type类型ignoreCase
- 是否在字段匹配时忽略大小写public static <T> T toObject(String value, Type type)
T
- 范型value
- 字符串字面值type
- Type类型public static void setChars(char[] argChars)
public static String radixConvert(long num, int radix)
public static long radixUnConvert(String str, int radix)
public static String radixBigConvert(BigDecimal n_num, int n_radix)
public static BigDecimal radixBigUnConvert(String str, int n_radix)
public static String generateShortUUID()
public static String generateId()
public static String generateId(Object obj)
obj
- 生成 id 的对象public static String generateId(Object obj, String sign)
obj
- 生成 id 的对象sign
- 生成 ID 的标记public static int maxLineLength(String source)
source
- unicode 字符串public static String[] split(String source, String regex)
source
- 源字符串regex
- 正则分割符public static String insert(String source, int position, String value)
source
- 源字符串position
- 插入位置, 从 1 开始value
- 插入的字符串public static String trimEndLF(String source)
source
- 源字符串public static int retract(String source)
source
- 源字符串public static String camelToUnderline(String param)
param
- 驼峰命名字符串public static String underlineToCamel(String param)
param
- 下划线命名字符串public static String assembly(Object... items)
items
- 需要拼装的字符串public static byte[] toAsciiBytes(String str)
str
- 需要转换的字符串public static String toAsciiString(byte[] bytes, int offset, int length)
bytes
- 字节数据offset
- 字节数据偏移量length
- 长度public static String readLine(String str, int beginIndex)
str
- 读取的字符串beginIndex
- 起始位置public static String formatBytes(long byteCount)
byteCount
- 字节数Copyright © 2020 Voovan. All rights reserved.