Example usage for java.lang Byte TYPE

List of usage examples for java.lang Byte TYPE

Introduction

In this page you can find the example usage for java.lang Byte TYPE.

Prototype

Class TYPE

To view the source code for java.lang Byte TYPE.

Click Source Link

Document

The Class instance representing the primitive type byte .

Usage

From source file:org.pentaho.reporting.engine.classic.core.util.beans.BeanUtility.java

public static boolean isSameType(final Class declared, final Class object) {
    if (declared.equals(object)) {
        return true;
    }/* ww w.  ja va  2 s. co  m*/

    if (Float.TYPE.equals(declared) && Float.class.equals(object)) {
        return true;
    }
    if (Double.TYPE.equals(declared) && Double.class.equals(object)) {
        return true;
    }
    if (Byte.TYPE.equals(declared) && Byte.class.equals(object)) {
        return true;
    }
    if (Character.TYPE.equals(declared) && Character.class.equals(object)) {
        return true;
    }
    if (Short.TYPE.equals(declared) && Short.class.equals(object)) {
        return true;
    }
    if (Integer.TYPE.equals(declared) && Integer.class.equals(object)) {
        return true;
    }
    if (Long.TYPE.equals(declared) && Long.class.equals(object)) {
        return true;
    }
    return false;
}

From source file:javadz.beanutils.locale.LocaleConvertUtilsBean.java

/**
 *  Create all {@link LocaleConverter} types for specified locale.
 *
 * @param locale The Locale//from   w  ww . j  a va2 s. c  o m
 * @return The FastHashMap instance contains the all {@link LocaleConverter} types
 *  for the specified locale.
 * @deprecated This method will be modified to return a Map in the next release.
 */
protected FastHashMap create(Locale locale) {

    FastHashMap converter = new DelegateFastHashMap(BeanUtils.createCache());
    converter.setFast(false);

    converter.put(BigDecimal.class, new BigDecimalLocaleConverter(locale, applyLocalized));
    converter.put(BigInteger.class, new BigIntegerLocaleConverter(locale, applyLocalized));

    converter.put(Byte.class, new ByteLocaleConverter(locale, applyLocalized));
    converter.put(Byte.TYPE, new ByteLocaleConverter(locale, applyLocalized));

    converter.put(Double.class, new DoubleLocaleConverter(locale, applyLocalized));
    converter.put(Double.TYPE, new DoubleLocaleConverter(locale, applyLocalized));

    converter.put(Float.class, new FloatLocaleConverter(locale, applyLocalized));
    converter.put(Float.TYPE, new FloatLocaleConverter(locale, applyLocalized));

    converter.put(Integer.class, new IntegerLocaleConverter(locale, applyLocalized));
    converter.put(Integer.TYPE, new IntegerLocaleConverter(locale, applyLocalized));

    converter.put(Long.class, new LongLocaleConverter(locale, applyLocalized));
    converter.put(Long.TYPE, new LongLocaleConverter(locale, applyLocalized));

    converter.put(Short.class, new ShortLocaleConverter(locale, applyLocalized));
    converter.put(Short.TYPE, new ShortLocaleConverter(locale, applyLocalized));

    converter.put(String.class, new StringLocaleConverter(locale, applyLocalized));

    // conversion format patterns of java.sql.* types should correspond to default
    // behaviour of toString and valueOf methods of these classes
    converter.put(java.sql.Date.class, new SqlDateLocaleConverter(locale, "yyyy-MM-dd"));
    converter.put(java.sql.Time.class, new SqlTimeLocaleConverter(locale, "HH:mm:ss"));
    converter.put(java.sql.Timestamp.class, new SqlTimestampLocaleConverter(locale, "yyyy-MM-dd HH:mm:ss.S"));

    converter.setFast(true);

    return converter;
}

From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java

/**
 * Transform an primitive array to an object array.
 * /* w ww  .  j  av a 2s  .  c  om*/
 * @param arr
 *           the array.
 * @return an array.
 */
