public Object transform()

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


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