本文整理了Java中java.lang.reflect.Array.getShort()
方法的一些代码示例,展示了Array.getShort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.getShort()
方法的具体详情如下:
包路径:java.lang.reflect.Array
类名称:Array
方法名:getShort
[英]Returns the short at the given index in the given array. Applies to byte and short arrays.
[中]返回给定数组中给定索引处的短字符。适用于字节和短数组。
代码示例来源:origin: redisson/redisson
@Override
protected String toString(Object array, int index) {
return ForNonArrayType.SHORT.toString(Array.getShort(array, index));
}
},
代码示例来源:origin: redisson/redisson
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;
}
代码示例来源:origin: drewnoakes/metadata-extractor
if (i != 0)
string.append(' ');
string.append(Array.getShort(o, i));
代码示例来源:origin: RuedigerMoeller/fast-serialization
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;
}
代码示例来源:origin: gdpancheng/LoonAndroid3
@Override
public Object get(Object array, int index) {
return Array.getShort(array, index);
}
代码示例来源:origin: org.testifyproject.external/external-bytebuddy
@Override
protected String toString(Object array, int index) {
return ForNonArrayType.SHORT.toString(Array.getShort(array, index));
}
},
代码示例来源:origin: org.python/jython
/**
* 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);
}
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul.mini
/**
* 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);
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* 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);
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* @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));
}
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* @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));
}
}
代码示例来源:origin: org.kuali.rice/rice-core-api
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;
}
代码示例来源:origin: org.apache.calcite/calcite-linq4j
/**
* 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);
}
}
代码示例来源:origin: julianhyde/linq4j
/**
* 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);
}
}
代码示例来源:origin: javapathfinder/jpf-core
@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);
}
}
}
代码示例来源:origin: com.jtransc/jtransc-rt
@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);
}
代码示例来源:origin: org.chromattic/chromattic.core
return (E)b;
} else if (componentType == short.class) {
Short b = Array.getShort(array, index);
return (E)b;
} else {
代码示例来源:origin: EvoSuite/evosuite
@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);
}
代码示例来源:origin: org.apache.calcite/calcite-linq4j
return;
case SHORT:
sink.set(Array.getShort(dataSet, ordinal));
return;
case INT:
代码示例来源:origin: julianhyde/linq4j
return;
case SHORT:
sink.set(Array.getShort(dataSet, ordinal));
return;
case INT:
内容来源于网络,如有侵权,请联系作者删除!