Package rewards.internal

Source Code of rewards.internal.PercentageTypeHandler

package rewards.internal;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import common.money.Percentage;

public class PercentageTypeHandler implements TypeHandler {

  @Override
  public void setParameter(PreparedStatement ps, int i, Object parameter,
      JdbcType jdbcType) throws SQLException {
   
    double d = ((Percentage)parameter).asDouble();
    ps.setDouble(i, d);
  }

  @Override
  public Object getResult(ResultSet rs, String columnName)
      throws SQLException {
   
    double d = rs.getDouble(columnName);
        return new Percentage(d);
  }

  @Override
  public Object getResult(CallableStatement cs, int columnIndex)
      throws SQLException {
   
    double d = cs.getDouble(columnIndex);
        return new Percentage(d);
  }
 
    public Object valueOf(String s) {
      return Percentage.valueOf(s);
    }
}
TOP

Related Classes of rewards.internal.PercentageTypeHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.