Java Code Examples for java.lang.reflect.Array.getInt()

The following are Jave code examples for showing how to use getInt() of the java.lang.reflect.Array class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sumo   File: AbstractCosmoSkymedImage.java   View Source Code Vote up 6 votes
public long readPixel(int x, int y,int band) {
    if (x < 0 || y < 0 || x > xSize || y > ySize) {
        return -1;
    }
    stride[1] = 1;
    stride[0] = 1;
    dims[1] = 1;
    dims[0] = 1;
    starts[1] = x;
    starts[0] = y;
    try {
        Object o2 = imagedata.read();
        return Array.getInt(o2, 0) & 0xFFFF;
    } catch (Exception ex) {
    	logger.error(null, ex);
        return 0;
    }
}
 
Example 2
Project: OpenJSharp   File: Plotter.java   View Source Code Vote up 4 votes
public void add(long value) {
    // May need to switch to a larger array type
    if ((values instanceof byte[] ||
         values instanceof short[] ||
         values instanceof int[]) &&
               value > Integer.MAX_VALUE) {
        long[] la = new long[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            la[i] = Array.getLong(values, i);
        }
        values = la;
    } else if ((values instanceof byte[] ||
                values instanceof short[]) &&
               value > Short.MAX_VALUE) {
        int[] ia = new int[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            ia[i] = Array.getInt(values, i);
        }
        values = ia;
    } else if (values instanceof byte[] &&
               value > Byte.MAX_VALUE) {
        short[] sa = new short[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            sa[i] = Array.getShort(values, i);
        }
        values = sa;
    }

    // May need to extend the array size
    if (Array.getLength(values) == size) {
        values = extendArray(values);
    }

    // Store the value
    if (values instanceof long[]) {
        ((long[])values)[size] = value;
    } else if (values instanceof int[]) {
        ((int[])values)[size] = (int)value;
    } else if (values instanceof short[]) {
        ((short[])values)[size] = (short)value;
    } else {
        ((byte[])values)[size] = (byte)value;
    }
    size++;
}
 
Example 3
Project: jdk8u-jdk   File: Plotter.java   View Source Code Vote up 4 votes
public void add(long value) {
    // May need to switch to a larger array type
    if ((values instanceof byte[] ||
         values instanceof short[] ||
         values instanceof int[]) &&
               value > Integer.MAX_VALUE) {
        long[] la = new long[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            la[i] = Array.getLong(values, i);
        }
        values = la;
    } else if ((values instanceof byte[] ||
                values instanceof short[]) &&
               value > Short.MAX_VALUE) {
        int[] ia = new int[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            ia[i] = Array.getInt(values, i);
        }
        values = ia;
    } else if (values instanceof byte[] &&
               value > Byte.MAX_VALUE) {
        short[] sa = new short[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            sa[i] = Array.getShort(values, i);
        }
        values = sa;
    }

    // May need to extend the array size
    if (Array.getLength(values) == size) {
        values = extendArray(values);
    }

    // Store the value
    if (values instanceof long[]) {
        ((long[])values)[size] = value;
    } else if (values instanceof int[]) {
        ((int[])values)[size] = (int)value;
    } else if (values instanceof short[]) {
        ((short[])values)[size] = (short)value;
    } else {
        ((byte[])values)[size] = (byte)value;
    }
    size++;
}
 
