net.wgen.op.db
Class Parameter

java.lang.Object
  extended bynet.wgen.op.db.Parameter
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ArrayParameter, SQLDataParameter

public class Parameter
extends java.lang.Object
implements java.io.Serializable

The encapsulation of Parameters to a DatabaseCall.

Version:
$Id: Parameter.html,v 1.2 2007/01/28 04:09:36 paulfeuer Exp $
Author:
Paul Feuer, Wireless Generation, Inc.
See Also:
Serialized Form

Field Summary
private  int _direction
          This parameter's direction IN, OUT, or INOUT.
private  int _jdbcType
          This parameter's jdbcType or TYPE_NOT_SET if it doesn't know its type.
private  java.util.Map _options
          Options for this parameter, which can be interpreted by the underlying execution framework.
private  java.lang.Object _value
          This parameter's value which could be set on the way in or on the way out.
private static java.util.Map CLASS_TO_JDBC_TYPE
          Mapping of common classes of input values to their JdbcTypes.
static int DIR_IN
          Identifies an input parameter.
static int DIR_INOUT
          Identifies a parameter that is both an input and an output parameter.
static int DIR_OUT
          Identifies an output parameter.
static int TYPE_NOT_SET
          The identifying jdbcType value when it has not been set.
 
Constructor Summary
Parameter(int jdbcType)
          Constructor for an implicit Out Parameter.
Parameter(java.lang.Object value)
          Constructor for an implicit In Parameter.
Parameter(java.lang.Object value, int jdbcType, int direction)
          Full constructor.
 
Method Summary
 int getDirection()
           
 int getJdbcType()
           
 java.util.Map getOptions()
          Options for handling the values for this parameter.
 java.lang.Object getValue()
          The input or output value.
static Parameter nullableNumeric(java.lang.Number value)
          A numeric input Parameter.
static Parameter nullableNumeric(java.lang.Number value, int direction)
          A numeric Parameter with direction.
static Parameter nullableString(java.lang.String value)
          A string input parameter.
static Parameter nullableString(java.lang.String value, int direction)
          A String Parameter with direction.
 void setOptions(java.util.Map options)
           
 void setValue(java.lang.Object value)
          The input or output value.
 java.lang.String toString()
           
private static int tryToLookupType(java.lang.Object value)
          Some common classes have JDBC types associated with them that we know about.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_TO_JDBC_TYPE

private static final java.util.Map CLASS_TO_JDBC_TYPE
Mapping of common classes of input values to their JdbcTypes. If a mapping is not found for an input value's class, the value is set in the Statement using the typeless setObject() method.


DIR_IN

public static final int DIR_IN
Identifies an input parameter.

See Also:
Constant Field Values

DIR_OUT

public static final int DIR_OUT
Identifies an output parameter.

See Also:
Constant Field Values

DIR_INOUT

public static final int DIR_INOUT
Identifies a parameter that is both an input and an output parameter.

See Also:
Constant Field Values

TYPE_NOT_SET

public static final int TYPE_NOT_SET
The identifying jdbcType value when it has not been set.

See Also:
Constant Field Values

_direction

private final int _direction
This parameter's direction IN, OUT, or INOUT.


_jdbcType

private final int _jdbcType
This parameter's jdbcType or TYPE_NOT_SET if it doesn't know its type.


_value

private java.lang.Object _value
This parameter's value which could be set on the way in or on the way out.


_options

private java.util.Map _options
Options for this parameter, which can be interpreted by the underlying execution framework.

Constructor Detail

Parameter

public Parameter(java.lang.Object value)
Constructor for an implicit In Parameter.

Parameters:
value - the input value

Parameter

public Parameter(java.lang.Object value,
                 int jdbcType,
                 int direction)
Full constructor.

Parameters:
value - the value for this Parameter
jdbcType - a jdbc type understood by the jdbc driver
direction - the direction IN, OUT, or INOUT

Parameter

public Parameter(int jdbcType)
Constructor for an implicit Out Parameter.

Parameters:
jdbcType - a jdbc type understood by the jdbc driver
Method Detail

getValue

public java.lang.Object getValue()
The input or output value.

Returns:
the input or output value

setValue

public void setValue(java.lang.Object value)
The input or output value.

Parameters:
value - the input or output value

getDirection

public int getDirection()

getJdbcType

public int getJdbcType()

getOptions

public java.util.Map getOptions()
Options for handling the values for this parameter. For example, the ResultSetRowToMapTransformer used during resultSet transformation will look for callbacks implementing the Transformer interface that can allow you to process each key as it is read or process each value as it is read from the ResultSet.

Returns:
the options for handling this parameter
See Also:
HandlingOption, CallOutputHandler, ResultSetRowToMapTransformer

setOptions

public void setOptions(java.util.Map options)

toString

public java.lang.String toString()

tryToLookupType

private static int tryToLookupType(java.lang.Object value)
Some common classes have JDBC types associated with them that we know about.

Parameters:
value - the value being set in the parameter
Returns:
the JDBC type found or TYPE_NOT_SET if not found

nullableString

public static Parameter nullableString(java.lang.String value)
A string input parameter.

These nullable creator methods are used because when a plain object is sent into the setParameters methods, and the value is null, it is impossible to tell the type, and JDBC may complain. This method is for the convenience of the developer to wrap possibly null values in a Parameter without the extra verbosity of the type and directionality parameters.

Parameters:
value - the value of the input, possibly null
Returns:
an String-typed input Parameter

nullableNumeric

public static Parameter nullableNumeric(java.lang.Number value)
A numeric input Parameter.

These nullable creator methods are used because when a plain object is sent into the setParameters methods, and the value is null, it is impossible to tell the type, and JDBC may complain. This method is for the convenience of the developer to wrap possibly null values in a Parameter without the extra verbosity of the type and directionality parameters.

Parameters:
value - the value of the input, possibly null
Returns:
a numeric input Parameter

nullableString

public static Parameter nullableString(java.lang.String value,
                                       int direction)
A String Parameter with direction.

These nullable creator methods are used because when a plain object is sent into the setParameters methods, and the value is null, it is impossible to tell the type, and JDBC may complain. This method is for the convenience of the developer to wrap possibly null values in a Parameter without the extra verbosity of the type and directionality parameters.

Parameters:
value - the value of the input, possibly null
direction -
Returns:
a string parameter

nullableNumeric

public static Parameter nullableNumeric(java.lang.Number value,
                                        int direction)
A numeric Parameter with direction.

These nullable creator methods are used because when a plain object is sent into the setParameters methods, and the value is null, it is impossible to tell the type, and JDBC may complain. This method is for the convenience of the developer to wrap possibly null values in a Parameter without the extra verbosity of the type and directionality parameters.

Parameters:
value - the value of the input, possibly null
direction -
Returns:
a numeric input Parameter