Java Is Null isNull(String sIn)

Here you can find the source of isNull(String sIn)

Description

is Null

License

Open Source License

Declaration

public static String isNull(String sIn) 

Method Source Code

//package com.java2s;

import java.io.Serializable;

public class Main {

    public static String isNull(String sIn) {
        return (sIn == null) ? "" : sIn;
    }//from   w w w.  j a  v a  2s .c  om

    public static boolean isNull(Object obj) {
        if (obj == null || obj.toString().trim().length() == 0 || obj.toString().toUpperCase().equals("NULL")) {
            return true;
        }
        return false;
    }

    public static boolean isNull(Object... obj) {
        for (int i = 0; i < obj.length; i++) {
            if (obj[i] == null || obj[i].toString().trim().length() == 0
                    || obj[i].toString().toUpperCase().equals("NULL")) {
                return true;
            }
        }
        return false;
    }

    /**
     * serializable toString
     *
     * @param serializable
     *
     * @return
     */
    public static String toString(Serializable serializable) {
        if (null == serializable) {
            return null;
        }
        try {
            return (String) serializable;
        } catch (Exception e) {
            return serializable.toString();
        }
    }
}

Related

  1. isNotNull(File file)
  2. isNotNullOrEmpty(final Object[] array)
  3. isNull(File file)
  4. isNull(Object s)
  5. isNullOrEmpty(Object[] array)