Example usage for org.apache.commons.lang ArrayUtils EMPTY_CHARACTER_OBJECT_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_CHARACTER_OBJECT_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_CHARACTER_OBJECT_ARRAY.

Prototype

Character[] EMPTY_CHARACTER_OBJECT_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_CHARACTER_OBJECT_ARRAY.

Click Source Link

Document

An empty immutable Character array.

Usage

From source file:net.sf.json.JSONUtils.java

/**
 * Converts an array of primitive chars to objects.<br>
 * <p>//from   w ww .  j  a va  2 s . c  o  m
 * <strong>This method is not in ArrayUtils. (commons-lang 2.1)</strong>
 * </p>
 * <p>
 * This method returns <code>null</code> for a <code>null</code> input
 * array.
 * </p>
 *
 * @param array a <code>char</code> array
 * @return a <code>Character</code> array, <code>null</code> if null
 *         array input
 */
public static Object[] toObject(char[] array) {
    if (array == null) {
        return null;
    } else if (array.length == 0) {
        return ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY;
    }

    final Character[] result = new Character[array.length];

    for (int i = 0; i < array.length; i++) {
        result[i] = new Character(array[i]);
    }

    return result;
}