protected Object[] createArray(int length) { if (_componentType != null) return (Object[]) Array.newInstance(_componentType, length); else return new Object[length]; }
private Object convertDataArrayToTargetArray(Object[] array, Class<?> targetClass) throws NoSuchMethodException { Class<?> targetType = targetClass.getComponentType(); Method fromMethod = targetType.getMethod("from", array.getClass().getComponentType()); Object resultArray = Array.newInstance(targetType, array.length); for (int i = 0; i < array.length; i++) { Array.set(resultArray, i, ReflectionUtils.invokeMethod(fromMethod, null, array[i])); } return resultArray; }
@SuppressWarnings("unchecked") @Override public OUT[] extract(Object in) { OUT[] output = (OUT[]) Array.newInstance(clazz, order.length); for (int i = 0; i < order.length; i++) { output[i] = (OUT) Array.get(in, this.order[i]); } return output; }
/** Returns the length of the supplied array. */ static public int getLength (Object array) { return java.lang.reflect.Array.getLength(array); }
private Object growArrayIfNecessary(Object array, int index, String name) { if (!isAutoGrowNestedPaths()) { return array; } int length = Array.getLength(array); if (index >= length && index < this.autoGrowCollectionLimit) { Class<?> componentType = array.getClass().getComponentType(); Object newArray = Array.newInstance(componentType, index + 1); System.arraycopy(array, 0, newArray, 0, length); for (int i = length; i < Array.getLength(newArray); i++) { Array.set(newArray, i, newValue(componentType, null, name)); } setPropertyValue(name, newArray); Object defaultValue = getPropertyValue(name); Assert.state(defaultValue != null, "Default value must not be null"); return defaultValue; } else { return array; } }
/** Returns the value of the indexed component in the supplied array. */ static public Object get (Object array, int index) { return java.lang.reflect.Array.get(array, index); }
/** Sets the value of the indexed component in the supplied array to the supplied value. */ static public void set (Object array, int index, Object value) { java.lang.reflect.Array.set(array, index, value); }
/** Returns the length of the supplied array. */ static public int getLength (Object array) { return java.lang.reflect.Array.getLength(array); }
/** Returns the value of the indexed component in the supplied array. */ static public Object get (Object array, int index) { return java.lang.reflect.Array.get(array, index); }
/** Sets the value of the indexed component in the supplied array to the supplied value. */ static public void set (Object array, int index, Object value) { java.lang.reflect.Array.set(array, index, value); }
/** Creates a new array with the specified component type and length. */ static public Object newInstance (Class c, int size) { return java.lang.reflect.Array.newInstance(c, size); }
@SuppressWarnings( "unchecked" ) public RECORD[] newBatchObject( int batchSize ) { Object array = Array.newInstance( klass, batchSize ); for ( int i = 0; i < batchSize; i++ ) { Array.set( array, i, factory.get() ); } return (RECORD[]) array; }
public Object next() { return Array.get(value, currentIndex++); }
@Override public T set(T record, F fieldValue) { Array.set(record, pos, fieldValue); return record; } }
/** Creates a new array with the specified component type and length. */ static public Object newInstance (Class c, int size) { return java.lang.reflect.Array.newInstance(c, size); }
/** * For each element in the managed array, resolve reference if necessary. */ private Object resolveManagedArray(Object argName, List<?> ml, Class<?> elementType) { Object resolved = Array.newInstance(elementType, ml.size()); for (int i = 0; i < ml.size(); i++) { Array.set(resolved, i, resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i))); } return resolved; }