Detects the DataType of a particular value.

@param v
@return
506823
public static DataType getDataType(Object v) {
        //NOTE: DO NOT CHANGE THE ORDER OF THE IFS!!!
        if(DataType.BOOLEAN.isInstance(v)) {
            return DataType.BOOLEAN;
        }
        else if(DataType.ORDINAL.isInstance(v)) {
            return DataType.ORDINAL;
        }
        else if(DataType.NUMERICAL.isInstance(v)) {
            return DataType.NUMERICAL;
        }
        else if(DataType.CATEGORICAL.isInstance(v)) {
            return DataType.CATEGORICAL;
        }
        else {
            //We will reach this point ONLY if the value is null. 
            //This is because the last enum value in the loop is Categorical which uses the Object class.
            return null; 
        }
    }
1004934
public static boolean isTypeWrappedPrimitive(TypeName value) {
		return isTypeIncludedIn(value, Byte.class, Character.class, Boolean.class, Short.class, Integer.class,
				Long.class, Float.class, Double.class);
	}
1051534
public static String valueToString(Object v) {
        if (v.getClass().isArray()) {
            if (v.getClass().getComponentType().isPrimitive()) {
                Class<?> c = v.getClass().getComponentType();
                if (c == int.class) {
                    return Arrays.toString((int[]) v);
                } else if (c == double.class) {
                    return Arrays.toString((double[]) v);
                } else if (c == float.class) {
                    return Arrays.toString((float[]) v);
                } else if (c == long.class) {
                    return Arrays.toString((long[]) v);
                } else if (c == byte.class) {
                    return Arrays.toString((byte[]) v);
                } else if (c == short.class) {
                    return Arrays.toString((short[]) v);
                } else {
                    return v.toString();
                }
            } else {
                return Arrays.toString((Object[]) v);
            }
        } else {
            return v.toString();
        }
    }
1039067
private static boolean isNumericType(Class<?> c) {
    return Number.class.isAssignableFrom(c)
        || double.class == c
        || float.class == c
        || long.class == c
        || int.class == c
        || short.class == c
        || byte.class == c;
  }
340683
public Datatype.Visibility getValueTypeVisibility() {
    Preconditions.checkState(
        !_unsetProperties.contains(Property.VALUE_TYPE_VISIBILITY), "valueTypeVisibility not set");
    return valueTypeVisibility;
  }
1008758
function isTypedArray( v ) {
	var i;
	v = typeName( v );
	for ( i = 0; i < NAMES.length; i++ ) {
		if ( NAMES[ i ] === v ) {
			return true;
		}
	}
	return false;
}
849782
protected Datatype updateDtrDatatype(Datatype datatype) {
		// 
		assert (dtrMapInUse);

		// // QNameContext qncSchemaType = datatype.getSchemaType();
		// QNameContext qncBase = qncSchemaType.getSimpleBaseType();
		// assert(qncSchemaType != null);
		//
		//
		// // // special integer handling
		// // if (dtrDatatype.getBuiltInType() == BuiltInType.INTEGER
		// // && (datatype.getBuiltInType() == BuiltInType.NBIT_UNSIGNED_INTEGER
		// || datatype
		// // .getBuiltInType() == BuiltInType.UNSIGNED_INTEGER)) {
		// // dtrDatatype = datatype;
		// // }
		//
		// Datatype dt = dtrMap.get(qncBase.getQName());
		//
		// if (dt == null) {
		// // dt = updateDtrDatatype(simpleBaseType);
		// // dt = updateDtrDatatype(qncSchemaType.getSimpleBaseDatatype());
		// dt = updateDtrDatatype(qncBase); //baseDatatype);
		// // dtrMap.put(qncBase.getQName(), dt);
		// } else {
		// // save new mapping in map
		// // dtrMap.put(qncSchemaType.getQName(), dt);
		// }
		//
		// return dt;

		Datatype baseDatatype = datatype.getBaseDatatype();
		// QNameContext qncSchemaType = datatype.getSchemaType();
		// QNameContext simpleBaseType =
		// qncSchemaType.getSimpleBaseDatatype().getSchemaType();
		QNameContext simpleBaseType = baseDatatype.getSchemaType();

		Datatype dtrDatatype = dtrMap.get(simpleBaseType.getQName());

		if (dtrDatatype == null) {
			// dt = updateDtrDatatype(simpleBaseType);
			// dt = updateDtrDatatype(qncSchemaType.getSimpleBaseDatatype());
			dtrDatatype = updateDtrDatatype(baseDatatype);
		}

		// special integer handling
		if ((dtrDatatype.getBuiltInType() == BuiltInType.INTEGER || dtrDatatype
				.getBuiltInType() == BuiltInType.UNSIGNED_INTEGER)
				&& (datatype.getBuiltInType() == BuiltInType.NBIT_UNSIGNED_INTEGER || datatype
						.getBuiltInType() == BuiltInType.UNSIGNED_INTEGER)) {
			dtrDatatype = datatype;
		}

		// save new mapping in map
		dtrMap.put(datatype.getSchemaType().getQName(), dtrDatatype);

		return dtrDatatype;
	}
1182616
public static boolean checkValueIsType(Object value, Object name, Class type) {
        if (value != null) {
            if (type.isAssignableFrom(value.getClass())) {
                return true;
            } else {
                throw new RuntimeException("The value argument of '" + name + "' must be of type "
                        + type.getName() + ". Found: " + value.getClass());
            }
        } else {
            return false;
        }
    }
