Java Object to String castToStringArray(Object[] array)

Here you can find the source of castToStringArray(Object[] array)

Description

EPL has embedded cast method, but it doesn't cover arrays

License

GNU General Public License

Parameter

Parameter Description
array a parameter

Declaration

public static String[] castToStringArray(Object[] array) 

Method Source Code

//package com.java2s;
/*//from   w  ww .  j  a v  a 2s  .  c  o m
 Pulsar
 Copyright (C) 2013-2015 eBay Software Foundation
 Licensed under the GPL v2 license.  See LICENSE for full terms.
 */

public class Main {
    /**
     * EPL has embedded cast method, but it doesn't cover arrays
     * 
     * @param array
     * @return
     */
    public static String[] castToStringArray(Object[] array) {
        if (array != null) {
            String[] retArray = new String[array.length];
            int i = 0;
            for (Object element : array) {
                retArray[i] = element == null ? null : element.toString();
                i++;
            }
            return retArray;
        }
        return null;
    }
}

Related

  1. castString(Object obj, String defaultValue)
  2. castString(Object val)
  3. castToString(Object inValue)
  4. castToString(Object object)
  5. castToString(Object value)
  6. objectToString(final Object value)
  7. objectToString(Object a_Object)
  8. objectToString(Object in)
  9. objectToString(Object in, boolean ignoreNull)