当前位置: 首页>>代码示例>>Java>>正文


Java Array.set方法代码示例

本文整理汇总了Java中java.lang.reflect.Array.set方法的典型用法代码示例。如果您正苦于以下问题:Java Array.set方法的具体用法?Java Array.set怎么用?Java Array.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Array的用法示例。


在下文中一共展示了Array.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import java.lang.reflect.Array; //导入方法依赖的package包/类
public Object read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }

  List<E> list = new ArrayList<E>();
  in.beginArray();
  while (in.hasNext()) {
    E instance = componentTypeAdapter.read(in);
    list.add(instance);
  }
  in.endArray();
  Object array = Array.newInstance(componentType, list.size());
  for (int i = 0; i < list.size(); i++) {
    Array.set(array, i, list.get(i));
  }
  return array;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ArrayTypeAdapter.java

示例2: convertArgs

import java.lang.reflect.Array; //导入方法依赖的package包/类
private static Object[] convertArgs (Member function, Class<?>[] formals, Object[] actuals) {
    Object[] results = actuals;
    if (isVarArgs(function)) {
        results = new Object[formals.length];
        int idx = 0;
        for (; idx < formals.length - 1; idx++) {
            // simply copy the basic parameters
            results[idx] = actuals[idx];
        }
        Class<?> type = formals[idx].getComponentType();
        Object varArgs = Array.newInstance(type, actuals.length - formals.length + 1);
        for (; idx < actuals.length; idx++) {
            // fill the varArg array with the remaining parameters
            Array.set(varArgs, idx - formals.length + 1, actuals[idx]);
        }
        results[results.length - 1] = varArgs;
    }
    return results;
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:20,代码来源:Reflection.java

示例3: a

import java.lang.reflect.Array; //导入方法依赖的package包/类
public final Object a(com.google.gson.jpush.b.a aVar) {
    if (aVar.f() == c.i) {
        aVar.j();
        return null;
    }
    List arrayList = new ArrayList();
    aVar.a();
    while (aVar.e()) {
        arrayList.add(this.c.a(aVar));
    }
    aVar.b();
    Object newInstance = Array.newInstance(this.b, arrayList.size());
    for (int i = 0; i < arrayList.size(); i++) {
        Array.set(newInstance, i, arrayList.get(i));
    }
    return newInstance;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:a.java

示例4: read

import java.lang.reflect.Array; //导入方法依赖的package包/类
@Override
public void read(JsonReader in, GsonProperty property, Object t) throws IOException {
    final Class<?> simpleType = property.getType();

    List list = new ArrayList();
    in.beginArray();
    if (simpleType.isPrimitive() || isBoxedClass(simpleType)) {
        while (in.hasNext()){
            list.add(SupportUtils.readPrimitiveOrItsBox(in, property));
        }
    }else{
        TypeAdapter adapter = getTypeAdapter(simpleType);
        while (in.hasNext()){
            list.add(adapter.read(in));
        }
    }
    //copy to array
    Object array = Array.newInstance(simpleType, list.size());
    for(int i = 0, size = list.size() ; i < size ; i ++){
        Array.set(array, i, list.get(i));
    }
    setValue(property, t, array);
    in.endArray();
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:25,代码来源:TypeHandler.java

示例5: isValidParameter

import java.lang.reflect.Array; //导入方法依赖的package包/类
static boolean isValidParameter(Method m, Object value, int paramNo) {
    Class<?> c = m.getParameterTypes()[paramNo];
    try {
        // Following is expensive but we only call this method to determine
        // if an exception is due to an incompatible parameter type.
        // Plain old c.isInstance doesn't work for primitive types.
        Object a = Array.newInstance(c, 1);
        Array.set(a, 0, value);
        return true;
    } catch (IllegalArgumentException e) {
        return false;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:MBeanIntrospector.java

示例6: setValue

import java.lang.reflect.Array; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setValue(Object object, Object value) {
    if (map != null) {
        map.put(key, value);
        return;
    }
    
    if (collection != null) {
        collection.add(value);
        return;
    }
    
    list.set(index, value);

    if (list instanceof JSONArray) {
        JSONArray jsonArray = (JSONArray) list;
        Object array = jsonArray.getRelatedArray();

        if (array != null) {
            int arrayLength = Array.getLength(array);

            if (arrayLength > index) {
                Object item;
                if (jsonArray.getComponentType() != null) {
                    item = TypeUtils.cast(value, jsonArray.getComponentType(), parser.getConfig());
                } else {
                    item = value;
                }
                Array.set(array, index, item);
            }
        }
    }
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:34,代码来源:ResolveFieldDeserializer.java

示例7: setTextCursorDrawable

import java.lang.reflect.Array; //导入方法依赖的package包/类
private void setTextCursorDrawable() {
    try {
        Method method = TextView.class.getDeclaredMethod("createEditorIfNeeded");
        method.setAccessible(true);
        method.invoke(this);
        Field field1 = TextView.class.getDeclaredField("mEditor");
        Field field2 = Class.forName("android.widget.Editor").getDeclaredField("mCursorDrawable");
        field1.setAccessible(true);
        field2.setAccessible(true);
        Object arr = field2.get(field1.get(this));
        Array.set(arr, 0, new LineSpaceCursorDrawable(getCursorColor(), getCursorWidth(), getCursorHeight()));
        Array.set(arr, 1, new LineSpaceCursorDrawable(getCursorColor(), getCursorWidth(), getCursorHeight()));
    } catch (Exception ignored) {
    }
}
 
开发者ID:hanks-zyh,项目名称:LineHeightEditText,代码行数:16,代码来源:LineHeightEditText.java

示例8: newValue

import java.lang.reflect.Array; //导入方法依赖的package包/类
private Object newValue(Class<?> type, String name) {
	try {
		if (type.isArray()) {
			Class<?> componentType = type.getComponentType();
			// TODO - only handles 2-dimensional arrays
			if (componentType.isArray()) {
				Object array = Array.newInstance(componentType, 1);
				Array.set(array, 0, Array.newInstance(componentType.getComponentType(), 0));
				return array;
			}
			else {
				return Array.newInstance(componentType, 0);
			}
		}
		else if (Collection.class.isAssignableFrom(type)) {
			return CollectionFactory.createCollection(type, 16);
		}
		else if (Map.class.isAssignableFrom(type)) {
			return CollectionFactory.createMap(type, 16);
		}
		else {
			return type.newInstance();
		}
	}
	catch (Exception ex) {
		// TODO Root cause exception context is lost here... should we throw another exception type that preserves context instead?
		throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + name,
				"Could not instantiate property type [" + type.getName() + "] to auto-grow nested property path: " + ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:BeanWrapperImpl.java

示例9: combineArray

import java.lang.reflect.Array; //导入方法依赖的package包/类
private static Object combineArray(Object firstArray, Object secondArray) {
    Class<?> localClass = firstArray.getClass().getComponentType();
    int firstArrayLength = Array.getLength(firstArray);
    int allLength = firstArrayLength + Array.getLength(secondArray);
    Object result = Array.newInstance(localClass, allLength);
    for (int k = 0; k < allLength; ++k) {
        if (k < firstArrayLength) {
            Array.set(result, k, Array.get(firstArray, k));
        } else {
            Array.set(result, k, Array.get(secondArray, k - firstArrayLength));
        }
    }
    return result;
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:15,代码来源:DexUtil.java

示例10: getProperty

import java.lang.reflect.Array; //导入方法依赖的package包/类
protected synchronized Object getProperty(String property, Class<?> clazz)
{
    Object o;

    try
    {
        o = getPropertySpi(property, clazz);
        if (o == null)
        {
            o = zero(clazz);
        }
        else if (clazz.isArray() && (o instanceof String[]) && !clazz.equals(String[].class))
        {
            String[] str = (String[]) o;

            o = Array.newInstance(clazz.getComponentType(), str.length);
            for (int i = 0; i < str.length; i++)
            {
                Array.set(o, i, parse(str[i], clazz.getComponentType()));
            }
        }
        else if ((o instanceof String) && !clazz.equals(String.class))
        {
            o = parse((String) o, clazz);
        }
    }
    catch (Exception x)
    {
        o = zero(clazz);
    }

    return o;
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:34,代码来源:AbstractBeanInvocationHandler.java

示例11: doCopyArray

import java.lang.reflect.Array; //导入方法依赖的package包/类
private Object doCopyArray(Object array,Class baseInterface) throws Exception {
    Class elementClass = array.getClass().getComponentType();
    int length = Array.getLength(array);
    Object newArray = Array.newInstance(elementClass,length);
    for (int i=0;i<length;i++) {
        Object element = doCopy(Array.get(array,i),baseInterface);
        Array.set(newArray,i,element);
    }
    return newArray;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:11,代码来源:CopyFromHelper.java

示例12: rehydrateInstance

import java.lang.reflect.Array; //导入方法依赖的package包/类
@Override
public Object rehydrateInstance(Instance ii) {
    ObjectArrayInstance oai = (ObjectArrayInstance) ii;
    int len = oai.getLength();
    Object a = Array.newInstance(ctype, len);
    rehydrationCache.put(ii.getInstanceId(), a);
    List<Instance> values = oai.getValues();
    for(int i = 0; i != len; ++i) {
        Array.set(a, i, rehydrate(values.get(i)));
    }
    return a;
}
 
开发者ID:aragozin,项目名称:heapunit,代码行数:13,代码来源:SimpleHeapImage.java

示例13: 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

示例14: setValue

import java.lang.reflect.Array; //导入方法依赖的package包/类
@Override
public void setValue(Object obj, Object value, Map<String, Object> args, InstanceFactory instanceFactory) {
	Object array = obj;
	if (INTERNAL_NODE != null) {
		array = INTERNAL_NODE.getValue(obj, args);
		if (array == null) {
			Class<?> nodeClass = INTERNAL_NODE.getNodeClass(obj, args);
			array = instanceFactory.getInstance(nodeClass, args);
			INTERNAL_NODE.setValue(obj, array, args);
		}
	}
	if (array != null) {
		Array.set(array, INDEX, value);
	}
}
 
开发者ID:InfinityRefactoring,项目名称:8R-Reflections,代码行数:16,代码来源:ArrayNode.java

示例15: endRead

import java.lang.reflect.Array; //导入方法依赖的package包/类
public boolean endRead() {
	setInitialized();
	array = Array.newInstance( elementClass, tempList.size() );
	for ( int i=0; i<tempList.size(); i++) {
		Array.set(array, i, tempList.get(i) );
	}
	tempList=null;
	return true;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:ArrayHolder.java


注:本文中的java.lang.reflect.Array.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。