All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avaje.ebeaninternal.server.persist.BindValues Maven / Gradle / Ivy

There is a newer version: 8.1.1
Show newest version
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 list = new ArrayList();

  /**
   * 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 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;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy