mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
88 lines
1.8 KiB
Java
88 lines
1.8 KiB
Java
package com.avaje.ebeaninternal.server.persist;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* Holds a list of bind values for binding to a PreparedStatement.
|
|
*/
|
|
public class BindValues {
|
|
|
|
final ArrayList<Value> list = new ArrayList<Value>();
|
|
|
|
/**
|
|
* Create with a Binder.
|
|
*/
|
|
public BindValues(){
|
|
}
|
|
|
|
/**
|
|
* Return the number of bind values.
|
|
*/
|
|
public int size() {
|
|
return list.size();
|
|
}
|
|
|
|
/**
|
|
* Add a bind value with its JDBC datatype.
|
|
*
|
|
* @param value the bind value
|
|
* @param dbType the type as per java.sql.Types
|
|
*/
|
|
public void add(Object value, int dbType, String name){
|
|
list.add(new Value(value, dbType, name));
|
|
}
|
|
|
|
/**
|
|
* List of bind values.
|
|
*/
|
|
public ArrayList<Value> values() {
|
|
return list;
|
|
}
|
|
|
|
/**
|
|
* A Value has additionally the JDBC data type.
|
|
*/
|
|
public static class Value {
|
|
|
|
private final Object value;
|
|
|
|
private final int dbType;
|
|
|
|
private final String name;
|
|
|
|
/**
|
|
* Create the value.
|
|
*/
|
|
public Value(Object value, int dbType, String name) {
|
|
this.value = value;
|
|
this.dbType = dbType;
|
|
this.name = name;
|
|
}
|
|
|
|
/**
|
|
* Return the type as per java.sql.Types.
|
|
*/
|
|
public int getDbType() {
|
|
return dbType;
|
|
}
|
|
|
|
/**
|
|
* Return the value.
|
|
*/
|
|
public Object getValue() {
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* Return the property name.
|
|
*/
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public String toString(){
|
|
return ""+value;
|
|
}
|
|
}
|
|
}
|