net.sf.jso.schema
Class StorableField

java.lang.Object
  extended bynet.sf.jso.schema.StorableField
All Implemented Interfaces:
java.io.Serializable

public abstract class StorableField
extends java.lang.Object
implements java.io.Serializable

Abstract class for field type mapping.

See Also:
JDBCTypes, Serialized Form

Field Summary
static int BOOLEAN
          Constant for the boolean primitive.
static int BYTE
          Constant for the byte primitive.
static int CHAR
          Constant for the char primitive.
static int CONTAINER
          Constant for container objects.
static int DATE
          Constant for date objects.
static int DOUBLE
          Constant for the double primitive.
static int FLOAT
          Constant for the float primitive.
static int INT
          Constant for the int primitive.
static int LONG
          Constant for the long primitive.
static int NULL
          Constant for "null" type.
static int OBJECT
          Constant for object references.
static int SHORT
          Constant for the short primitive.
static int STRING
          Constant for string objects.
static int TEXT
          Constant for text (large strings) objects.
static int TIME
          Constant for time objects.
static int TIMESTAMP
          Constant for timestamp (date/time) objects.
static int VOID
          Constant for the void type.
 
Constructor Summary
StorableField()
           
 
Method Summary
static java.lang.Integer getJDBCTypeFor(int aType)
          Maps attributte types to JDBC types, defined in java.sql.Types.
static java.lang.Integer getJDBCTypeFor(java.lang.Integer aType)
          Maps attributte types to JDBC types, defined in java.sql.Types.
static java.lang.String getNameFor(int aType)
          Returns the name of a storable type.
static java.lang.String getNameFor(java.lang.Integer aType)
          Returns the name of a storable type.
static java.util.Set getValidTypes()
          Returns a set of valid storable field type.
static java.lang.Class getWrapperClass(java.lang.Integer aType)
          Maps a storable field type to a class.
static java.lang.Integer getWrapperType(java.lang.Class aClass)
          Maps a wrapper class to a storable field type.
static boolean isValidType(int aType)
          Checks if a type is a valid storable field type.
static boolean isValidType(java.lang.Integer aType)
          Checks if a type is a valid storable field type.
static void prepareField(java.sql.PreparedStatement aPs, int anIndex, java.lang.Integer aType, java.lang.Object aValue)
          Sets the value for a prepared statement's parameter.
static java.lang.Object retrieveField(java.sql.ResultSet aRs, int anIndex, java.lang.Integer aType)
          Retrieves a field value from a result set.
static java.lang.Object retrieveField(java.sql.ResultSet aRs, java.lang.String aField, java.lang.Integer aType)
          Retrieves a field value from a result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final int NULL
Constant for "null" type. Not a valid type.

See Also:
Constant Field Values

VOID

public static final int VOID
Constant for the void type. Not a valid type.

See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
Constant for the boolean primitive.

See Also:
Constant Field Values

BYTE

public static final int BYTE
Constant for the byte primitive.

See Also:
Constant Field Values

CHAR

public static final int CHAR
Constant for the char primitive.

See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
Constant for the double primitive.

See Also:
Constant Field Values

FLOAT

public static final int FLOAT
Constant for the float primitive.

See Also:
Constant Field Values

INT

public static final int INT
Constant for the int primitive.

See Also:
Constant Field Values

LONG

public static final int LONG
Constant for the long primitive.

See Also:
Constant Field Values

SHORT

public static final int SHORT
Constant for the short primitive.

See Also:
Constant Field Values

DATE

public static final int DATE
Constant for date objects.

See Also:
Constant Field Values

STRING

public static final int STRING
Constant for string objects.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Constant for text (large strings) objects.

See Also:
Constant Field Values

TIME

public static final int TIME
Constant for time objects.

See Also:
Constant Field Values

TIMESTAMP

public static final int TIMESTAMP
Constant for timestamp (date/time) objects.

See Also:
Constant Field Values

