コード例 #1
0
  public String process(String content) {
    Matcher matcher = Pattern.compile(ELEMENT_BOUNDARY).matcher(content);

    StringBuilder sb = new StringBuilder();
    int startIndex, matchIndex;
    for (startIndex = 0; matcher.find(); startIndex = matcher.end()) {
      matchIndex = matcher.start();
      String preMatch = content.substring(startIndex, matchIndex);
      if (!StringUtil.isBlank(preMatch)) sb.append(span(preMatch));
      if (!StringUtil.isBlank(matcher.group(2))) sb.append(matcher.group());
    }
    String postMatch = content.substring(startIndex, content.length());
    if (!StringUtil.isBlank(postMatch)) sb.append(span(postMatch));

    return sb.toString();
  }
コード例 #2
0
  private void addToList(List<String> expressionsList, String addExpression) {
    addExpression = addExpression.trim();

    if (format != null) {
      addExpression = String.format(format, addExpression);
    }

    if (!StringUtil.isEmpty(addExpression) && !expressionsList.contains(addExpression)) {
      expressionsList.add(addExpression);
    }
  }
コード例 #3
0
  /**
   * Checks if the message is an GreenPepper server tagged Exception. If so an
   * GreenPepperServerException will be thrown with the error id found.
   *
   * @param the error id found.
   * @throws GreenPepperServerException
   */
  private static void checkErrors(Object object) throws GreenPepperServerException {
    if (object instanceof Exception) {
      throw new GreenPepperServerException(
          GreenPepperServerErrorKey.CALL_FAILED, ((Exception) object).getMessage());
    }

    if (object instanceof String) {
      String msg = (String) object;
      if (!StringUtil.isEmpty(msg) && msg.indexOf(GreenPepperServerErrorKey.ERROR) > -1) {
        String errorId = msg.replace(GreenPepperServerErrorKey.ERROR, "");
        if (errorId.startsWith(LicenseErrorKey.LICENSE)) {
          throw new GreenPepperLicenceException(errorId, errorId);
        }

        throw new GreenPepperServerException(errorId, errorId);
      }
    }
  }
コード例 #4
0
  public OgnlResolution(String expression) {
    if (StringUtil.isBlank(expression))
      throw new IllegalArgumentException("No expression to resolve");

    this.expression = expression;
  }
コード例 #5
0
 public static String toNullIfEmpty(String str) {
   return StringUtil.toNullIfEmpty(str);
 }