程序包 org.anyline.util

类 BasicUtil

java.lang.Object
org.anyline.util.BasicUtil

public class BasicUtil extends Object
  • 字段详细资料

  • 构造器详细资料

    • BasicUtil

      public BasicUtil()
  • 方法详细资料

    • isEmpty

      public static boolean isEmpty(boolean recursion, Object obj)
      是否为空或""或"null"(大写字母"NULL"不算空) 集合对象检查是否为空或集合中是否有对象
      参数:
      recursion - recursion 是否递归查检集合对象
      obj - obj
      返回:
      boolean
    • isEmpty

      public static boolean isEmpty(Object obj)
    • isEmpty

      public static boolean isEmpty(Object... objs)
      是否全部为空
      参数:
      objs - objs
      返回:
      boolean
    • isNotEmpty

      public static boolean isNotEmpty(Object obj)
    • isNotEmpty

      public static boolean isNotEmpty(boolean recursion, Object obj)
    • equals

      public static boolean equals(byte[] bytes1, byte[] bytes2)
    • equals

      public static boolean equals(Object obj1, Object obj2)
    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(Object obj1, Object obj2)
    • equals

      public static boolean equals(Object obj1, Object obj2, boolean ignoreCase)
      对象toString相等
      参数:
      obj1 - object
      obj2 - object
      ignoreCase - 是否忽略大小写
      返回:
      boolean
    • nvl

      public static <T> T nvl(T... values)
      nvl 取第一个不为null的值, 没有符合条件的 则返回null
      类型参数:
      T - T
      参数:
      values - values
      返回:
      T
    • evl

      public static <T> T evl(boolean recursion, T... values)
      反回第一个不为空(""|null|empty)的值 没有符合条件的 则返回NULL 与nvl区别 : ""不符合evl条件 但符合nvl条件
      类型参数:
      T - T
      参数:
      recursion - recursion
      values - values
      返回:
      Object
    • evl

      public static <T> T evl(T... values)
    • getRandomNumber

      public static int getRandomNumber(int fr, int to)
      随机数
      参数:
      fr - fr
      to - to
      返回:
      int
    • getRandomNumber

      public static double getRandomNumber(double fr, double to)
    • getRandomString

      public static String getRandomString(int length, StringBuffer buffer)
      生成随机字符串
      参数:
      length - length
      buffer - buffer
      返回:
      String
    • getRandomString

      public static String getRandomString(int length)
    • getRandomLowerString

      public static String getRandomLowerString(int length)
    • getRandomUpperString

      public static String getRandomUpperString(int length)
    • getRandomNumberString

      public static String getRandomNumberString(int length)
    • getRandomCnString

      public static String getRandomCnString(int length)
      随机中文字符(GBK)
      参数:
      length - length
      返回:
      String
    • insert

      public static String insert(String src, int idx, String key)
      在src的第idx位置插入key
      参数:
      src - src
      idx - idx
      key - key
      返回:
      String
    • isNumber

      public static boolean isNumber(Object obj)
      判断数字
      参数:
      obj - obj
      返回:
      boolean
    • isBoolean

      public static boolean isBoolean(Object obj)
    • isDate

      public static boolean isDate(Object obj)
    • isDateTime

      public static boolean isDateTime(Object obj)
    • parseByte

      public static Byte parseByte(Object value, Byte def)
    • parseByte

      public static Byte parseByte(Object value) throws NumberFormatException
      抛出:
      NumberFormatException
    • parseShort

      public static Short parseShort(Object value, Short def)
    • parseShort

      public static Short parseShort(Object value) throws NumberFormatException
      抛出:
      NumberFormatException
    • parseInt

      public static Integer parseInt(Object value, Integer def)
    • parseInt

      public static Integer parseInt(Object value) throws NumberFormatException
      抛出:
      NumberFormatException
    • parseFloat

      public static Float parseFloat(Object value, Float def)
    • parseDouble

      public static Double parseDouble(Object value, Double def)
    • parseDecimal

      public static BigDecimal parseDecimal(Object value, double def)
    • parseDecimal

      public static BigDecimal parseDecimal(Object value, BigDecimal def)
    • parseLong

      public static Long parseLong(Object value, Long def)
    • parseLong

      public static Long parseLong(Object value) throws NumberFormatException
      抛出:
      NumberFormatException
    • parseBoolean

      public static Boolean parseBoolean(Object obj, Boolean def)
      类型转换
      参数:
      obj - obj
      def - def
      返回:
      Boolean
    • parseBoolean

      public static Boolean parseBoolean(Object obj)
    • parseLimit

      public static List<String> parseLimit(int num)
      拆分权限数 : 将任意一个数拆分成多个(2的n次方)的和
      参数:
      num - num
      返回:
      List
    • replace

      public static String replace(String src, String pattern, String replace)
      字符串替换
      参数:
      src - src
      pattern - pattern
      replace - replace
      返回:
      String
    • trim

      public static String trim(Object str)
      删除空格
      参数:
      str - str
      返回:
      String
    • trim

      public static String trim(String str)
      删除空格
      参数:
      str - str
      返回:
      String
    • compress

      public static String compress(String str)
      压缩空白 将多个空白压缩成一个空格
      参数:
      str - str
      返回:
      String
    • compress

      public static String[] compress(String[] strs)
    • compress

      public static List<String> compress(List<String> strs)
    • compressXml

      public static String compressXml(String xml)
    • fillLChar

      public static String fillLChar(String src, String chr, int len)
      填充字符(从左侧填充)
      参数:
      src - 原文
      chr - 填充字符
      len - 需要达到的长度
      返回:
      String
    • fillRChar

      public static String fillRChar(String src, String chr, int len)
    • fillChar

      public static String fillChar(String src, String chr, int len)
    • fillChar

      public static String fillChar(String src, int len)
    • fillLChar

      public static String fillLChar(int src, String chr, int len)
    • fillRChar

      public static String fillRChar(int src, String chr, int len)
    • fillChar

      public static String fillChar(int src, String chr, int len)
    • fillChar

      public static String fillChar(int src, int len)
    • getMapKeys

      public static List<String> getMapKeys(Map<?,?> map)
      提取HashMap的key
      参数:
      map - map
      返回:
      List
    • split

      public static List<String> split(String str, String separator)
    • charCount

      public static int charCount(String src, String chr)
      子串出现次数
      参数:
      src - src
      chr - chr
      返回:
      int
    • fetch

      public static Object fetch(Collection<?> items, String key, Object value)
    • cut

      public static String cut(String src, int fr, int to)
      截取子串
      参数:
      src - string
      fr - 开始位置
      to - 结束位置 负数表示倒数, 如-2表示删除最后2位
      返回:
      String
    • left

      public static String left(String src, int len)
      从左侧开始取len位
      参数:
      src - String
      len - 截取长度
      返回:
      String
    • right

      public static String right(String src, int len)
      从右侧开始取len位
      参数:
      src - String
      len - 截取长度
      返回:
      String
    • ellipsis

      public static String ellipsis(int length, String src)
      超长部分忽略
      参数:
      length - 最长显示长度
      src - 原文
      返回:
      String
    • localInetAddress

      public static List<InetAddress> localInetAddress()
      获取本机IP
      返回:
      List
    • localIps

      public static List<String> localIps()
      获取本机IP地址
      返回:
      List
    • containsString

      public static boolean containsString(boolean ignoreNull, boolean ignoreCase, Object[] objs, String obj)
      数组是否包含
      参数:
      ignoreNull - 是否忽略null, 如果忽略 则无论是否包含null都返回false
      ignoreCase - 是否不区分大小写
      objs - objs
      obj - obj
      返回:
      boolean
    • index

      public static int index(boolean ignoreNull, boolean ignoreCase, Object[] objs, String obj)
    • containsString

      public static boolean containsString(Object[] objs, String obj)
    • index

      public static int index(Object[] objs, String obj)
    • contains

      public static boolean contains(Object[] objs, Object obj)
    • index

      public static int index(Object[] objs, Object obj)
    • index

      public static int index(boolean ignoreNull, Collection<Object> objs, Object obj)
    • contains

      public static boolean contains(boolean ignoreNull, Collection<Object> objs, Object obj)
    • containsString

      public static <T> boolean containsString(boolean ignoreNull, boolean ignoreCase, Collection<T> objs, String obj)
    • index

      public static <T> int index(boolean ignoreNull, boolean ignoreCase, Collection<T> objs, String obj)
    • containsString

      public static boolean containsString(Collection<Object> objs, String obj)
    • index

      public static int index(Collection<Object> objs, String obj)
    • concat

      public static String concat(List<String> list, String split)
      拼接字符
      参数:
      list - list
      split - split
      返回:
      String
    • concat

      public static String concat(String split, String... values)
    • omit

      public static String omit(String src, int left, int right)
    • omit

      public static String omit(String src, int left, int right, String ellipsis)
    • escape

      public static String escape(String src)
    • unescape

      public static String unescape(String src)
    • equals

      public static boolean equals(Object v1, Object v2, List<String> properties1, List<String> properties2)
      v1与v2是否相等
      参数:
      v1 - v1
      v2 - v2
      properties1 - 属性列表1
      properties2 - 属性列表2
      返回:
      boolean
    • equals

      public static boolean equals(Object v1, Object v2, String properties)
      v1与v2是否相等
      参数:
      v1 - v1
      v2 - v2
      properties - 属性(ID:CD, NM:NAME)(ID, NM)
      返回:
      boolean
    • index

      public static int index(int index, int size)
      计算下标
      参数:
      index - 下标 从0开始 -1表示最后一行 -2表示倒数第2行
      size - 总行数
      返回:
      最终下标
    • range

      public static int[] range(Integer begin, Integer end, Integer qty, Integer total)
      确认边界
      参数:
      begin - 开始
      end - 结束
      qty - 数量
      total - 总数
      返回:
      [开始, 结束]
    • checkEl

      public static boolean checkEl(String str)
      检测是否符合el格式 ${body}
      主要过滤掉${A}xxx{B}中间不能再再现其他{}或${}格式
      参数:
      str - string
      返回:
      boolean