Пример #1
0
  private static String trimSpace2One(String str) {
    if (StringCheckUtil.isEmpty(str)) {
      return str;
    }

    StringBuffer sb = new StringBuffer();
    char[] charArray = str.toCharArray();
    boolean spaceStartFlg = false;
    for (int i = 0; i < charArray.length; i++) {
      if (charArray[i] == ConstantMark.SPACE_CHAR
          || charArray[i] == ConstantMark.FULL_SPACE_CHAR
          || charArray[i] == ConstantMark.TAB_CHAR) {
        spaceStartFlg = true;
        continue;
      }
      if (spaceStartFlg) {
        sb.append(ConstantMark.SPACE_CHAR);
        spaceStartFlg = false;
      }
      sb.append(charArray[i]);
    }
    if (spaceStartFlg) {
      sb.append(ConstantMark.SPACE_CHAR);
    }
    return sb.toString();
  }
Пример #2
0
  private static String toUpperCaseExceptConst(String str) {
    if (StringCheckUtil.isTrimedEmpty(str)) {
      return str;
    }

    StringBuffer sb = new StringBuffer();
    String[] strArray = str.split(ConstantMark.SINGLE_QUOTAION);
    for (int i = 0; i < strArray.length; i++) {
      sb.append((i > 0) ? ConstantMark.SINGLE_QUOTAION : ConstantMark.BLANK);
      String line = StringCheckUtil.nvl(strArray[i]);
      if ((i % 2 == 0)) {
        line = trimSpace2One(line.toUpperCase());
      }
      sb.append(line);
    }
    return sb.toString();
  }
Пример #3
0
  private static boolean containsKeyword(String str, String keyword) {
    if (StringCheckUtil.isEmpty(keyword) || StringCheckUtil.isEmpty(str)) {
      return false;
    }

    int index = str.indexOf(keyword);
    if (index == -1) {
      return false;
    }

    if (index > 0 && !DIVISION_MARK_SET.contains(String.valueOf(str.charAt(index - 1)))) {
      return false;
    }

    int keywordLength = keyword.length();

    if (index < str.length() - 1 - keywordLength
        && !DIVISION_MARK_SET.contains(String.valueOf(str.charAt(index + keywordLength + 1)))) {
      return false;
    }

    return true;
  }