com.j256.ormlite.stmt
Class SelectArg

java.lang.Object
  extended by com.j256.ormlite.stmt.BaseArgumentHolder
      extended by com.j256.ormlite.stmt.SelectArg
All Implemented Interfaces:
ArgumentHolder

public class SelectArg
extends BaseArgumentHolder
implements ArgumentHolder

An argument to a select SQL statement. After the query is constructed, the caller can set the value on this argument and run the query. Then the argument can be set again and the query re-executed. This is equivalent in SQL to a ? argument.

NOTE: If the argument has not been set by the time the query is executed, an exception will be thrown.

NOTE: For protections sake, the object cannot be reused with different column names.

Author:
graywatson

Constructor Summary
SelectArg()
          Constructor for when the value will be set later with setValue(Object).
SelectArg(Object value)
          Constructor for when the value is known at time of construction.
SelectArg(SqlType sqlType)
          This constructor is only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.
SelectArg(SqlType sqlType, Object value)
          This constructor is only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.
SelectArg(String columnName, Object value)
          This constructor is only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.
 
Method Summary
protected  Object getValue()
          Return the stored value.
protected  boolean isValueSet()
          Return true if the value is set.
 void setValue(Object value)
          Set the value associated with this argument.
 
Methods inherited from class com.j256.ormlite.stmt.BaseArgumentHolder
getColumnName, getFieldType, getSqlArgValue, getSqlType, setMetaInfo, setMetaInfo, setMetaInfo, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.j256.ormlite.stmt.ArgumentHolder
getColumnName, getFieldType, getSqlArgValue, getSqlType, setMetaInfo, setMetaInfo, setMetaInfo
 

Constructor Detail

SelectArg

public SelectArg()
Constructor for when the value will be set later with setValue(Object).


SelectArg

public SelectArg(String columnName,
                 Object value)
This constructor is only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.

Parameters:
columnName - Name of the column this argument corresponds to.
value - Value for the select-arg if know at time of construction. Otherwise call setValue(Object) later.

SelectArg

public SelectArg(SqlType sqlType,
                 Object value)
This constructor is only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.

Parameters:
sqlType - Type of the column that this argument corresponds to. Only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.
value - Value for the select-arg if know at time of construction. Otherwise call setValue(Object) later.

SelectArg

public SelectArg(SqlType sqlType)
This constructor is only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.

Parameters:
sqlType - Type of the column that this argument corresponds to. Only necessary if you are using the Where.raw(String, ArgumentHolder...) and similar methods.

SelectArg

public SelectArg(Object value)
Constructor for when the value is known at time of construction. You can instead use the SelectArg() empty constructor and set the value later with setValue(Object).

WARNING, This constructor sets the _value_ not the column-name. To set the column-name only, use the SelectArg(String, Object) and pass a null as the value.

Method Detail

getValue

protected Object getValue()
Description copied from class: BaseArgumentHolder
Return the stored value.

Specified by:
getValue in class BaseArgumentHolder

setValue

public void setValue(Object value)
Description copied from interface: ArgumentHolder
Set the value associated with this argument. The value should be set by the user after the query has been built but before it has been executed.

Specified by:
setValue in interface ArgumentHolder
Specified by:
setValue in class BaseArgumentHolder

isValueSet

protected boolean isValueSet()
Description copied from class: BaseArgumentHolder
Return true if the value is set.

Specified by:
isValueSet in class BaseArgumentHolder


This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.