根据Field类型返回值

@param type
@param value

@return

@throws Exception
495151
public static Object getValeByType(Class<?> type, Object value)
            throws Exception {

        // 预处理
        if (!(value instanceof String)) {
            value = "";
        }

        // trim
        String dataValue = (String) value;
        dataValue = dataValue.trim();

        // process
        String typeName = type.getName();
        typeName = typeName.toLowerCase();

        if (typeName.equals("int") || typeName.equals("java.lang.integer")) {

            if (value.equals("")) {
                value = "0";
            }

            return Integer.valueOf(dataValue);

        } else if (typeName.equals("long") || typeName.equals("java.lang.long")) {

            if (value.equals("")) {
                value = "0";
            }

            return Long.valueOf(dataValue);

        } else if (typeName.equals("boolean")
                || typeName.equals("java.lang.boolean")) {

            if (value.equals("")) {
                value = "false";
            }

            return Boolean.valueOf(dataValue);

        } else if (typeName.equals("double")
                || typeName.equals("java.lang.double")) {

            if (value.equals("")) {
                value = "0.0";
            }

            return Double.valueOf(dataValue);

        } else {

            return value;
        }
    }
538831
private static void typeCheckFieldSet(Field field, Class<?> valueType, Object value) throws IllegalAccessException {
		if (!isPrimitive(valueType)) {
			//Call the version of this method that considers autoboxing
			typeCheckFieldSet(field, value);
		}
		else {
			//Value type is primitive.
			//  Note: In this case value was a primitive value that became boxed, so it can't be null.
			Class<?> fieldType = field.getType();
			if (!Utils.isConvertableFrom(fieldType, valueType)) {
				throw Exceptions.illegalSetFieldTypeException(field, valueType, value);
			}
		}
	}
446110
protected function createNodeByValueAndType($value, $type)
    {
        /*
         * URI
         */
        if ('uri' == $type) {
            return $this->nodeFactory->createNamedNode($value);

        /*
         * Any Pattern
         */
        } elseif ('var' == $type) {
            return $this->nodeFactory->createAnyPattern();

        /*
         * Typed Literal or Literal
         */
        } elseif ('typed-literal' == $type || 'literal' == $type) {
            return $this->nodeFactory->createLiteral($value);

        /*
         * Unknown type
         */
        } else {
            throw new \Exception('Unknown type given: '.$type);
        }
    }
1207734
public DiscriminatorJdbcSubBuilder when(String value, TypeReference<? extends T> type) {
        return when(value, type.getType());
    }
160882
public static final boolean valueIsNotDefault(FieldType type, Object value)
   {
      boolean result = true;

      if (value == null)
      {
         result = false;
      }
      else
      {
         DataType dataType = type.getDataType();
         switch (dataType)
         {
            case BOOLEAN:
            {
               result = ((Boolean) value).booleanValue();
               break;
            }

            case CURRENCY:
            case NUMERIC:
            {
               result = !NumberHelper.equals(((Number) value).doubleValue(), 0.0, 0.00001);
               break;
            }

            case DURATION:
            {
               result = (((Duration) value).getDuration() != 0);
               break;
            }

            default:
            {
               break;
            }
         }
      }

      return result;
   }