9514
public static int getTypeValForSqlType(SqlType sqlType) throws SQLException {
		int[] typeVals = typeToValMap.get(sqlType);
		if (typeVals == null) {
			throw new SQLException("SqlType is unknown to type val mapping: " + sqlType);
		}
		if (typeVals.length == 0) {
			throw new SQLException("SqlType does not have any JDBC type value mapping: " + sqlType);
		} else {
			return typeVals[0];
		}
	}
137882
private DataType readDataType() {
    String name = readWord();
    switch (name) {
      case "map":
        if (readChar() != '<') throw unexpected("expected '<'");
        DataType keyType = readDataType();
        if (readChar() != ',') throw unexpected("expected ','");
        DataType valueType = readDataType();
        if (readChar() != '>') throw unexpected("expected '>'");
        return MapType.create(keyType, valueType);
      case "any":
        return ScalarType.ANY;
      case "bool":
        return ScalarType.BOOL;
      case "bytes":
        return ScalarType.BYTES;
      case "double":
        return ScalarType.DOUBLE;
      case "float":
        return ScalarType.FLOAT;
      case "fixed32":
        return ScalarType.FIXED32;
      case "fixed64":
        return ScalarType.FIXED64;
      case "int32":
        return ScalarType.INT32;
      case "int64":
        return ScalarType.INT64;
      case "sfixed32":
        return ScalarType.SFIXED32;
      case "sfixed64":
        return ScalarType.SFIXED64;
      case "sint32":
        return ScalarType.SINT32;
      case "sint64":
        return ScalarType.SINT64;
      case "string":
        return ScalarType.STRING;
      case "uint32":
        return ScalarType.UINT32;
      case "uint64":
        return ScalarType.UINT64;
      default:
        return NamedType.create(name);
    }
  }
1314180
public static DataType typeFromTensorType(byte type, int elementSize) {
        if(type == Type.FloatingPoint) {
            return DataType.FLOAT;
        }
        else if(type == Type.Decimal) {
            return DataType.DOUBLE;
        }
        else if(type == Type.Int) {
            if(elementSize == 4) {
                return DataType.INT;
            }
            else if(elementSize == 8) {
                return DataType.LONG;
            }
        }
        else {
            throw new IllegalArgumentException("Only valid types are Type.Decimal and Type.Int");
        }

        throw new IllegalArgumentException("Unable to determine data type");
    }
971952
public static Integer isInteger(String value) {
		Validate.notNull(value);
		Validate.notEmpty(value);
		Integer intValue = null;
		try{
			intValue = 	Integer.parseInt(value);
		} catch(NumberFormatException e){
			throw new TypeException("Integer");
		}
		return intValue;
	}
1071527
public static int readVInt(DataInput in) throws IOException {
    long ret = readVLong(in);
    if ((ret > Integer.MAX_VALUE) || (ret < Integer.MIN_VALUE)) {
      throw new RuntimeException(
          "Number too large to be represented as Integer");
    }
    return (int) ret;
  }
235775
function getTypedArrayType( v ) {
	if (v instanceof Float32Array) {
		return NUMTYPE.FLOAT32;
	} else if (v instanceof Float64Array) {
		return NUMTYPE.FLOAT64;
	} else if (v instanceof Uint8Array) {
		return NUMTYPE.UINT8;
	} else if (v instanceof Int8Array) {
		return NUMTYPE.INT8;
	} else if (v instanceof Uint16Array) {
		return NUMTYPE.UINT16;
	} else if (v instanceof Int16Array) {
		return NUMTYPE.INT16;
	} else if (v instanceof Uint32Array) {
		return NUMTYPE.UINT32;
	} else if (v instanceof Int32Array) {
		return NUMTYPE.INT32;
	} else if (v instanceof Array) {

		// Sneaky but fast way to check if array is 100% numeric
		// by testing the first, last and middle elemnet

		var a=0,b=v.length-1,c=Math.floor((b-a)/2);
		if((typeof v[a] === "number") &&
		   (typeof v[b] === "number") &&
		   (typeof v[c] === "number")) {
		   	return NUMTYPE.NUMERIC;
		} else {
			return NUMTYPE.UNKNOWN;
		}

	} else {
		return NUMTYPE.UNKNOWN;
	}
}
1050809
private static boolean isVariableInteger(TokenList.Token t) {
        if( t == null )
            return false;

        return t.getScalarType() == VariableScalar.Type.INTEGER;
    }
74968
private void determineValueType(Object value){
		if (value instanceof Integer){
			this.valueEncoder.valueType = INTEGER;
			this.valueEncoder.valueBytes = ByteBuffer.allocate(4).putInt((Integer)value).array();
		}
		else if (value instanceof Long) {
			this.valueEncoder.valueType = LONG;
			this.valueEncoder.valueBytes = ByteBuffer.allocate(8).putLong((Long)value).array();
		}
		else if (value == null){
			this.valueEncoder.valueType = NULL;
		}
		else {
			ObjectOutputStream oos = null;
			try {
				ByteArrayOutputStream bos = new ByteArrayOutputStream();
				oos = new ObjectOutputStream(bos);
				oos.writeObject(value);
				this.valueEncoder.valueType = OBJECT;
				this.valueEncoder.valueBytes = bos.toByteArray();
			} catch (Exception e) {
				throw new IllegalStateException("Failed to serialize value: " + value, e);
			} finally {
				try {
					if (oos != null){
						oos.close();
					}
				} catch (Exception e2) {/*ignore*/}
			}
		}
	}
211799
static Boolean isValue(Object v) {
        return (v instanceof Map && ((Map<String, Object>) v).containsKey("@value"));
    }