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

The following are Jave code examples for showing how to use setBoolean() 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: Android-Router   File: ValueParser.java   View Source Code Vote up 5 votes
private static void setArray(Object array, String arrayType, int index, Object value) throws ValueParseException {
    if ("int".equals(arrayType)) {
        Array.setInt(array, index, (Integer) parse(value, arrayType));
    } else if ("boolean".equals(arrayType)) {
        Array.setBoolean(array, index, (Boolean) parse(value, arrayType));
    } else if ("long".equals(arrayType)) {
        Array.setLong(array, index, (Long) parse(value, arrayType));
    } else if ("double".equals(arrayType)) {
        Array.setDouble(array, index, (Double) parse(value, arrayType));
    } else if ("float".equals(arrayType)) {
        Array.setFloat(array, index, (Float) parse(value, arrayType));
    } else {
        Array.set(array, index, parse(value, arrayType));
    }
}
 
Example 2
Project: AndroidApktool   File: BaseConstructor.java   View Source Code Vote up 4 votes
protected Object constructArrayStep2(SequenceNode node, Object array) {
    final Class<?> componentType = node.getType().getComponentType();

    int index = 0;
    for (Node child : node.getValue()) {
        // Handle multi-dimensional arrays...
        if (child.getType() == Object.class) {
            child.setType(componentType);
        }

        final Object value = constructObject(child);

        if (componentType.isPrimitive()) {
            // Null values are disallowed for primitives
            if (value == null) {
                throw new NullPointerException("Unable to construct element value for " + child);
            }

            // Primitive arrays require quite a lot of work.
            if (byte.class.equals(componentType)) {
                Array.setByte(array, index, ((Number) value).byteValue());

            } else if (short.class.equals(componentType)) {
                Array.setShort(array, index, ((Number) value).shortValue());

            } else if (int.class.equals(componentType)) {
                Array.setInt(array, index, ((Number) value).intValue());

            } else if (long.class.equals(componentType)) {
                Array.setLong(array, index, ((Number) value).longValue());

            } else if (float.class.equals(componentType)) {
                Array.setFloat(array, index, ((Number) value).floatValue());

            } else if (double.class.equals(componentType)) {
                Array.setDouble(array, index, ((Number) value).doubleValue());

            } else if (char.class.equals(componentType)) {
                Array.setChar(array, index, ((Character) value).charValue());

            } else if (boolean.class.equals(componentType)) {
                Array.setBoolean(array, index, ((Boolean) value).booleanValue());

            } else {
                throw new YAMLException("unexpected primitive type");
            }

        } else {
            // Non-primitive arrays can simply be assigned:
            Array.set(array, index, value);
        }

        ++index;
    }
    return array;
}
 
Example 3
Project: 5zig-TIMV-Plugin   File: BaseConstructor.java   View Source Code Vote up 4 votes
protected Object constructArrayStep2(SequenceNode node, Object array) {
    final Class<?> componentType = node.getType().getComponentType();

    int index = 0;
    for (Node child : node.getValue()) {
        // Handle multi-dimensional arrays...
        if (child.getType() == Object.class) {
            child.setType(componentType);
        }

        final Object value = constructObject(child);

        if (componentType.isPrimitive()) {
            // Null values are disallowed for primitives
            if (value == null) {
                throw new NullPointerException(
                        "Unable to construct element value for " + child);
            }

            // Primitive arrays require quite a lot of work.
            if (byte.class.equals(componentType)) {
                Array.setByte(array, index, ((Number) value).byteValue());

            } else if (short.class.equals(componentType)) {
                Array.setShort(array, index, ((Number) value).shortValue());

            } else if (int.class.equals(componentType)) {
                Array.setInt(array, index, ((Number) value).intValue());

            } else if (long.class.equals(componentType)) {
                Array.setLong(array, index, ((Number) value).longValue());

            } else if (float.class.equals(componentType)) {
                Array.setFloat(array, index, ((Number) value).floatValue());

            } else if (double.class.equals(componentType)) {
                Array.setDouble(array, index, ((Number) value).doubleValue());

            } else if (char.class.equals(componentType)) {
                Array.setChar(array, index, ((Character) value).charValue());

            } else if (boolean.class.equals(componentType)) {
                Array.setBoolean(array, index, ((Boolean) value).booleanValue());

            } else {
                throw new YAMLException("unexpected primitive type");
            }

        } else {
            // Non-primitive arrays can simply be assigned:
            Array.set(array, index, value);
        }

        ++index;
    }
    return array;
}
 
