convert a primitive array (value type) to Object Array (reference type).

@param primArr value type Array
@return reference type Array
181624
public static Character[] toReferenceType(char[] primArr) {
	Character[] refArr = new Character[primArr.length];
	for (int i = 0; i < primArr.length; i++)
	    refArr[i] = new Character(primArr[i]);
	return refArr;
    }
2877
public static double[][] convertFrontToArray(Front front) {
    if (front == null) {
      throw new NullFrontException();
    }

    double[][] arrayFront = new double[front.getNumberOfPoints()][] ;

    for (int i = 0; i < front.getNumberOfPoints(); i++) {
      arrayFront[i] = new double[front.getPoint(i).getDimension()] ;
      for (int j = 0 ; j < front.getPoint(i).getDimension(); j++) {
        arrayFront[i][j] = front.getPoint(i).getValue(j) ;
      }
    }

    return arrayFront ;
  }
1292520
public static Object toWrapperArray(Object array) {
    if (!array.getClass().isArray()) {
      throw new IllegalArgumentException("Must give array object.");
    }
    if (isPrimitiveArray(array.getClass())) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapper(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapper(Array.get(array, i)));
      }
      return newArray;
    } else if (array.getClass().getComponentType().isArray()) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapperArray(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapperArray(Array.get(array, i)));
      }
      return newArray;
    }
    return array;
  }
168825
private Class mapPrimitive(Class clazz) {
		if (clazz == Integer.TYPE) {
			return Integer.class;
		}
		if (clazz == Double.TYPE) {
			return Double.class;
		}
		if (clazz == Float.TYPE) {
			return Float.class;
		}
		if (clazz == Boolean.TYPE) {
			return Boolean.class;
		}
		if (clazz == Long.TYPE) {
			return Long.class;
		}
		
		throw new RuntimeException("Unsupported primitive: "+clazz);
	}
289115
public static boolean isPrimitiveArray(Class<?> type) {
        logger.entering(type);
        checkArgument(type != null, "Type cannot be null.");
        logger.exiting(PRIMITIVE_ARRAY_TYPES.contains(type));
        return PRIMITIVE_ARRAY_TYPES.contains(type);
    }
733491
public static Class convertPrimitiveToWrapper(Class clazz) {
		if (clazz == null || !clazz.isPrimitive())
			return clazz;

		return (Class) primativeToWrapperMap.get(clazz);
	}
524885
protected Object convertNullValue(Class type) throws ConversionException {
        try {
            return type.isPrimitive() ? Array.get(Array.newInstance(type, 1), 0) : null;
        } catch (Exception e) {
            throw new ConversionException(String.format("Could not convert null to primitive type <%s>", type), e);
        }
    }
739900
public static boolean isArray(TypeRef type) {

        if (type instanceof ClassRef) {
            return ((ClassRef)type).getDimensions() > 0;
        } else if (type instanceof PrimitiveRef) {
            return ((PrimitiveRef)type).getDimensions() > 0;
        } else if (type instanceof TypeParamRef) {
            return ((TypeParamRef)type).getDimensions() > 0;
        } else {
            return false;
        }
    }
681107
private ArrayList<Object> parseArray(JsonParser jp) throws IOException {
        JsonToken value = jp.nextToken();
        ArrayList<Object> ret = new ArrayList<>();
        while(value != JsonToken.END_ARRAY) {
            if (value == JsonToken.START_OBJECT) {
                Object object = parseObject(jp);
                ret.add(object);
            } else if (value == JsonToken.START_ARRAY) {
                ArrayList<Object> arrayList = parseArray(jp);
                ret.add(arrayList.toArray());
            } else if (value == JsonToken.VALUE_NUMBER_INT) {
                ret.add(jp.getValueAsInt());
            } else if (value == JsonToken.VALUE_FALSE || value == JsonToken.VALUE_TRUE) {
                ret.add(jp.getValueAsBoolean());
            } else if (value == JsonToken.VALUE_NUMBER_FLOAT) {
                ret.add(jp.getValueAsDouble());
            } else if (value == JsonToken.VALUE_STRING) {
                ret.add(jp.getValueAsString());
            } else if (value == JsonToken.VALUE_NULL) {
                ret.add("null");
            }
            value = jp.nextToken();
        }
        return ret;
    }
1204736
def p_const_value_primitive(self, p):
        ''''''
        p[0] = ast.ConstPrimitiveValue(p[1], lineno=p.lineno(1))
781478
public static final SerIterable array(final Class<?> valueType) {
        final List<Object> list = new ArrayList<>();
        return new SerIterable() {
            @Override
            public SerIterator iterator() {
                return array(build(), Object.class, valueType);
            }
            @Override
            public void add(Object key, Object column, Object value, int count) {
                if (key != null) {
                    throw new IllegalArgumentException("Unexpected key");
                }
                if (count != 1) {
                    throw new IllegalArgumentException("Unexpected count");
                }
                for (int i = 0; i < count; i++) {
                    list.add(value);
                }
            }
            @Override
            public Object[] build() {
                Object[] array = (Object[]) Array.newInstance(valueType, list.size());
                return list.toArray(array);
            }
            @Override
            public Class<?> valueType() {
                return valueType;
            }
            @Override
            public List<Class<?>> valueTypeTypes() {
                return EMPTY_VALUE_TYPES;
            }
        };
    }
