Java Utililty Methods Object Array Convert To

List of utility methods to do Object Array Convert To

Description

The list of methods to do Object Array Convert To are organized into topic(s).

Method

ObjectconvertObject(final Object obj, final Class clazz)
Converts an given object to the given class type.
if (clazz.isAssignableFrom(obj.getClass())) {
    return obj;
} else {
    if (String.class.isAssignableFrom(clazz)) {
        return obj.toString();
    else if (Integer.class.isAssignableFrom(clazz)) {
        if (obj instanceof String) {
...
byte[]convertObjectArrayToByte(Object[] array)
Converts an object array to the primitive type
byte[] primitives = new byte[array.length];
for (int i = 0; i < array.length; i++)
    primitives[i] = (byte) (Byte) array[i];
return primitives;
StringconvertObjectGUIToByteString(byte[] objectGUID)

Creates a byte-based String representation of a raw byte array representing the value of the objectGUID attribute retrieved from Active Directory.

The returned string is useful to perform queries on AD based on the objectGUID value.

StringBuilder result = new StringBuilder();
for (int i = 0; i < objectGUID.length; i++) {
    String transformed = prefixZeros((int) objectGUID[i] & 0xFF);
    result.append("\\");
    result.append(transformed);
return result.toString();
TconvertObjectToBean(Object obj, Class clazz)
convert Object To Bean
if (obj != null && clazz.isInstance(obj)) {
    return (T) obj;
return null;
booleanconvertObjectToBoolean(Object value)
Throws an IllegalArgumentException if the provided value is null.
if (value != null) {
    if (value instanceof Boolean) {
        return ((Boolean) value).booleanValue();
    } else {
        return Boolean.valueOf(value.toString()).booleanValue();
} else {
    throw new IllegalArgumentException("Property value was null so it couldn't be converted to a boolean.");
...
intconvertObjectToInt(Object value)
convert Object To Int
if (value != null) {
    if (value instanceof Integer) {
        return ((Integer) value).intValue();
    } else {
        return Integer.valueOf(value.toString()).intValue();
} else {
    throw new NullPointerException("Property value was null so it couldn't be converted to an int.");
...
ObjectconvertObjectToIntegerIfNecessary(final Object configValue)
convert Object To Integer If Necessary
if (configValue instanceof String) {
    return Integer.valueOf((String) configValue);
return configValue;
StringconvertObjectToSqlSyntaxe(Object value)
convert Object To Sql Syntaxe
String valuesSql = "''";
if (value != null) {
    if (value instanceof String) {
        valuesSql = "'" + ((String) value).replaceAll("'", "''") + "'";
    } else if (value instanceof Boolean) {
        valuesSql = "" + ((Boolean) value ? 1 : 0);
    } else {
        valuesSql = value.toString();
...
int[]objectArrayToIntArray(Object[] objectArray)
object Array To Int Array
int[] returnInt = new int[objectArray.length];
for (int i = 0; i < objectArray.length; i++) {
    returnInt[i] = (Integer) objectArray[i];
return returnInt;
Object[]objectArrayToObjectArray(Object[] objArray)
object Array To Object Array
Object[] array = new Object[objArray.length];
int i = 0;
for (Object obj : objArray) {
    array[i++] = obj;
return array;