@Override protected String toString(Object array, int index) { return ForNonArrayType.SHORT.toString(Array.getShort(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.getShort(o, i));
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; }
@Override public Object get(Object array, int index) { return Array.getShort(array, index); }
@Override protected String toString(Object array, int index) { return ForNonArrayType.SHORT.toString(Array.getShort(array, index)); } },
/** * Byte order reverses an <code>Array</code> of <code>shorts</code> * * @param array input array */ private static void swapShortArray(Object array) { int len = Array.getLength(array); short tmp; int b1, b2; for (int i = 0; i < len; i++) { tmp = Array.getShort(array, i); b1 = (tmp >> 0) & 0xff; b2 = (tmp >> 8) & 0xff; tmp = (short) (b1 << 8 | b2 << 0); Array.setShort(array, i, tmp); } } }
/** * Returns the value of the indexed component in the specified * array object, as an {@code int}. * * @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 int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { final Class<?> t = array.getClass().getComponentType(); if (MethodImpl.samePrimitive(t, Integer.TYPE)) { int[] arr = (int[]) array; return arr[index]; } return getShort(array, index); }
/** * Returns the value of the indexed component in the specified * array object, as an {@code int}. * * @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 int getInt(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { final Class<?> t = array.getClass().getComponentType(); if (MethodImpl.samePrimitive(t, Integer.TYPE)) { int[] arr = (int[]) array; return arr[index]; } return getShort(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.writeShort(Array.getShort(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.writeShort(Array.getShort(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; }
/** * 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); } }
@Test public void getSetShortFieldTest() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { if(verifyNoPropertyViolation()) { ShortField sf = new ShortField(); Field f = sf.getClass().getField("f"); f.set(sf, (short)3); assertEquals((short)f.get(sf), (short)3); short[] x = new short[] {1,2,3}; Array.setShort(x, 0, (short) 3); assertEquals(Array.getShort(x, 0), (short)3); } } }
@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)b; } else if (componentType == short.class) { Short b = Array.getShort(array, index); return (E)b; } else {
@Override public void SALOAD(Object conc_array, int conc_index) { // pop symbolic arguments IntegerValue symb_index = env.topFrame().operandStack.popBv32(); ReferenceExpression array_ref = env.topFrame().operandStack.popRef(); /* check reference initialization */ env.heap.initializeReference(conc_array, array_ref); /* null-check */ if (nullReferenceViolation(array_ref, conc_array)) { return; } /* negative index */ if (negativeIndexViolation(conc_index, symb_index)) { return; } /* out of bound index */ ReferenceExpression symb_array = array_ref; int conc_array_length = Array.getLength(conc_array); IntegerValue symb_array_length = env.heap.getField("", ARRAY_LENGTH, conc_array, symb_array, conc_array_length); if (indexTooBigViolation(conc_index, symb_index, conc_array_length, symb_array_length)) return; short conc_value = Array.getShort(conc_array, conc_index); IntegerValue e = env.heap.array_load(symb_array, conc_index, (long) conc_value); env.topFrame().operandStack.pushBv32(e); }
return; case SHORT: sink.set(Array.getShort(dataSet, ordinal)); return; case INT:
return; case SHORT: sink.set(Array.getShort(dataSet, ordinal)); return; case INT: