public Object transform()

in src/main/java/com/aliyun/odps/jdbc/utils/transformer/to/jdbc/ToJdbcIntTransformer.java [44:74]


  public Object transform(Object o, String charset) throws SQLException {
    if (o == null) {
      return 0;
    }
    try {
      if (o instanceof Number) {
        return ((Number) o).intValue();
      } else if (o instanceof Boolean) {
        return (Boolean) o ? (Integer) 1 : (Integer) 0;
      } else if (o instanceof byte[]) {
        String str = encodeBytes((byte[]) o, charset);
        return Integer.parseInt(str);
      } else if (o instanceof String) {
        String str = (String) o;
        return Integer.parseInt(str);
      } else if (o instanceof AbstractChar) {
        return Integer.parseInt(((AbstractChar) o).getValue());
      } else if (o instanceof Binary) {
        String str = encodeBytes(((Binary) o).data(), charset);
        return Integer.parseInt(str);
      } else {
        String errorMsg = getInvalidTransformationErrorMsg(o.getClass(), Integer.class);
        throw new SQLException(errorMsg);
      }
    } catch (SQLException e) {
      throw e;
    } catch (Exception e) {
      String errorMsg = getTransformationErrMsg(Objects.toString(o), Integer.class, e.getMessage());
      throw new SQLException(errorMsg, e);
    }
  }