Exemplo n.º 1
0
  /**
   * validate
   *
   * @param value
   * @param pattern
   * @param caseSensitive
   * @param trim
   * @return
   */
  public static boolean validate(
      String value, String pattern, boolean caseSensitive, boolean trim) {

    if (StringUtils.isBlank(value) || StringUtils.isBlank(pattern)) return false;

    Pattern p =
        (caseSensitive
            ? Pattern.compile(pattern)
            : Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));

    if (trim) value = value.trim();

    return p.matcher(value).matches();
  }
Exemplo n.º 2
0
    /**
     * @param key
     * @param v
     * @param sb
     */
    void appendQueryString(String key, Object v, StringBuilder sb) {
      if (v == null) return;

      String value = String.valueOf(v);
      if (ignoreEmpty && StringUtils.isBlank(value)) return;

      sb.append("&").append(key).append("=").append(encodeUrl(value));
    }