CONTAINER

public static final int CONTAINER
Constant for container objects.

See Also:
Constant Field Values

OBJECT

public static final int OBJECT
Constant for object references.

See Also:
Constant Field Values
Constructor Detail

StorableField

public StorableField()
Method Detail

getWrapperType

public static java.lang.Integer getWrapperType(java.lang.Class aClass)
Maps a wrapper class to a storable field type.

Parameters:
aClass - Wrapper class to be mapped.
Returns:
An integer with storable type corresponding to wrapper class, or null if class is not storable.

getWrapperClass

public static java.lang.Class getWrapperClass(java.lang.Integer aType)
Maps a storable field type to a class.

Parameters:
aType - Storable field type to be mapped.
Returns:
Wrapper class corresponding to storable field type or null if type is invalid.

getJDBCTypeFor

public static java.lang.Integer getJDBCTypeFor(int aType)
                                        throws java.lang.IllegalArgumentException
Maps attributte types to JDBC types, defined in java.sql.Types.

Parameters:
aType - Attibute type.
Returns:
The corresponding SQL type to the attribute type supplied.
Throws:
java.lang.IllegalArgumentException

getJDBCTypeFor

public static java.lang.Integer getJDBCTypeFor(java.lang.Integer aType)
                                        throws java.lang.IllegalArgumentException
Maps attributte types to JDBC types, defined in java.sql.Types.

Parameters:
aType - Attibute type.
Returns:
The corresponding SQL type to the attribute type supplied.
Throws:
java.lang.IllegalArgumentException

isValidType

public static boolean isValidType(int aType)
Checks if a type is a valid storable field type.

Parameters:
aType - Type to be checked.
Returns:
true if the supplied type is valid; false otherwise.

isValidType

public static boolean isValidType(java.lang.Integer aType)
Checks if a type is a valid storable field type.

Parameters:
aType - Type to be checked.
Returns:
true if the supplied type is valid; false otherwise.

getValidTypes

public static java.util.Set getValidTypes()
Returns a set of valid storable field type.

Returns:
A set of valid storable field type.

getNameFor

public static java.lang.String getNameFor(int aType)
                                   throws java.lang.IllegalArgumentException
Returns the name of a storable type.

Parameters:
aType - Storable type.
Returns:
The corresponding name for the storable type.
Throws:
java.lang.IllegalArgumentException

getNameFor

public static java.lang.String getNameFor(java.lang.Integer aType)
                                   throws java.lang.IllegalArgumentException
Returns the name of a storable type.

Parameters:
aType - Storable type.
Returns:
The corresponding name for the storable type.
Throws:
java.lang.IllegalArgumentException

retrieveField

public static java.lang.Object retrieveField(java.sql.ResultSet aRs,
                                             java.lang.String aField,
                                             java.lang.Integer aType)
                                      throws java.sql.SQLException
Retrieves a field value from a result set.

Parameters:
aRs - The result set that contains field's value.
aField - Name of the field in the result set.
aType - Storable type.
Returns:
Field value.
Throws:
java.sql.SQLException

retrieveField

public static java.lang.Object retrieveField(java.sql.ResultSet aRs,
                                             int anIndex,
                                             java.lang.Integer aType)
                                      throws java.sql.SQLException
Retrieves a field value from a result set.

Parameters:
aRs - The result set that contains field's value.
anIndex - Index of the field in the result set.
aType - Storable type.
Returns:
Field value.
Throws:
java.sql.SQLException

prepareField

public static void prepareField(java.sql.PreparedStatement aPs,
                                int anIndex,
                                java.lang.Integer aType,
                                java.lang.Object aValue)
                         throws java.sql.SQLException
Sets the value for a prepared statement's parameter.

Parameters:
aPs - The prepared statement containing the parameter.
anIndex - Index of the parameter.
aType - Storable type.
aValue - Parameter's value.
Throws:
java.sql.SQLException