程序包 org.xmeta.util

类 UtilData

java.lang.Object
org.xmeta.util.UtilData

public class UtilData extends Object
数据工具类。
作者:
zyx
  • 字段详细资料

  • 构造器详细资料

    • UtilData

      public UtilData()
  • 方法详细资料

    • 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)
    • getDate

      public static Date getDate(Object v, Date defaultValue)
    • getDateDefault

      public static Date getDateDefault(String defaultValue)
    • getDate

      public static Date getDate(Object v, Date defaultValue, String pattern)
    • 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)
    • getString

      public static String getString(Object v, String 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)
    • resetAttributeByType

      public static void resetAttributeByType(Thing thing, String name, String type)