|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.test4j.tools.commons.StringHelper
public class StringHelper
| 字段摘要 | |
|---|---|
static List<String> |
DEFAULT_EXCEPTION_FILTER
默认的Exception信息过滤规则 |
static String |
EMPTY
|
| 构造方法摘要 | |
|---|---|
StringHelper()
|
|
| 方法摘要 | |
|---|---|
static String |
ascii2native(String asciiStr)
将转义后的ascII字符串恢复成原始的是字符串 例如,转义后就是:我是中文 原始字符串为:我是中文 |
static String |
camel(String name)
返回驼峰命名处理结果字符串 |
static String |
camel(String name,
String... strings)
返回驼峰命名处理结果字符串 |
static boolean |
compareWikiIgnoreSpace(String left,
String right)
比较2个wiki字符串是否相同(忽略换行) |
static String |
deCamelCase(String wikiWord)
|
static String |
deleteWhitespace(String str)
Deletes all whitespaces from a String as defined by Character.isWhitespace(char). |
static boolean |
equals(String str1,
String str2)
Compares two Strings, returning true if they are equal. |
static String |
exceptionTrace(Throwable e)
把exception的trace信息写到string中 |
static String |
exceptionTrace(Throwable e,
List<String> filters)
把exception的trace信息写到string中,同时过滤掉filters中指定的信息 |
static String |
formatHtml(String html)
把文本转义成正确格式的Html 比如:"<"转换成"<"等等 |
static String |
ignoreWhiteSpace(String str)
忽略字符串中所有的空白符 |
static int |
indexOfWhiteSpace(String text)
|
static boolean |
isBlank(String str)
|
static boolean |
isBlankOrNull(String in)
判断string是否为null或空字符串 |
static boolean |
isEmpty(String str)
Checks if a String is empty ("") or null. |
static boolean |
isSpace(char ch)
是否是空白字符串 |
static boolean |
isWhiteSpaceCharacter(char c)
|
static String |
join(char seperator,
char[] chars)
|
static String |
join(String seperator,
String[] strings)
合并字符串数组 |
static String |
ltrim(String source)
去除开头的空白符,包括回车,换行符 |
static String |
merger(Iterable<?> items,
char ch)
将list中字符串以ch分割串在一起 |
static String |
merger(String[] strs,
char ch)
|
static String |
native2ascii(String nativeStr)
将原始字符串转义为ascII字符串 例如,原始字符串为:我是中文 转义后就是:我是中文 |
static int |
parseInt(String str,
int _default)
|
static List<String> |
removeTheWhiteSpaces(List<String> original)
|
static String |
rtrim(String source)
去除末尾的空白符,包括回车,换行符 |
static String |
rTrimSpace(String source)
去除末尾的空白符,只包括空格和tab符 |
static String |
simpleDateStr(Timestamp time)
|
static String |
simpleDateTimeStr(long time)
|
static String |
simpleTimeStr(long time)
|
static String[] |
splits(String string,
String splitStr)
根据splitStr分割字符串string,并且过滤掉空串 |
static String |
substringAfterLast(String str,
String separator)
Gets the substring after the last occurrence of a separator. |
static String |
toString(Object o)
将对象转化为字符串{ddd,ddd} |
static String |
toString(Throwable e)
将exception转为string输出 |
static String |
trim(String source)
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final String EMPTY
public static final List<String> DEFAULT_EXCEPTION_FILTER
| 构造方法详细信息 |
|---|
public StringHelper()
| 方法详细信息 |
|---|
public static boolean isBlankOrNull(String in)
in -
public static String trim(String source)
public static String camel(String name)
name -
public static String camel(String name,
String... strings)
name - strings -
public static String exceptionTrace(Throwable e)
e -
public static String exceptionTrace(Throwable e,
List<String> filters)
e - filters -
public static String simpleDateStr(Timestamp time)
public static String simpleDateTimeStr(long time)
public static String simpleTimeStr(long time)
public static int parseInt(String str,
int _default)
public static String[] splits(String string,
String splitStr)
string - splitStr -
public static String join(String seperator,
String[] strings)
seperator - strings -
public static String join(char seperator,
char[] chars)
public static String formatHtml(String html)
html -
public static String toString(Object o)
o -
public static String native2ascii(String nativeStr)
nativeStr -
public static String ascii2native(String asciiStr)
asciiStr -
public static String deleteWhitespace(String str)
Deletes all whitespaces from a String as defined by
Character.isWhitespace(char).
StringUtils.deleteWhitespace(null) = null
StringUtils.deleteWhitespace("") = ""
StringUtils.deleteWhitespace("abc") = "abc"
StringUtils.deleteWhitespace(" ab c ") = "abc"
str - the String to delete whitespace from, may be null
null if null String
inputpublic static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false
StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().
str - the String to check, may be null
true if the String is empty or null
public static boolean equals(String str1,
String str2)
Compares two Strings, returning true if they are equal.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
StringUtils.equals(null, null) = true
StringUtils.equals(null, "abc") = false
StringUtils.equals("abc", null) = false
StringUtils.equals("abc", "abc") = true
StringUtils.equals("abc", "ABC") = false
str1 - the first String, may be nullstr2 - the second String, may be null
true if the Strings are equal, case sensitive, or
both nullString.equals(Object)
public static String substringAfterLast(String str,
String separator)
Gets the substring after the last occurrence of a separator. The separator is not returned.
A null string input will return null. An empty
("") string input will return the empty string. An empty or
null separator will return the empty string if the input
string is not null.
If nothing is found, the empty string is returned.
StringUtils.substringAfterLast(null, *) = null
StringUtils.substringAfterLast("", *) = ""
StringUtils.substringAfterLast(*, "") = ""
StringUtils.substringAfterLast(*, null) = ""
StringUtils.substringAfterLast("abc", "a") = "bc"
StringUtils.substringAfterLast("abcba", "b") = "a"
StringUtils.substringAfterLast("abc", "c") = ""
StringUtils.substringAfterLast("a", "a") = ""
StringUtils.substringAfterLast("a", "z") = ""
str - the String to get a substring from, may be nullseparator - the String to search for, may be null
null if null String inputpublic static String ignoreWhiteSpace(String str)
input -
public static final boolean isSpace(char ch)
ch -
public static final boolean isBlank(String str)
public static List<String> removeTheWhiteSpaces(List<String> original)
public static String deCamelCase(String wikiWord)
public static boolean isWhiteSpaceCharacter(char c)
public static int indexOfWhiteSpace(String text)
public static String ltrim(String source)
source -
public static String rtrim(String source)
source -
public static String rTrimSpace(String source)
source -
public static String toString(Throwable e)
e -
public static boolean compareWikiIgnoreSpace(String left,
String right)
left - right -
public static String merger(Iterable<?> items,
char ch)
items - ch -
public static String merger(String[] strs,
char ch)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||