@Override protected String toString(Object array, int index) { return ForNonArrayType.BYTE.toString(Array.getByte(array, index)); } },
protected String arrayToString(Object o) { int len = Array.getLength(o); Class c = o.getClass().getComponentType(); String res = "[ "; for (int i = 0; i < len; i++) { if ( c == byte.class ) res+=Array.getByte(o,i); if ( c == boolean.class ) res+=Array.getBoolean(o, i); if ( c == char.class ) res+=Array.getChar(o, i); if ( c == short.class ) res+=Array.getShort(o, i); if ( c == int.class ) res+=Array.getInt(o, i); if ( c == long.class ) res+=Array.getLong(o, i); if ( c == float.class ) res+=Array.getFloat(o, i); if ( c == double.class ) res+=Array.getDouble(o, i); if ( i < len-1) res+=","; } res += " ]"; return res; }
if (i != 0) string.append(' '); string.append(Array.getByte(o, i) & 0xff);
protected String arrayToString(Object o) { int len = Array.getLength(o); Class c = o.getClass().getComponentType(); String res = "[ "; for (int i = 0; i < len; i++) { if ( c == byte.class ) res+=Array.getByte(o,i); if ( c == boolean.class ) res+=Array.getBoolean(o, i); if ( c == char.class ) res+=Array.getChar(o, i); if ( c == short.class ) res+=Array.getShort(o, i); if ( c == int.class ) res+=Array.getInt(o, i); if ( c == long.class ) res+=Array.getLong(o, i); if ( c == float.class ) res+=Array.getFloat(o, i); if ( c == double.class ) res+=Array.getDouble(o, i); if ( i < len-1) res+=","; } res += " ]"; return res; }
dest[i] = Array.getByte(array, i);
@Override public Object get(Object array, int index) { return Array.getByte(array, index); }
@Override public Object get(Object array, int index) { return Array.getByte(array, index); }
@Override protected String toString(Object array, int index) { return ForNonArrayType.BYTE.toString(Array.getByte(array, index)); } },
/** * Returns the value of the indexed component in the specified * array object, as a {@code short}. * * @param array the array * @param index the index * @return the value of the indexed component in the specified array * @exception NullPointerException If the specified object is null * @exception IllegalArgumentException If the specified object is not * an array, or if the indexed element cannot be converted to the * return type by an identity or widening conversion * @exception ArrayIndexOutOfBoundsException If the specified {@code index} * argument is negative, or if it is greater than or equal to the * length of the specified array * @see Array#get */ public static short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { final Class<?> t = array.getClass().getComponentType(); if (MethodImpl.samePrimitive(t, Short.TYPE)) { short[] arr = (short[]) array; return arr[index]; } return getByte(array, index); }
/** * Returns the value of the indexed component in the specified * array object, as a {@code short}. * * @param array the array * @param index the index * @return the value of the indexed component in the specified array * @exception NullPointerException If the specified object is null * @exception IllegalArgumentException If the specified object is not * an array, or if the indexed element cannot be converted to the * return type by an identity or widening conversion * @exception ArrayIndexOutOfBoundsException If the specified {@code index} * argument is negative, or if it is greater than or equal to the * length of the specified array * @see Array#get */ public static short getShort(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { final Class<?> t = array.getClass().getComponentType(); if (MethodImpl.samePrimitive(t, Short.TYPE)) { short[] arr = (short[]) array; return arr[index]; } return getByte(array, index); }
/** * @throws IOException * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object, * WicketObjectOutputStream) */ public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException { int length = Array.getLength(object); dos.writeInt(length); for (int i = 0; i < length; i++) { dos.writeByte(Array.getByte(object, i)); } }
/** * @throws IOException * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object, * WicketObjectOutputStream) */ @Override public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException { int length = Array.getLength(object); dos.writeInt(length); for (int i = 0; i < length; i++) { dos.writeByte(Array.getByte(object, i)); } }
public static Object toObject(Object value) { if (!value.getClass().isArray()) return value; Class type = value.getClass().getComponentType(); if (Array.getLength(value) == 0) return null; if (!type.isPrimitive()) return Array.get(value, 0); if (boolean.class.isAssignableFrom(type)) return Array.getBoolean(value, 0); if (char.class.isAssignableFrom(type)) return new Character(Array.getChar(value, 0)); if (byte.class.isAssignableFrom(type)) return new Byte(Array.getByte(value, 0)); if (int.class.isAssignableFrom(type)) return new Integer(Array.getInt(value, 0)); if (long.class.isAssignableFrom(type)) return new Long(Array.getLong(value, 0)); if (short.class.isAssignableFrom(type)) return new Short(Array.getShort(value, 0)); if (double.class.isAssignableFrom(type)) return new Double(Array.getDouble(value, 0)); if (float.class.isAssignableFrom(type)) return new Float(Array.getFloat(value, 0)); return null; }
dest[i] = Array.getByte(array, i);
/** * Gets an item from an array. */ public Object arrayItem(Object dataSet, int ordinal) { // Plain old Array.get doesn't cut it when you have an array of // Integer values but you want to read Short values. Array.getShort // does the right thing. switch (this) { case DOUBLE: return Array.getDouble(dataSet, ordinal); case FLOAT: return Array.getFloat(dataSet, ordinal); case BOOLEAN: return Array.getBoolean(dataSet, ordinal); case BYTE: return Array.getByte(dataSet, ordinal); case CHAR: return Array.getChar(dataSet, ordinal); case SHORT: return Array.getShort(dataSet, ordinal); case INT: return Array.getInt(dataSet, ordinal); case LONG: return Array.getLong(dataSet, ordinal); case OTHER: return Array.get(dataSet, ordinal); default: throw new AssertionError("unexpected " + this); } }
/** * Gets an item from an array. */ public Object arrayItem(Object dataSet, int ordinal) { // Plain old Array.get doesn't cut it when you have an array of // Integer values but you want to read Short values. Array.getShort // does the right thing. switch (this) { case DOUBLE: return Array.getDouble(dataSet, ordinal); case FLOAT: return Array.getFloat(dataSet, ordinal); case BOOLEAN: return Array.getBoolean(dataSet, ordinal); case BYTE: return Array.getByte(dataSet, ordinal); case CHAR: return Array.getChar(dataSet, ordinal); case SHORT: return Array.getShort(dataSet, ordinal); case INT: return Array.getInt(dataSet, ordinal); case LONG: return Array.getLong(dataSet, ordinal); case OTHER: return Array.get(dataSet, ordinal); default: throw new AssertionError("unexpected " + this); } }
@JTranscSync public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { Type elementType = getArrayElementType(array.getClass()); if (elementType == Boolean.TYPE) return getBoolean(array, index); if (elementType == Byte.TYPE) return getByte(array, index); if (elementType == Character.TYPE) return getChar(array, index); if (elementType == Short.TYPE) return getShort(array, index); if (elementType == Integer.TYPE) return getInt(array, index); if (elementType == Long.TYPE) return getLong(array, index); if (elementType == Float.TYPE) return getFloat(array, index); if (elementType == Double.TYPE) return getDouble(array, index); return getInstance(array, index); }
return (E)d; } else if (componentType == byte.class) { Byte b = Array.getByte(array, index); return (E)b; } else if (componentType == char.class) {