StringUtils.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.goafanti.common.utils;
  2. import java.util.Map;
  3. import java.util.regex.Pattern;
  4. public class StringUtils extends org.apache.commons.lang3.StringUtils {
  5. private static Pattern FRACTIONAL_NUMERIC = Pattern.compile("^[\\-+]?\\d+(\\.\\d+)?$");
  6. private static Pattern CHINESE_CODE=Pattern.compile("[\u4e00-\u9fa5]");
  7. public static boolean isFractionalNumeric(String val) {
  8. return FRACTIONAL_NUMERIC.matcher(val).matches();
  9. }
  10. public static boolean isNull(Object value) {
  11. return value == null;
  12. }
  13. /**
  14. * * 判断一个对象是否非空
  15. *
  16. * @param object Object
  17. * @return true:非空 false:空
  18. */
  19. public static boolean isNotNull(Object object) {
  20. return !isNull(object);
  21. }
  22. /**
  23. * * 判断一个Map是否为空
  24. *
  25. * @param map 要判断的Map
  26. * @return true:非空 false:空
  27. */
  28. public static boolean isNotEmpty(Map<?, ?> map)
  29. {
  30. return !isEmpty(map);
  31. }
  32. /**
  33. * * 判断一个Map是否为空
  34. *
  35. * @param map 要判断的Map
  36. * @return true:为空 false:非空
  37. */
  38. public static boolean isEmpty(Map<?, ?> map)
  39. {
  40. return isNull(map) || map.isEmpty();
  41. }
  42. /**
  43. * * 判断一个对象数组是否为空
  44. *
  45. * @param objects 要判断的对象数组
  46. ** @return true:为空 false:非空
  47. */
  48. public static boolean isEmpty(Object[] objects) {
  49. return isNull(objects) || (objects.length == 0);
  50. }
  51. public static boolean isContainChinese(String str){
  52. if (CHINESE_CODE.matcher(str).find()){
  53. return true;
  54. }
  55. return false;
  56. }
  57. public static void main(String[] args) {
  58. System.out.println(isContainChinese("91430100060111212G"));
  59. }
  60. }