程序包 org.xmeta.util
类 UtilData
- java.lang.Object
-
- org.xmeta.util.UtilData
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringTYPE_BIGDECIMALstatic StringTYPE_BIGINTEGERstatic StringTYPE_BOOLEANstatic StringTYPE_BYTEstatic StringTYPE_BYTESstatic StringTYPE_DATEstatic StringTYPE_DATETIMEstatic StringTYPE_DOUBLEstatic StringTYPE_FLOATstatic StringTYPE_INTstatic StringTYPE_INTEGERstatic StringTYPE_LONGstatic StringTYPE_OBJECTstatic StringTYPE_SHORTstatic StringTYPE_STRINGstatic StringTYPE_TIMEstatic StringVALUE_BLANKstatic StringVALUE_CURRENT_DATEstatic StringVALUE_FALSEstatic StringVALUE_NOWstatic StringVALUE_ONEstatic StringVALUE_TRUEstatic StringVALUE_ZERO
-
构造器概要
构造器 构造器 说明 UtilData()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static List<Thing>addToSource(List<Thing> source, List<Thing> forAdd, boolean strict)添加指定的事物列表到已有的事物列表中,添加时如果存在第一个的描述者相同且名字相同的则不添加。static List<Thing>addToSource(List<Thing> source, Thing forAdd, boolean strict)添加指定的事物到源事物列表中。static StringbytesToHexString(byte[] bytes)二进制转字符串。static booleanequalsOne(String str, String[] matchs)如果str和matchs中任何一个匹配返回true,如果str=null或者matchs=null,返回false。static Stringformat(Object value, String pattern)把数据对象转换为字符串类型。static <T> Tget(Thing thing, String attributeName, ActionContext actionContext)static BigDecimalgetBigDecimal(Object v, BigDecimal defaultValue)static BigIntegergetBigInteger(Object v, BigInteger defaultValue)static booleangetBoolean(Object v, boolean defaultValue)static bytegetByte(Object v, byte defaultValue)static byte[]getBytes(Object v, byte[] defaultValue)static chargetChar(Object v, char defaultValue)static ObjectgetData(String value, ActionContext actionContext)static ObjectgetData(Thing thing, String attributeName, ActionContext actionContext)通过事物的属性获取数据。static DategetDate(Object v, Date defaultValue)static DategetDate(Object v, Date defaultValue, String pattern)static DategetDateDefault(String defaultValue)static doublegetDouble(Object v, double defaultValue)static floatgetFloat(Object v, float defaultValue)static intgetInt(Object v, int defaultValue)static longgetLong(Object v, long defaultValue)static ObjectgetObject(Thing thing, String attributeName, ActionContext actionContext)返回通过属性定义的对象,首先使用UtilData获取,如果没有从actionContext中获取。static <T> TgetObjectByType(Thing thing, String attributeName, Class<T> t, ActionContext actionContext)static shortgetShort(Object v, short defaultValue)static SimpleDateFormatgetSimpleDateFormat(String dateStr)static StringgetSizeInfo(double size)按照字节、千字节和兆返回大小的值。static StringgetString(Object v, String defaultValue)static StringgetString(Thing thing, String attributeName, ActionContext actionContext)static ThinggetThing(Thing thing, String attributeName, String childThingPath, ActionContext actionContext)先从事物指定的属性上获取事物,如果不存在从子节点的路径上获取。static ThinggetThing(Thing thing, String attributeName, ActionContext actionContext)根据事物的属性返回指定的事物。static byte[]hexStringToByteArray(String hex)将"00 01 02"形式的字符串转成byte[]static booleanisTrue(Object condition)static booleanisTrue(Object condition, boolean defaultValue)判断condition是否为true, 当condition==null时返回传入的默认值。static Objectparse(String value, String valueType, String pattern)static voidresetAttributeByType(Thing thing, String name, String type)static Objecttransfer(Object sourceValue, String targetType, String pattern, String patternType, String patternAction)转换数据类型。
-
-
-
方法详细资料
-
equalsOne
public static boolean equalsOne(String str, String[] matchs)
如果str和matchs中任何一个匹配返回true,如果str=null或者matchs=null,返回false。- 参数:
str- 字符串matchs- 匹配正则表达式- 返回:
- 是否匹配
-
format
public static String format(Object value, String pattern)
把数据对象转换为字符串类型。- 参数:
value- 值pattern- 格式- 返回:
- 结果
-
parse
public static Object parse(String value, String valueType, String pattern) throws ParseException
- 抛出:
ParseException
-
addToSource
public static List<Thing> addToSource(List<Thing> source, List<Thing> forAdd, boolean strict)
添加指定的事物列表到已有的事物列表中,添加时如果存在第一个的描述者相同且名字相同的则不添加。- 参数:
source- 源事物列表forAdd- 要添加的事物列表strict- 是否严格判断,如果是严格判断那么校验两个事物必须相等,否则校验事物的描述者和名- 返回:
- 结果
-
addToSource
public static List<Thing> addToSource(List<Thing> source, Thing forAdd, boolean strict)
添加指定的事物到源事物列表中。- 参数:
source- 源事物列表forAdd- 需要添加的事物strict- 是否严格判断,如果是严格判断那么校验两个事物必须相等,否则校验事物的描述者和名- 返回:
- 事物列表
-
getBigDecimal
public static BigDecimal getBigDecimal(Object v, BigDecimal defaultValue)
-
getBigInteger
public static BigInteger getBigInteger(Object v, BigInteger defaultValue)
-
getByte
public static byte getByte(Object v, byte defaultValue)
-
getBytes
public static byte[] getBytes(Object v, byte[] defaultValue)
-
getChar
public static char getChar(Object v, char defaultValue)
-
getSimpleDateFormat
public static SimpleDateFormat getSimpleDateFormat(String dateStr)
-
getDouble
public static double getDouble(Object v, double defaultValue)
-
getFloat
public static float getFloat(Object v, float defaultValue)
-
getLong
public static long getLong(Object v, long defaultValue)
-
getInt
public static int getInt(Object v, int defaultValue)
-
getShort
public static short getShort(Object v, short defaultValue)
-
getBoolean
public static boolean getBoolean(Object v, boolean defaultValue)
-
getSizeInfo
public static String getSizeInfo(double size)
按照字节、千字节和兆返回大小的值。- 参数:
size- 大小- 返回:
- 字符串
-
hexStringToByteArray
public static byte[] hexStringToByteArray(String hex)
将"00 01 02"形式的字符串转成byte[]- 参数:
hex- 16进制字符串- 返回:
- 字节数组
-
bytesToHexString
public static String bytesToHexString(byte[] bytes)
二进制转字符串。- 参数:
bytes- 字节数组- 返回:
- 16进制字符串
-
transfer
public static Object transfer(Object sourceValue, String targetType, String pattern, String patternType, String patternAction) throws ParseException
转换数据类型。- 参数:
sourceValue- 原值targetType- 目标值pattern- 格式patternType- 格式类型patternAction- 动作- 返回:
- 转换后的结果
- 抛出:
ParseException- 异常
-
getObject
public static Object getObject(Thing thing, String attributeName, ActionContext actionContext)
返回通过属性定义的对象,首先使用UtilData获取,如果没有从actionContext中获取。- 参数:
thing- 事物attributeName- 属性名actionContext- 变量上下文- 返回:
- 对象
-
get
public static <T> T get(Thing thing, String attributeName, ActionContext actionContext)
-
getObjectByType
public static <T> T getObjectByType(Thing thing, String attributeName, Class<T> t, ActionContext actionContext)
-
getThing
public static Thing getThing(Thing thing, String attributeName, ActionContext actionContext)
根据事物的属性返回指定的事物。- 参数:
thing- 事物attributeName- 属性名actionContext- 变量上下文- 返回:
- 事物,如果不存在返回null
-
getThing
public static Thing getThing(Thing thing, String attributeName, String childThingPath, ActionContext actionContext)
先从事物指定的属性上获取事物,如果不存在从子节点的路径上获取。- 参数:
thing- 事物attributeName- 属性名childThingPath- 子事物节点actionContext- 变量上下文- 返回:
- 要返回的额事物,如果不存在返回null
-
getData
public static Object getData(Thing thing, String attributeName, ActionContext actionContext)
通过事物的属性获取数据。- 参数:
thing- 事物attributeName- 属性名actionContext- 变量上下文- 返回:
- 结果
-
getData
public static Object getData(String value, ActionContext actionContext)
-
isTrue
public static boolean isTrue(Object condition)
-
isTrue
public static boolean isTrue(Object condition, boolean defaultValue)
判断condition是否为true, 当condition==null时返回传入的默认值。- 参数:
condition-defaultValue-- 返回:
-
getString
public static String getString(Thing thing, String attributeName, ActionContext actionContext)
-
-