程序包 org.xmeta.util
类 UtilString
java.lang.Object
org.xmeta.util.UtilString
public class UtilString extends Object
字符串工具类。
- 作者:
- zyx
-
构造器概要
构造器 构造器 说明 UtilString()
-
方法概要
修饰符和类型 方法 说明 static String
capFirst(String str)
static Object
createObjectFromParams(String params, String thingPath, ActionContext actionContext)
static Object
createObjectFromParams(Map<String,?> values, String thingPath, ActionContext actionContext)
static void
debug(ActionContext context, Object obj)
static boolean
eq(Thing thing, String attributeName, String value)
返回字符串是否相等,如果属性值为null也返回false。static String[]
getGroovyStringArray(String str)
解析使用Groovy方式定义的字符串数组,如["cb", "cb"] as String[]。static int
getInt(String str)
static Map<String,String>
getParams(String str)
解码参数字符串,分隔符默认为&,默认编码utf-8,过滤引号。static Map<String,String>
getParams(String str, String splitStr)
解码参数字符串,默认编码utf-8,过滤引号。static Map<String,String>
getParams(String str, String splitStr, String encoding)
解码参数字符串,过滤引号。static Map<String,String>
getParams(String str, String splitStr, String encoding, boolean trimQuotate)
解码参数字符串。static String
getSizeInfo(double size)
static String
getString(String value, ActionContext actionContext)
从制定的字符串值中读取字符串。static String
getString(Thing thing, String attribute, ActionContext actionContext)
从模型取指定的属性的字符串值,然后从actionContext中取可能的值。static String[]
getStringArray(String strArray)
static String
getThingManagerFileName(Thing thing)
static boolean
haveDescriptor(String descriptors, String descriptor)
判断描述者列表字符串中是否包含描述者。static byte[]
hexStringToByteArray(String hex)
将"00 01 02"形式的字符串转成byte[]static String
insert(String source, String forInsert, int index)
插入一个指定字符串至源字符串中,源字符串中用,号隔开的。static boolean
isNotNull(String str)
static boolean
isNull(String str)
static boolean
isNull(Thing thing, String attributeName)
返回指定的模型的属性是否为空,如果是字符串那么null和""都返回true。static String[]
split(String str, char ch)
分割字符串的方法非String实现,稍微快一些。static char
toHex(int nibble)
static String
toHexString(byte[] bytes)
static int[]
toIntArray(String intArray)
static String
toUnicode(String theString, boolean escapeSpace)
static String
trimFileName(String str)
返回一个正常的文件名,把/\.?static String
uncapFirst(String str)
让字符串的第一个字母小写。
-
构造器详细资料
-
UtilString
public UtilString()
-
-
方法详细资料
-
getGroovyStringArray
解析使用Groovy方式定义的字符串数组,如["cb", "cb"] as String[]。- 参数:
str
- 字符串- 返回:
- 数组
-
eq
返回字符串是否相等,如果属性值为null也返回false。- 参数:
thing
- 模型attributeName
- 属性名value
- 值- 返回:
- 是否相等
-
isNull
返回指定的模型的属性是否为空,如果是字符串那么null和""都返回true。- 参数:
thing
- 模型attributeName
- 属性名- 返回:
- 是否为null
-
split
分割字符串的方法非String实现,稍微快一些。- 参数:
str
- 字符串ch
- 分给符- 返回:
- 结果
-
haveDescriptor
判断描述者列表字符串中是否包含描述者。- 参数:
descriptors
- 描述者列表descriptor
- 描述者- 返回:
- 是否包含
-
insert
插入一个指定字符串至源字符串中,源字符串中用,号隔开的。- 参数:
source
- 源字符串forInsert
- 需要插入的字符串index
- 位置- 返回:
- 新的字符串
-
createObjectFromParams
public static Object createObjectFromParams(String params, String thingPath, ActionContext actionContext) -
createObjectFromParams
public static Object createObjectFromParams(Map<String,?> values, String thingPath, ActionContext actionContext) -
isNotNull
-
isNull
-
capFirst
-
uncapFirst
让字符串的第一个字母小写。- 参数:
str
- 字符串- 返回:
- 出理后的字符串
-
debug
-
getStringArray
-
toIntArray
-
getParams
解码参数字符串,分隔符默认为&,默认编码utf-8,过滤引号。- 参数:
str
- 参数字符串- 返回:
- 参数
-
getParams
解码参数字符串,默认编码utf-8,过滤引号。- 参数:
str
- 参数字符串splitStr
- 分隔符- 返回:
- 参数
-
getParams
解码参数字符串,过滤引号。- 参数:
str
- 参数字符串splitStr
- 分隔符encoding
- 编码- 返回:
- 分析后的参数集
-
getParams
public static Map<String,String> getParams(String str, String splitStr, String encoding, boolean trimQuotate)解码参数字符串。- 参数:
str
- 参数字符串splitStr
- 分隔符encoding
- 编码trimQuotate
- 是否过滤参数值包围的引号- 返回:
- 参数集
-
getInt
-
getString
从模型取指定的属性的字符串值,然后从actionContext中取可能的值。- 参数:
thing
- 模型attribute
- 属性名actionContext
- 变量上下文- 返回:
- 值
-
getString
从制定的字符串值中读取字符串。
如果字符串值为"号开头,那么返回"号包围的字符串值,如果是以res:开头那么从资源文件中读取,如果以上条件都不符合那么从 actionContext或binding中读取。
如果是读取资源,那么字符串的格式为:res:<resourceName>:<varName>:<defaultValue>。- 参数:
value
- 字符串值actionContext
- 动作上下文- 返回:
- 字符串
-
toUnicode
-
toHex
public static char toHex(int nibble) -
trimFileName
返回一个正常的文件名,把/\.?等替换成_,并且长度保留最后30,如果大于30增加hashcode。- 参数:
str
-- 返回:
-
getThingManagerFileName
-
toHexString
-
hexStringToByteArray
将"00 01 02"形式的字符串转成byte[]- 参数:
hex
- 16进制字符串- 返回:
- 字节数组
-
getSizeInfo
-