1183326
public Type getTypeOfArrayItems()
      throws DataConversionException {
    JsonSchema arrayValues = getItemsWithinDataType();
    if (arrayValues == null) {
      throw new DataConversionException("Array types only allow values as primitive, null or JsonObject");
    }
    return arrayValues.getType();
  }
444745
public static Boolean[] toReferenceType(boolean[] primArr) {
	Boolean[] refArr = new Boolean[primArr.length];
	for (int i = 0; i < primArr.length; i++)
	    refArr[i] = Caster.toBoolean(primArr[i]);
	return refArr;
    }
1288031
private Object convertListToArray(List<?> rawValues, ExtendedAttributeDefinition attrDef, EvaluationContext context, boolean ignoreWarnings) throws ConfigEvaluatorException {
        // The implementation of this method is similar to convertListToVector,
        // but this method needs to handle primitive array types.  This could
        // be implemented by calling convertListToVector first, but that would
        // require boxing/unboxing the primitive values.  To avoid that, the
        // logic from the convertListToVector and convertObjectToSingleValue
        // methods is inlined for the primitive array types.

        int size = rawValues.size();
        int type = attrDef.getType();
        int i = 0;
        if (type == AttributeDefinition.BOOLEAN) {
            boolean[] retVal = new boolean[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Boolean.parseBoolean(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.BYTE) {
            byte[] retVal = new byte[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Byte.parseByte(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.CHARACTER) {
            char[] retVal = new char[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = value.charAt(0);
            }
            return retVal;
        } else if (type == AttributeDefinition.DOUBLE) {
            double[] retVal = new double[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Double.parseDouble(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.FLOAT) {
            float[] retVal = new float[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Float.parseFloat(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.INTEGER) {
            int[] retVal = new int[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Integer.parseInt(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.LONG) {
            long[] retVal = new long[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Long.parseLong(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.SHORT) {
            short[] retVal = new short[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Short.parseShort(value);
            }
            return retVal;
        } else if (type == MetaTypeFactory.DURATION_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MILLISECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_S_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.SECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_M_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MINUTES, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_H_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.HOURS, ignoreWarnings);
        } else {
            // STRING, PID_TYPE, TOKEN_TYPE, and all other unknown/invalid types.
            return convertListToStringArray(rawValues, attrDef, context, ignoreWarnings);
        }
    }
345186
@ReplacedBy("com.google.common.collect.Iterables#toArray()")
    public static <T> T[] toArray (Collection<? extends T> col, Class<T> type)
    {
        @SuppressWarnings("unchecked")
        T[] array = (T[]) Array.newInstance(type, col.size());
        return col.toArray(array);
    }
757311
private static String readArrayProperty(String ref, TypeDef source, Property property) {
        TypeRef typeRef = property.getTypeRef();
        if (typeRef instanceof ClassRef) {
            //TODO: This needs further breakdown, to cover edge cases.
            return readObjectArrayProperty(ref, source, property);
        }

        if (typeRef instanceof PrimitiveRef) {
            return readPrimitiveArrayProperty(ref, source, property);
        }
        throw new IllegalStateException("Property should be either an object or a primitive.");
    }
606517
public static final SerIterator array(
            final Object[] array, final Class<?> declaredType, final Class<?> valueType) {
        return new SerIterator() {
            private int index = -1;

            @Override
            public String metaTypeName() {
                return metaTypeNameBase(valueType);
            }
            private String metaTypeNameBase(Class<?> arrayType) {
                if (arrayType.isArray()) {
                    return metaTypeNameBase(arrayType.getComponentType()) + "[]";
                }
                if (arrayType == Object.class) {
                    return "Object[]";
                }
                if (arrayType == String.class) {
                    return "String[]";
                }
                return arrayType.getName() + "[]";
            }
            @Override
            public boolean metaTypeRequired() {
                if (valueType == Object.class) {
                    return Object[].class.isAssignableFrom(declaredType) == false;
                }
                if (valueType == String.class) {
                    return String[].class.isAssignableFrom(declaredType) == false;
                }
                return true;
            }
            @Override
            public int size() {
                return array.length;
            }
            @Override
            public boolean hasNext() {
                return (index + 1) < array.length;
            }
            @Override
            public void next() {
                index++;
            }
            @Override
            public Class<?> valueType() {
                return valueType;
            }
            @Override
            public List<Class<?>> valueTypeTypes() {
                return Collections.emptyList();
            }
            @Override
            public Object value() {
                return array[index];
            }
        };
    }