+ builtinValues.put(Datatypes.DOUBLE, b.Double);
+ builtinValues.put(Datatypes.STRING, b.String);
+ builtinValues.put(Datatypes.INTEGER, b.Integer);
+ builtinValues.put(Datatypes.LONG, b.Long);
+ builtinValues.put(Datatypes.FLOAT, b.Float);
+ builtinValues.put(Datatypes.BYTE, b.Byte);
+ builtinValues.put(Datatypes.BOOLEAN, b.Boolean);
+ builtinValues.put(Datatypes.VARIANT, b.Variant);
+
+ builtinValues.put(Datatypes.DOUBLE_ARRAY, b.DoubleArray);
+ builtinValues.put(Datatypes.STRING_ARRAY, b.StringArray);
+ builtinValues.put(Datatypes.INTEGER_ARRAY, b.IntegerArray);
+ builtinValues.put(Datatypes.LONG_ARRAY, b.LongArray);
+ builtinValues.put(Datatypes.FLOAT_ARRAY, b.FloatArray);
+ builtinValues.put(Datatypes.BYTE_ARRAY, b.ByteArray);
+ builtinValues.put(Datatypes.BOOLEAN_ARRAY, b.BooleanArray);
+ builtinValues.put(Datatypes.VARIANT_ARRAY, b.VariantArray);
+ }
+
+ private static Datatype canonicalizeToBuiltinDatatype(Datatype datatype) {
+ if (datatype instanceof ArrayType) {
+ ArrayType at = (ArrayType) datatype;
+ datatype = at.componentType();
+ if (datatype instanceof ByteType) {
+ return Datatypes.BYTE_ARRAY;
+ } else if (datatype instanceof DoubleType) {
+ return Datatypes.DOUBLE_ARRAY;
+ } else if (datatype instanceof FloatType) {
+ return Datatypes.FLOAT_ARRAY;
+ } else if (datatype instanceof IntegerType) {
+ return Datatypes.INTEGER_ARRAY;
+ } else if (datatype instanceof LongType) {
+ return Datatypes.LONG_ARRAY;
+ } else if (datatype instanceof BooleanType) {
+ return Datatypes.BOOLEAN_ARRAY;
+ } else if (datatype instanceof StringType) {
+ return Datatypes.STRING_ARRAY;
+ } else if (datatype instanceof VariantType) {
+ return Datatypes.VARIANT_ARRAY;
+ }
+ return null;
+ }
+ if (datatype instanceof ByteType) {
+ return Datatypes.BYTE;
+ } else if (datatype instanceof DoubleType) {
+ return Datatypes.DOUBLE;
+ } else if (datatype instanceof FloatType) {
+ return Datatypes.FLOAT;
+ } else if (datatype instanceof IntegerType) {
+ return Datatypes.INTEGER;
+ } else if (datatype instanceof LongType) {
+ return Datatypes.LONG;
+ } else if (datatype instanceof BooleanType) {
+ return Datatypes.BOOLEAN;
+ } else if (datatype instanceof StringType) {
+ return Datatypes.STRING;
+ } else if (datatype instanceof VariantType) {
+ return Datatypes.VARIANT;
+ }
+ return null;
+ }
+
+ private Resource resolveBuiltinResourceType(Class<?> valueClass, Datatype datatype) {
+ Resource type = builtinValues.get(valueClass);
+ return type != null ? type : builtinValues.get(datatype);
+ }
+
+ private Resource resolveBuiltinResourceTypeByCanonicalizedDatatype(Datatype datatype, Resource defaultResult) {
+ Datatype cdt = canonicalizeToBuiltinDatatype(datatype);
+ return cdt != null ? builtinValues.get(cdt) : defaultResult;