Java Object NVL nvl(CharSequence source)

Here you can find the source of nvl(CharSequence source)

Description

nvl

License

Apache License

Declaration

public static String nvl(CharSequence source) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String nvl(CharSequence source, String re) {
        CharSequence val = hasText(source) ? source : re;
        return val.toString();
    }/*from  ww  w  . ja  v a 2s  .co m*/

    public static String nvl(CharSequence source) {
        return nvl(source, "");
    }

    public static String nvl(Object o) {
        return o == null ? "" : o.toString();
    }

    public static boolean hasText(CharSequence str) {
        if (!hasLength(str))
            return false;
        int strLen = str.length();
        for (int i = 0; i < strLen; i++)
            if (!Character.isWhitespace(str.charAt(i)))
                return true;

        return false;
    }

    public static boolean hasLength(CharSequence str) {
        return str != null && str.length() > 0;
    }

    public static boolean hasLength(String str) {
        return hasLength(((CharSequence) (str)));
    }
}

Related

  1. isNotEmpty(Object object)
  2. isNullOrEmpty(final Object obj)
  3. isNullOrEmpty(Object object, boolean zeroEqualsEmpty)
  4. isNullOrEmptyOrZero(Object object)
  5. nvl(Boolean b, boolean defaultValue)
  6. nvl(E expr1, E expr2)
  7. nvl(final T t, final T def)
  8. nvl(Integer value, Number valueWhenNull)
  9. NVL(Long l)