Example 4
Project: Zombe-Modpack   File: Cheat.java   View Source Code Vote up 4 votes
@Override
protected void onClientTick(EntityPlayerSP player) {
    modCheatAllowed = ZHandle.handle("allowCheats", true);

    if (getGamma() < 100f) cheatGamma = getGamma();
    setGamma((cheating && cheatHighlight && (!isInMenu() || getMenu() instanceof GuiChat || getMenu() instanceof GuiContainer)) ? 1000f : cheatGamma);

    boolean enable = optNerfEnderman && !isMultiplayer();
    if (enable != cheatCarryOverride)
    try {
        cheatCarryOverride = enable;
        Object arr = getValue(fCarryBlocks, null);
        if (cheatCarryBlocks == null) {
            cheatCarryBlocks = new boolean[256];
            for (int i=0;i<256;i++) cheatCarryBlocks[i] = Array.getBoolean(arr, i);
        }
        for (int i=0;i<256;i++) Array.setBoolean(arr, i, !enable && cheatCarryBlocks[i]);
    } catch (Exception e) {}

    if (!isInMenu() && wasKeyPressedThisTick(keyCheat)) {
        cheating = !cheating;
        if (!modCheatAllowed && cheating) {
            cheating = false;
            chatClient("\u00a74zombe's \u00a72cheat\u00a74-mod is not allowed on this server.");
        }
    }

    if (!cheating) return;
    if (!isInMenu()) {
        if (wasKeyPressedThisTick(keyShowMobs)) cheatShowMobs = !cheatShowMobs;
        if (wasKeyPressedThisTick(keyShowOres)) cheatShowOres = !cheatShowOres;
        if (wasKeyPressedThisTick(keyHighlight)) cheatHighlight = !cheatHighlight;
        if (wasKeyPressedThisTick(keyHealth)) optRestoreHealth = !optRestoreHealth;
        if (wasKeyPressedThisTick(keyDamage)) optDisableDamage = !optDisableDamage;
        if (optSeeIsToggle) {
            if (wasKeyPressedThisTick(keySee)) cheatSee = !cheatSee;
        } else cheatSee = isKeyDownThisTick(keySee);
        if (!isMultiplayer() && wasKeyPressedThisTick(keyRemoveFire)) {
            BlockPos pos = getPos(getView());
            int x = getX(pos), y = getY(pos), z = getZ(pos);
            World world = getWorld();
            for (int dx = -16; dx <= 16; ++dx)
            for (int dy = -16; dy <= 16; ++dy)
            for (int dz = -16; dz <= 16; ++dz)
            if (getIdAt(world,x+dx,y+dy,z+dz) == 51)
                setIdAt(world,0,MARK_BOTH,x+dx,y+dy,z+dz);
        }
    }
    if (!isMultiplayer()) {
        /*
        if (!optCheatFallDamage) setFall(player, 0f);
        boolean arrowChk = true;
        if (optCheatInfArrows || optCheatInfArmor || optCheatInfSword || optCheatInfTools)
        for (int slot=0;slot<invItemsArr.length;slot++)
        if (invItemsArr[slot] != null) {
            ItemStack items = invItemsArr[slot];
            int id = getItemsId(items);
            if (id < 256 || id >= cheatItems) continue;
            if (optCheatInfArrows && id==262 && arrowChk) {
                arrowChk = false;
                int count = getItemsCount(items);
                if (cheatArrowCount - 1 == count) setItemsCount(items, ++count);
                cheatArrowCount = count;
            } else if (cheatDamage[id]) setItemsInfo(items, 0);
        }
        if (optCheatInfArmor) for (int slot=0;slot<invArmorsArr.length;slot++) if (invArmorsArr[slot] != null) {
            int id = getItemsId(invArmorsArr[slot]);
            if (id < 256 || id >= cheatItems) continue;
            if (cheatDamage[id]) setItemsInfo(invArmorsArr[slot], 0);
        }
        */
    }
}
 
Example 5
Project: openjdk-jdk10   File: Array_setBoolean01.java   View Source Code Vote up 4 votes
public static boolean test(int i, boolean value) {
    Array.setBoolean(array, i, value);
    return array[i];
}