764057
private void retrieveTypeAndFillRecord(int pos, int type, Record record) throws SQLException,
			NotTransformableSQLFieldException {
		switch (type) {
		case java.sql.Types.NULL:
			record.setField(pos, NullValue.getInstance());
			break;
		case java.sql.Types.BOOLEAN:
			record.setField(pos, new BooleanValue(resultSet.getBoolean(pos + 1)));
			break;
		case java.sql.Types.BIT:
			record.setField(pos, new BooleanValue(resultSet.getBoolean(pos + 1)));
			break;
		case java.sql.Types.CHAR:
			record.setField(pos, new StringValue(resultSet.getString(pos + 1)));
			break;
		case java.sql.Types.NCHAR:
			record.setField(pos, new StringValue(resultSet.getString(pos + 1)));
			break;
		case java.sql.Types.VARCHAR:
			record.setField(pos, new StringValue(resultSet.getString(pos + 1)));
			break;
		case java.sql.Types.LONGVARCHAR:
			record.setField(pos, new StringValue(resultSet.getString(pos + 1)));
			break;
		case java.sql.Types.LONGNVARCHAR:
			record.setField(pos, new StringValue(resultSet.getString(pos + 1)));
			break;
		case java.sql.Types.TINYINT:
			record.setField(pos, new ShortValue(resultSet.getShort(pos + 1)));
			break;
		case java.sql.Types.SMALLINT:
			record.setField(pos, new ShortValue(resultSet.getShort(pos + 1)));
			break;
		case java.sql.Types.BIGINT:
			record.setField(pos, new LongValue(resultSet.getLong(pos + 1)));
			break;
		case java.sql.Types.INTEGER:
			record.setField(pos, new IntValue(resultSet.getInt(pos + 1)));
			break;
		case java.sql.Types.FLOAT:
			record.setField(pos, new DoubleValue(resultSet.getDouble(pos + 1)));
			break;
		case java.sql.Types.REAL:
			record.setField(pos, new FloatValue(resultSet.getFloat(pos + 1)));
			break;
		case java.sql.Types.DOUBLE:
			record.setField(pos, new DoubleValue(resultSet.getDouble(pos + 1)));
			break;
		case java.sql.Types.DECIMAL:
			record.setField(pos, new DoubleValue(resultSet.getBigDecimal(pos + 1).doubleValue()));
			break;
		case java.sql.Types.NUMERIC:
			record.setField(pos, new DoubleValue(resultSet.getBigDecimal(pos + 1).doubleValue()));
			break;
		case java.sql.Types.DATE:
			record.setField(pos, new StringValue(resultSet.getDate(pos + 1).toString()));
			break;
		case java.sql.Types.TIME:
			record.setField(pos, new LongValue(resultSet.getTime(pos + 1).getTime()));
			break;
		case java.sql.Types.TIMESTAMP:
			record.setField(pos, new StringValue(resultSet.getTimestamp(pos + 1).toString()));
			break;
		case java.sql.Types.SQLXML:
			record.setField(pos, new StringValue(resultSet.getSQLXML(pos + 1).toString()));
			break;
		default:
			throw new NotTransformableSQLFieldException("Unknown sql-type [" + type + "]on column [" + pos + "]");

			// case java.sql.Types.BINARY:
			// case java.sql.Types.VARBINARY:
			// case java.sql.Types.LONGVARBINARY:
			// case java.sql.Types.ARRAY:
			// case java.sql.Types.JAVA_OBJECT:
			// case java.sql.Types.BLOB:
			// case java.sql.Types.CLOB:
			// case java.sql.Types.NCLOB:
			// case java.sql.Types.DATALINK:
			// case java.sql.Types.DISTINCT:
			// case java.sql.Types.OTHER:
			// case java.sql.Types.REF:
			// case java.sql.Types.ROWID:
			// case java.sql.Types.STRUCT:
		}
	}
164139
public static Object convertExample(String value, String type) {
        if (value == null) {
            return null;
        }

        try {
            switch (type) {
                case "integer":
                    return Integer.valueOf(value);
                case "number":
                    return Float.valueOf(value);
                case "boolean":
                    return Boolean.valueOf(value);
                case "string":
                    return value;
                default:
                    return value;
            }
        } catch (NumberFormatException e) {
            throw new RuntimeException(String.format("Value '%s' cannot be converted to '%s'", value, type), e);
        }
    }
297619
public static void setField(Class<?> type, String fieldName, Object fieldValue) {
		setField(null, type, fieldName, fieldValue);
	}
915927
public <T> T convert(Object value, Class<T> type) {
		return converter.convert(value, type);
	}
563477
private void checkType(FieldType type, Field field) {
        Class<?> cls = field.getType();

        if (type == FieldType.OBJECT || type == FieldType.ENUM) {
            return;
        }

        String javaType = type.getJavaType();
        if (Integer.class.getSimpleName().equals(javaType)) {
            if (cls.getSimpleName().equals("int") || Integer.class.getSimpleName().equals(cls.getSimpleName())) {
                return;
            }
            throw new IllegalArgumentException(getMismatchTypeErroMessage(type, field));
        }
        if (!javaType.equalsIgnoreCase(cls.getSimpleName())) {
            throw new IllegalArgumentException(getMismatchTypeErroMessage(type, field));
        }
    }
1001043
public void saveField(DateTimeFieldType fieldType, int value) {
        obtainSaveField().init(fieldType.getField(iChrono), value);
    }
979822
public Object parse(String value, Class type)
    {
        if (StringUtil.isBlank(value))
        {
            return null;
        }

        return doConvert(value.trim(), type);
    }