private static Object toArray(final Object arr) {

    if (arr == null) {
        return arr;
    }

    final Class cls = arr.getClass();
    if (!cls.isArray()) {
        return arr;
    }

    Class compType = cls.getComponentType();
    int dim = 1;
    while (!compType.isPrimitive()) {
        if (!compType.isArray()) {
            return arr;
        } else {
            dim++;
            compType = compType.getComponentType();
        }
    }

    final int[] length = new int[dim];
    length[0] = Array.getLength(arr);
    Object[] newarr = null;

    try {
        if (compType.equals(Integer.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Integer"), length);
        } else if (compType.equals(Double.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Double"), length);
        } else if (compType.equals(Long.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Long"), length);
        } else if (compType.equals(Float.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Float"), length);
        } else if (compType.equals(Short.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Short"), length);
        } else if (compType.equals(Byte.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Byte"), length);
        } else if (compType.equals(Character.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Character"), length);
        } else if (compType.equals(Boolean.TYPE)) {
            newarr = (Object[]) Array.newInstance(Class.forName("java.lang.Boolean"), length);
        }
    } catch (ClassNotFoundException ex) {
        System.out.println(ex);
    }

    for (int i = 0; i < length[0]; i++) {
        if (dim != 1) {
            newarr[i] = toArray(Array.get(arr, i));
        } else {
            newarr[i] = Array.get(arr, i);
        }
    }
    return newarr;
}

From source file:com.nway.spring.jdbc.bean.JavassistBeanProcessor.java

private Object processColumn(ResultSet rs, int index, Class<?> propType, String writer, StringBuilder handler)
        throws SQLException {
    if (propType.equals(String.class)) {
        handler.append("bean.").append(writer).append("(").append("$1.getString(").append(index).append("));");
        return rs.getString(index);
    } else if (propType.equals(Integer.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getInt(").append(index).append("));");
        return rs.getInt(index);
    } else if (propType.equals(Integer.class)) {
        handler.append("bean.").append(writer).append("(").append("integerValue($1.getInt(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Integer.class);
    } else if (propType.equals(Long.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getLong(").append(index).append("));");
        return rs.getLong(index);
    } else if (propType.equals(Long.class)) {
        handler.append("bean.").append(writer).append("(").append("longValue($1.getLong(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Long.class);
    } else if (propType.equals(java.sql.Date.class)) {
        handler.append("bean.").append(writer).append("(").append("$1.getDate(").append(index).append("));");
        return rs.getDate(index);
    } else if (propType.equals(java.util.Date.class) || propType.equals(Timestamp.class)) {
        handler.append("bean.").append(writer).append("(").append("$1.getTimestamp(").append(index)
                .append("));");
        return rs.getTimestamp(index);
    } else if (propType.equals(Double.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getDouble(").append(index).append("));");
        return rs.getDouble(index);
    } else if (propType.equals(Double.class)) {
        handler.append("bean.").append(writer).append("(").append("doubleValue($1.getDouble(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Double.class);
    } else if (propType.equals(Float.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getFloat(").append(index).append("));");
        return rs.getFloat(index);
    } else if (propType.equals(Float.class)) {
        handler.append("bean.").append(writer).append("(").append("floatValue($1.getFloat(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Float.class);
    } else if (propType.equals(Time.class)) {
        handler.append("bean.").append(writer).append("(").append("$1.getTime(").append(index).append("));");
        return rs.getTime(index);
    } else if (propType.equals(Boolean.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getBoolean(").append(index).append("));");
        return rs.getBoolean(index);
    } else if (propType.equals(Boolean.class)) {
        handler.append("bean.").append(writer).append("(").append("booleanValue($1.getBoolean(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Boolean.class);
    } else if (propType.equals(byte[].class)) {
        handler.append("bean.").append(writer).append("(").append("$1.getBytes(").append(index).append("));");
        return rs.getBytes(index);
    } else if (BigDecimal.class.equals(propType)) {
        handler.append("bean.").append(writer).append("(").append("$1.getBigDecimal(").append(index)
                .append("));");
        return rs.getBigDecimal(index);
    } else if (Blob.class.equals(propType)) {
        handler.append("bean.").append(writer).append("(").append("$1.getBlob(").append(index).append("));");
        return rs.getBlob(index);
    } else if (Clob.class.equals(propType)) {
        handler.append("bean.").append(writer).append("(").append("$1.getClob(").append(index).append("));");
        return rs.getClob(index);
    } else if (propType.equals(Short.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getShort(").append(index).append("));");
        return rs.getShort(index);
    } else if (propType.equals(Short.class)) {
        handler.append("bean.").append(writer).append("(").append("shortValue($1.getShort(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Short.class);
    } else if (propType.equals(Byte.TYPE)) {
        handler.append("bean.").append(writer).append("(").append("$1.getByte(").append(index).append("));");
        return rs.getByte(index);
    } else if (propType.equals(Byte.class)) {
        handler.append("bean.").append(writer).append("(").append("byteValue($1.getByte(").append(index)
                .append("),$1.wasNull()));");
        return JdbcUtils.getResultSetValue(rs, index, Byte.class);
    } else {/*from  www .  j  a v a 2s.co  m*/
        handler.append("bean.").append(writer).append("(").append("(").append(propType.getName()).append(")")
                .append("$1.getObject(").append(index).append("));");
        return rs.getObject(index);
    }
}

From source file:org.xmlsh.util.JavaUtils.java

public static <T> T convert(Object value, Class<T> targetClass) throws InvalidArgumentException {

    assert (targetClass != null);

    assert (value != null);
    if (targetClass.isInstance(value))
        return targetClass.cast(value);

    Class<?> sourceClass = value.getClass();

    // Asking for an XdmValue class
    if (XdmValue.class.isAssignableFrom(targetClass)) {
        if (value instanceof XdmNode)
            return (T) (XdmValue) value;

        if (targetClass.isAssignableFrom(XdmAtomicValue.class)) {

            // Try some smart conversions of all types XdmAtomicValue knows
            if (value instanceof Boolean)
                return (T) new XdmAtomicValue(((Boolean) value).booleanValue());
            else if (value instanceof Double)
                return (T) new XdmAtomicValue(((Double) value).doubleValue());
            else if (value instanceof Float)
                return (T) new XdmAtomicValue(((Float) value).floatValue());

            else if (value instanceof BigDecimal)
                return (T) new XdmAtomicValue((BigDecimal) value);
            else if (value instanceof BigDecimal)
                return (T) new XdmAtomicValue((BigDecimal) value);

            else if (value instanceof URI)
                return (T) new XdmAtomicValue((URI) value);
            else if (value instanceof Long)
                return (T) new XdmAtomicValue((Long) value);
            else if (value instanceof QName)
                return (T) new XdmAtomicValue((QName) value);

            // Still wanting an xdm value
        }/*from w w  w .ja v  a  2  s  .  c o m*/

        if (isAtomic(value))
            return (T) new XdmAtomicValue(value.toString());

    }

    boolean bAtomic = isAtomic(value);
    Class<?> vclass = value.getClass();

    if (targetClass.isPrimitive() && bAtomic) {

        /* Try to match non-primative types
        */
        if (targetClass == Integer.TYPE) {
            if (vclass == Long.class)
                value = Integer.valueOf(((Long) value).intValue());
            else if (vclass == Short.class)
                value = Integer.valueOf(((Short) value).intValue());
            else if (vclass == Byte.class)
                value = Integer.valueOf(((Byte) value).intValue());
            else
                value = Integer.valueOf(value.toString());

        } else if (targetClass == Long.TYPE) {
            if (vclass == Integer.class)
                value = Long.valueOf(((Integer) value).intValue());
            else if (vclass == Short.class)
                value = Long.valueOf(((Short) value).intValue());
            else if (vclass == Byte.class)
                value = Long.valueOf(((Byte) value).intValue());
            value = Long.valueOf(value.toString());

        }

        else if (targetClass == Short.TYPE) {
            if (vclass == Integer.class)
                value = Short.valueOf((short) ((Integer) value).intValue());
            else if (vclass == Long.class)
                value = Short.valueOf((short) ((Long) value).intValue());
            else if (vclass == Byte.class)
                value = Short.valueOf((short) ((Byte) value).intValue());
            value = Short.valueOf(value.toString());

        }

        else if (targetClass == Byte.TYPE) {
            if (vclass == Integer.class)
                value = Byte.valueOf((byte) ((Integer) value).intValue());
            else if (vclass == Long.class)
                value = Byte.valueOf((byte) ((Long) value).intValue());
            else if (vclass == Short.class)
                value = Byte.valueOf((byte) ((Short) value).intValue());
            value = Byte.valueOf(value.toString());
        } else
            ; // skip

        return (T) value;
    }

    // Bean constructor

    Constructor<?> cnst = getBeanConstructor(targetClass, sourceClass);
    if (cnst != null)
        try {
            return (T) cnst.newInstance(convert(value, cnst.getParameterTypes()[0]));
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
                | InvocationTargetException e) {

            mLogger.debug("Exception converting argument for constructor", e);
        }

    // Cast through string

    String svalue = value.toString();

    if (targetClass == Integer.class)
        value = Integer.valueOf(svalue);
    else if (targetClass == Long.class)
        value = Long.valueOf(svalue);
    else if (targetClass == Short.class)
        value = Short.valueOf(svalue);
    else if (targetClass == Float.class)
        value = Float.valueOf(svalue);
    else if (targetClass == Double.class)
        value = Double.valueOf(svalue);
    else
        value = null;

    return (T) value;

}

From source file:com.nway.spring.jdbc.bean.AsmBeanProcessor.java

private Object processColumn(ResultSet rs, int index, Class<?> propType, String writer, String processorName,
        String beanName, MethodVisitor mv) throws SQLException {

    if (propType.equals(String.class)) {
        visitMethod(mv, index, beanName, "Ljava/lang/String;", "getString", writer);
        return rs.getString(index);
    } else if (propType.equals(Integer.TYPE)) {
        visitMethod(mv, index, beanName, "I", "getInt", writer);
        return rs.getInt(index);
    } else if (propType.equals(Integer.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_INTEGER, writer, processorName);
        return JdbcUtils.getResultSetValue(rs, index, Integer.class);
    } else if (propType.equals(Long.TYPE)) {
        visitMethod(mv, index, beanName, "J", "getLong", writer);
        return rs.getLong(index);
    } else if (propType.equals(Long.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_LONG, writer, processorName);
        return JdbcUtils.getResultSetValue(rs, index, Long.class);
    } else if (propType.equals(java.sql.Date.class)) {
        visitMethod(mv, index, beanName, "Ljava/sql/Date;", "getDate", writer);
        return rs.getDate(index);
    } else if (propType.equals(java.util.Date.class)) {
        visitMethodCast(mv, index, beanName, PROPERTY_TYPE_DATE, "java/util/Date", writer);
        return rs.getTimestamp(index);
    } else if (propType.equals(Timestamp.class)) {
        visitMethod(mv, index, beanName, "Ljava/sql/Timestamp;", "getTimestamp", writer);
        return rs.getTimestamp(index);
    } else if (propType.equals(Time.class)) {
        visitMethod(mv, index, beanName, "Ljava/sql/Time;", "getTime", writer);
        return rs.getTime(index);
    } else if (propType.equals(Double.TYPE)) {
        visitMethod(mv, index, beanName, "D", "getDouble", writer);
        return rs.getDouble(index);
    } else if (propType.equals(Double.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_DOUBLE, writer, processorName);
        return JdbcUtils.getResultSetValue(rs, index, Double.class);
    } else if (propType.equals(Float.TYPE)) {
        visitMethod(mv, index, beanName, "F", "getFloat", writer);
        return rs.getFloat(index);
    } else if (propType.equals(Float.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_FLOAT, writer, processorName);
        return JdbcUtils.getResultSetValue(rs, index, Float.class);
    } else if (propType.equals(Boolean.TYPE)) {
        visitMethod(mv, index, beanName, "Z", "getBoolean", writer);
        return rs.getBoolean(index);
    } else if (propType.equals(Boolean.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_BOOLEAN, writer, processorName);
        return JdbcUtils.getResultSetValue(rs, index, Boolean.class);
    } else if (propType.equals(Clob.class)) {
        visitMethod(mv, index, beanName, "Ljava/sql/Clob;", "getClob", writer);
        return rs.getClob(index);
    } else if (propType.equals(Blob.class)) {
        visitMethod(mv, index, beanName, "Ljava/sql/Blob;", "getBlob", writer);
        return rs.getBlob(index);
    } else if (propType.equals(byte[].class)) {
        visitMethod(mv, index, beanName, "[B", "getBytes", writer);
        return rs.getBytes(index);
    } else if (propType.equals(Short.TYPE)) {
        visitMethod(mv, index, beanName, "S", "getShort", writer);
        return rs.getShort(index);
    } else if (propType.equals(Short.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_SHORT, writer, processorName);
        return JdbcUtils.getResultSetValue(rs, index, Short.class);
    } else if (propType.equals(Byte.TYPE)) {
        visitMethod(mv, index, beanName, "B", "getByte", writer);
        return rs.getByte(index);
    } else if (propType.equals(Byte.class)) {
        visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_BYTE, writer, processorName);
        return rs.getByte(index);
    } else {//  w  w w .j av a  2 s .c om
        visitMethodCast(mv, index, beanName, PROPERTY_TYPE_OTHER, propType.getName().replace('.', '/'), writer);
        return rs.getObject(index);
    }
}

From source file:com.icsshs.datatransfer.database.impl.QueryBeanProcessor.java

/**
 * Convert a <code>ResultSet</code> column into an object.  Simple
 * implementations could just call <code>rs.getObject(index)</code> while
 * more complex implementations could perform type manipulation to match
 * the column's type to the bean property type.
 *
 * <p>//  w  ww  . j  av a 2 s . c  o m
 * This implementation calls the appropriate <code>ResultSet</code> getter
 * method for the given property type to perform the type conversion.  If
 * the property type doesn't match one of the supported
 * <code>ResultSet</code> types, <code>getObject</code> is called.
 * </p>
 *
 * @param rs The <code>ResultSet</code> currently being processed.  It is
 * positioned on a valid row before being passed into this method.
 *
 * @param index The current column index being processed.
 *
 * @param propType The bean property type that this column needs to be
 * converted into.
 *
 * @throws SQLException if a database access error occurs
 *
 * @return The object from the <code>ResultSet</code> at the given column
 * index after optional type processing or <code>null</code> if the column
 * value was SQL NULL.
 */
protected Object processColumn(ResultSet rs, int index, Class<?> propType) throws SQLException {

    if (!propType.isPrimitive() && rs.getObject(index) == null) {
        return null;
    }

    if (propType.equals(String.class)) {
        return rs.getString(index);

    } else if (propType.equals(Integer.TYPE) || propType.equals(Integer.class)) {
        return Integer.valueOf(rs.getInt(index));

    } else if (propType.equals(Boolean.TYPE) || propType.equals(Boolean.class)) {
        return Boolean.valueOf(rs.getBoolean(index));

    } else if (propType.equals(Long.TYPE) || propType.equals(Long.class)) {
        return Long.valueOf(rs.getLong(index));

    } else if (propType.equals(Double.TYPE) || propType.equals(Double.class)) {
        return Double.valueOf(rs.getDouble(index));

    } else if (propType.equals(Float.TYPE) || propType.equals(Float.class)) {
        return Float.valueOf(rs.getFloat(index));

    } else if (propType.equals(Short.TYPE) || propType.equals(Short.class)) {
        return Short.valueOf(rs.getShort(index));

    } else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) {
        return Byte.valueOf(rs.getByte(index));

    } else if (propType.equals(Timestamp.class)) {
        return rs.getTimestamp(index);

    } else if (propType.equals(byte[].class)) {
        return rs.getBytes(index);

    } else {
        return rs.getObject(index);

    }

}

From source file:Main.java

/**
 * <p>Inserts the specified element at the specified position in the array.
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component
 * type of the returned array is always the same as that of the input
 * array.</p>/*from  w w w  .  j ava2  s.  c o  m*/
 *
 * <p>If the input array is {@code null}, a new one element array is returned
 *  whose component type is the same as the element.</p>
 *
 * <pre>
 * ArrayUtils.add([1], 0, 2)         = [2, 1]
 * ArrayUtils.add([2, 6], 2, 3)      = [2, 6, 3]
 * ArrayUtils.add([2, 6], 0, 1)      = [1, 2, 6]
 * ArrayUtils.add([2, 6, 3], 2, 1)   = [2, 6, 1, 3]
 * </pre>
 *
 * @param array  the array to add the element to, may be {@code null}
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range
 * (index < 0 || index > array.length).
 */
public static byte[] add(byte[] array, int index, byte element) {
    return (byte[]) add(array, index, Byte.valueOf(element), Byte.TYPE);
}

From source file:org.enerj.apache.commons.beanutils.ConvertUtilsBean.java

/**
 * Remove all registered {@link Converter}s, and re-establish the
 * standard Converters./*  w w w . j  a  v  a 2s.c  o  m*/
 */
public void deregister() {

    boolean booleanArray[] = new boolean[0];
    byte byteArray[] = new byte[0];
    char charArray[] = new char[0];
    double doubleArray[] = new double[0];
    float floatArray[] = new float[0];
    int intArray[] = new int[0];
    long longArray[] = new long[0];
    short shortArray[] = new short[0];
    String stringArray[] = new String[0];

    converters.clear();
    register(BigDecimal.class, new BigDecimalConverter());
    register(BigInteger.class, new BigIntegerConverter());
    register(Boolean.TYPE, new BooleanConverter(defaultBoolean));
    register(Boolean.class, new BooleanConverter(defaultBoolean));
    register(booleanArray.getClass(), new BooleanArrayConverter(booleanArray));
    register(Byte.TYPE, new ByteConverter(defaultByte));
    register(Byte.class, new ByteConverter(defaultByte));
    register(byteArray.getClass(), new ByteArrayConverter(byteArray));
    register(Character.TYPE, new CharacterConverter(defaultCharacter));
    register(Character.class, new CharacterConverter(defaultCharacter));
    register(charArray.getClass(), new CharacterArrayConverter(charArray));
    register(Class.class, new ClassConverter());
    register(Double.TYPE, new DoubleConverter(defaultDouble));
    register(Double.class, new DoubleConverter(defaultDouble));
    register(doubleArray.getClass(), new DoubleArrayConverter(doubleArray));
    register(Float.TYPE, new FloatConverter(defaultFloat));
    register(Float.class, new FloatConverter(defaultFloat));
    register(floatArray.getClass(), new FloatArrayConverter(floatArray));
    register(Integer.TYPE, new IntegerConverter(defaultInteger));
    register(Integer.class, new IntegerConverter(defaultInteger));
    register(intArray.getClass(), new IntegerArrayConverter(intArray));
    register(Long.TYPE, new LongConverter(defaultLong));
    register(Long.class, new LongConverter(defaultLong));
    register(longArray.getClass(), new LongArrayConverter(longArray));
    register(Short.TYPE, new ShortConverter(defaultShort));
    register(Short.class, new ShortConverter(defaultShort));
    register(shortArray.getClass(), new ShortArrayConverter(shortArray));
    register(String.class, new StringConverter());
    register(stringArray.getClass(), new StringArrayConverter(stringArray));
    register(Date.class, new SqlDateConverter());
    register(Time.class, new SqlTimeConverter());
    register(Timestamp.class, new SqlTimestampConverter());
    register(File.class, new FileConverter());
    register(URL.class, new URLConverter());

}

From source file:Main.java

/**
 * <p>Inserts the specified element at the specified position in the array.
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component
 * type of the returned array is always the same as that of the input
 * array.</p>/*from w ww.  java2 s. c  o  m*/
 *
 * <p>If the input array is {@code null}, a new one element array is returned
 *  whose component type is the same as the element.</p>
 *
 * <pre>
 * ArrayUtils.add([1], 0, 2)         = [2, 1]
 * ArrayUtils.add([2, 6], 2, 3)      = [2, 6, 3]
 * ArrayUtils.add([2, 6], 0, 1)      = [1, 2, 6]
 * ArrayUtils.add([2, 6, 3], 2, 1)   = [2, 6, 1, 3]
 * </pre>
 *
 * @param array  the array to add the element to, may be {@code null}
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range
 * (index < 0 || index > array.length).
 */
public static byte[] add(final byte[] array, final int index, final byte element) {
    return (byte[]) add(array, index, Byte.valueOf(element), Byte.TYPE);
}