當前位置: 首頁>>代碼示例>>Java>>正文


Java Array.setDouble方法代碼示例

本文整理匯總了Java中java.lang.reflect.Array.setDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java Array.setDouble方法的具體用法?Java Array.setDouble怎麽用?Java Array.setDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.Array的用法示例。


在下文中一共展示了Array.setDouble方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setArray

import java.lang.reflect.Array; //導入方法依賴的package包/類
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));
    }
}
 
開發者ID:TangXiaoLv,項目名稱:Android-Router,代碼行數:16,代碼來源:ValueParser.java

示例2: constructArrayStep2

import java.lang.reflect.Array; //導入方法依賴的package包/類
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;
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:57,代碼來源:BaseConstructor.java

示例3: constructArrayStep2

import java.lang.reflect.Array; //導入方法依賴的package包/類
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;
}
 
開發者ID:RoccoDev,項目名稱:5zig-TIMV-Plugin,代碼行數:58,代碼來源:BaseConstructor.java

示例4: test

import java.lang.reflect.Array; //導入方法依賴的package包/類
public static double test(int i, double value) {
    Array.setDouble(array, i, value);
    return array[i];
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:Array_setDouble01.java


注:本文中的java.lang.reflect.Array.setDouble方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。