874690
private String parseValue(String fieldType, Object value) {
		if (TypeConver.isBasicType(fieldType)) {
			if (value != null) {
				return value.toString();
			} else {
				return null;
			}
		}
		return null;
	}
266648
public void setObject(Class<?> type, Object value) {
		if (type.equals(String.class)) {
			this.setString((String) value);
		}
		else if (type.equals(Integer.class) || type.equals(int.class)) {
			this.setInt((Integer) value);
		}
		else if (type.equals(Long.class) || type.equals(long.class)) {
			this.setLong((Long) value);
		}
		else if (type.equals(Float.class) || type.equals(float.class)) {
			this.setFloat((Float) value);
		}
		else if (type.equals(Double.class) || type.equals(double.class)) {
			this.setDouble((Double) value);
		}
		else if (type.equals(Boolean.class) || type.equals(boolean.class)) {
			if (value instanceof Integer) {
				int num = (Integer) value;
				this.setBool(num == 1);
			}
			else {
				this.setBool((Boolean) value);
			}
		}
		// else if (type.equals(Month.class)) {
		// if (value instanceof String) {
		// String month = (String) value;
		// this.setMonth(new Month(month));
		// }
		// else {
		// this.setMonth((Month) value);
		// }
		// }
		else if (type.equals(Date.class)) {
			this.setDate((Date) value);
		}
		// else if (type.equals(OnlyDate.class)) {
		// if (value instanceof java.sql.Date) {
		// java.sql.Date date = (java.sql.Date) value;
		// this.setOnlyDate(new OnlyDate(date.getTime()));
		// }
		// else {
		// this.setOnlyDate((OnlyDate) value);
		// }
		// }
		else {
			throw new IllegalArgumentException("未知类型[" + type + "].");
		}
	}
664787
public static <T> T getField(Object obj, String string, Class<?> clazz, Class<T> fieldType) {
		try {
			final Field field = clazz.getDeclaredField(string);
			field.setAccessible(true);
			final Object value = field.get(obj);
			return fieldType.cast(value);
		} catch (Exception exception) {
			throw new Error(exception);
		}
	}
671230
public static boolean isInstance(final Object value, final Type type) {
        if (type == null) {
            return false;
        }

        return value == null ? !(type instanceof Class<?>) || !((Class<?>) type).isPrimitive()
                : isAssignable(value.getClass(), type, null);
    }
421802
void setFieldValue(final Object containingObj, final Object value) {
        try {
            if (value == null) {
                if (primitiveType != PrimitiveType.NON_PRIMITIVE) {
                    throw new IllegalArgumentException("Tried to set primitive-typed field "
                            + field.getDeclaringClass().getName() + "." + field.getName() + " to null value");
                }
                field.set(containingObj, null);
                return;
            }
            switch (primitiveType) {
            case NON_PRIMITIVE:
                field.set(containingObj, value);
                break;
            case INTEGER:
                if (!(value instanceof Integer)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Integer; got " + value.getClass().getName());
                }
                field.setInt(containingObj, (Integer) value);
                break;
            case LONG:
                if (!(value instanceof Long)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Long; got " + value.getClass().getName());
                }
                field.setLong(containingObj, (Long) value);
                break;
            case SHORT:
                if (!(value instanceof Short)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Short; got " + value.getClass().getName());
                }
                field.setShort(containingObj, (Short) value);
                break;
            case DOUBLE:
                if (!(value instanceof Double)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Double; got " + value.getClass().getName());
                }
                field.setDouble(containingObj, (Double) value);
                break;
            case FLOAT:
                if (!(value instanceof Float)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Float; got " + value.getClass().getName());
                }
                field.setFloat(containingObj, (Float) value);
                break;
            case BOOLEAN:
                if (!(value instanceof Boolean)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Boolean; got " + value.getClass().getName());
                }
                field.setBoolean(containingObj, (Boolean) value);
                break;
            case BYTE:
                if (!(value instanceof Byte)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Byte; got " + value.getClass().getName());
                }
                field.setByte(containingObj, (Byte) value);
                break;
            case CHARACTER:
                if (!(value instanceof Character)) {
                    throw new IllegalArgumentException(
                            "Expected value of type Character; got " + value.getClass().getName());
                }
                field.setChar(containingObj, (Character) value);
                break;
            default:
                throw new IllegalArgumentException();
            }
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new IllegalArgumentException(
                    "Could not set field " + field.getDeclaringClass().getName() + "." + field.getName(), e);
        }
    }