Example 4
Project: jdk8u-jdk   File: MethodExitReturnValuesTest.java   View Source Code Vote up 4 votes
static void doit(MethodExitReturnValuesTarg xx) {
    s_show("==========  Testing static methods ================");
    s_bytef();
    s_charf();
    s_doublef();
    s_floatf();
    s_intf();
    s_longf();
    s_shortf();
    s_booleanf();

    s_stringf();
    s_classf();
    s_classLoaderf();
    s_threadf();
    s_threadGroupf();
    s_intArrayf();
    s_nullObjectf();
    s_objectf();
    s_voidf();

    s_show("==========  Testing instance methods ================");
    xx.i_bytef();
    xx.i_charf();
    xx.i_doublef();
    xx.i_floatf();
    xx.i_intf();
    xx.i_longf();
    xx.i_shortf();
    xx.i_booleanf();
    xx.i_stringf();
    xx.i_intArrayf();
    xx.i_classf();
    xx.i_classLoaderf();
    xx.i_threadf();
    xx.i_threadGroupf();
    xx.i_nullObjectf();
    xx.i_objectf();
    xx.i_voidf();

    // Prove it works for native methods too
    s_show("==========  Testing native methods ================");
    StrictMath.sin(doubleValue);
    Array.getByte(arrByte, 0);
    Array.getChar(arrChar, 0);
    Array.getDouble(arrDouble, 0);
    Array.getFloat(arrFloat, 0);
    Array.getInt(arrInt, 0);
    Array.getLong(arrLong, 0);
    Array.getShort(arrShort, 0);
    Array.getBoolean(arrBoolean, 0);
    Array.get(arrObject, 0);
    stringValue.intern();
}
 
Example 5
Project: openjdk-jdk10   File: Array_getInt01.java   View Source Code Vote up 4 votes
public static int test(int i) {
    return Array.getInt(array, i);
}
 
Example 6
Project: openjdk-jdk10   File: Plotter.java   View Source Code Vote up 4 votes
public void add(long value) {
    // May need to switch to a larger array type
    if ((values instanceof byte[] ||
         values instanceof short[] ||
         values instanceof int[]) &&
               value > Integer.MAX_VALUE) {
        long[] la = new long[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            la[i] = Array.getLong(values, i);
        }
        values = la;
    } else if ((values instanceof byte[] ||
                values instanceof short[]) &&
               value > Short.MAX_VALUE) {
        int[] ia = new int[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            ia[i] = Array.getInt(values, i);
        }
        values = ia;
    } else if (values instanceof byte[] &&
               value > Byte.MAX_VALUE) {
        short[] sa = new short[Array.getLength(values)];
        for (int i = 0; i < size; i++) {
            sa[i] = Array.getShort(values, i);
        }
        values = sa;
    }

    // May need to extend the array size
    if (Array.getLength(values) == size) {
        values = extendArray(values);
    }

    // Store the value
    if (values instanceof long[]) {
        ((long[])values)[size] = value;
    } else if (values instanceof int[]) {
        ((int[])values)[size] = (int)value;
    } else if (values instanceof short[]) {
        ((short[])values)[size] = (short)value;
    } else {
        ((byte[])values)[size] = (byte)value;
    }
    size++;
}
 
Example 7
Project: openjdk-jdk10   File: MethodExitReturnValuesTest.java   View Source Code Vote up 4 votes
static void doit(MethodExitReturnValuesTarg xx) {
    s_show("==========  Testing static methods ================");
    s_bytef();
    s_charf();
    s_doublef();
    s_floatf();
    s_intf();
    s_longf();
    s_shortf();
    s_booleanf();

    s_stringf();
    s_classf();
    s_classLoaderf();
    s_threadf();
    s_threadGroupf();
    s_intArrayf();
    s_nullObjectf();
    s_objectf();
    s_voidf();

    s_show("==========  Testing instance methods ================");
    xx.i_bytef();
    xx.i_charf();
    xx.i_doublef();
    xx.i_floatf();
    xx.i_intf();
    xx.i_longf();
    xx.i_shortf();
    xx.i_booleanf();
    xx.i_stringf();
    xx.i_intArrayf();
    xx.i_classf();
    xx.i_classLoaderf();
    xx.i_threadf();
    xx.i_threadGroupf();
    xx.i_nullObjectf();
    xx.i_objectf();
    xx.i_voidf();

    // Prove it works for native methods too
    s_show("==========  Testing native methods ================");
    StrictMath.sin(doubleValue);
    Array.getByte(arrByte, 0);
    Array.getChar(arrChar, 0);
    Array.getDouble(arrDouble, 0);
    Array.getFloat(arrFloat, 0);
    Array.getInt(arrInt, 0);
    Array.getLong(arrLong, 0);
    Array.getShort(arrShort, 0);
    Array.getBoolean(arrBoolean, 0);
    Array.get(arrObject, 0);
    stringValue.intern();
}