com.simba.dsi.dataengine.utilities
Class DataWrapper

java.lang.Object
  extended by com.simba.dsi.dataengine.utilities.DataWrapper

public final class DataWrapper
extends java.lang.Object

The DataWrapper class is used to hold a piece of data of any available SQL type.


Constructor Summary
DataWrapper()
          Constructor.
 
Method Summary
 void copyData(DataWrapper other)
          Shallow copies the members of the input DataWrapper into this DataWrapper.
 IArray getArray()
          Gets an Array value.
 java.math.BigInteger getBigInt()
          Gets a big integer value.
 java.lang.Long getBigIntAsLong()
          Gets a SQL_BIGINT value as a Long.
 byte[] getBinary()
          Gets a binary value.
 java.lang.Boolean getBit()
          Gets a bit value.
 java.lang.Boolean getBoolean()
          Gets a boolean value.
 java.lang.String getChar()
          Gets a char value in String form.
 java.sql.Date getDate()
          Gets a DATE value.
 java.math.BigDecimal getDecimal()
          Gets a decimal value.
 java.lang.Double getDouble()
          Gets a double value.
 java.lang.Double getFloat()
          Gets a float value.
 java.util.UUID getGuid()
          Gets a GUID value.
 java.lang.Long getInteger()
          Gets an integer value.
 java.lang.Object getInterval()
          Gets an interval value.
 byte[] getLongVarBinary()
          Gets a long varbinary value.
 java.lang.String getLongVarChar()
          Gets a long varchar value in String form.
 java.math.BigDecimal getNumeric()
          Gets a numeric value.
 java.lang.Object getObject()
          Gets the raw object value.
 java.lang.Float getReal()
          Gets a REAL value.
 java.lang.Integer getSmallInt()
          Gets a small integer value.
 java.sql.Time getTime()
          Gets a time value with the YEAR/MONTH/DAY values truncated to 1970/01/01 in the timezone that the time was created in.
 java.sql.Timestamp getTimestamp()
          Gets a timestamp value.
 TimestampTz getTimestampTz()
          Gets a timestamp value with timezone.
 TimeTz getTimeTz()
          Gets a time value with timezone.
 java.lang.Short getTinyInt()
          Gets a tiny integer value.
 int getType()
          Returns the SQL type as defined in java.sql.Types.
 byte[] getVarBinary()
          Gets a varbinary value.
 java.lang.String getVarChar()
          Gets a varchar value in String form.
 boolean isNull()
          Indicates if the associated data is "null".
 boolean isSet()
          Indicates if a value (or null) has been set for this object.
 void setArray(IArray value)
          Sets Array data.
 void setBigInt(java.math.BigInteger value)
          Sets big integer data.
 void setBigInt(long value)
          Sets big integer data.
 void setBinary(byte[] value)
          Sets binary data.
 void setBit(boolean value)
          Sets bit data.
 void setBit(java.lang.Boolean value)
          Sets bit data.
 void setBoolean(boolean value)
          Sets boolean data.
 void setBoolean(java.lang.Boolean value)
          Sets boolean data.
 void setChar(java.lang.String value)
          Sets char data.
 void setData(int javaSqlType, java.lang.Object data)
          Sets the data stored in the DataWrapper.
 void setDate(java.sql.Date value)
          Sets DATE data.
 void setDate(int year, int month, int dayOfMonth)
          Sets the Date in the default timezone.
 void setDecimal(java.math.BigDecimal value)
          Sets decimal data.
 void setDouble(double value)
          Sets double data.
 void setDouble(java.lang.Double value)
          Sets double data.
 void setFloat(double value)
          Sets float data.
 void setFloat(java.lang.Double value)
          Sets float data.
 void setGuid(java.util.UUID value)
          Sets GUID data.
 void setInteger(long value)
          Sets integer data.
 void setInteger(java.lang.Long value)
          Sets integer data.
 void setInterval(java.lang.Object value)
          Sets interval data.
 void setLongVarBinary(byte[] value)
          Sets long varbinary data.
 void setLongVarChar(java.lang.String value)
          Sets long varchar data.
 void setNull(int javaSqlType)
          Sets the associated data to be "null" with the given SQL type.
 void setNumeric(java.math.BigDecimal value)
          Sets numeric data.
 void setReal(float value)
          Sets REAL data.
 void setReal(java.lang.Float value)
          Sets REAL data.
 void setSmallInt(int value)
          Sets small integer data.
 void setSmallInt(java.lang.Integer value)
          Sets small integer data.
 void setTime(int hour, int minute, int second)
          Sets time data.
 void setTime(int hour, int minute, int second, int fraction)
          Sets time data.
 void setTime(java.sql.Time value)
          Sets time data.
 void setTime(TimeTz value)
          Sets time data.
 void setTimestamp(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanos)
          Sets timestamp data.
 void setTimestamp(java.sql.Timestamp value)
          Sets timestamp data.
 void setTimestamp(TimestampTz value)
          Sets timestamp data.
 void setTinyInt(short value)
          Sets tiny integer data.
 void setTinyInt(java.lang.Short value)
          Sets tiny integer data.
 void setVarBinary(byte[] value)
          Sets varbinary data.
 void setVarChar(java.lang.String value)
          Sets varchar data.
 void setWChar(java.lang.String value)
          Sets wchar data.
 void setWLongVarChar(java.lang.String value)
          Sets wchar data.
 void setWVarChar(java.lang.String value)
          Sets wvarchar data.
 java.lang.String toString()
          Get the object as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataWrapper

public DataWrapper()
Constructor.

Creates a DataWrapper with value null and type "0". This is not a legal DataWrapper, and will return false for a call to isSet(). The DataWrapper must be initialized using a setXXX() method.

Method Detail

copyData

public void copyData(DataWrapper other)
Shallow copies the members of the input DataWrapper into this DataWrapper.

Parameters:
other - The DataWrapper to copy from.

getArray

public IArray getArray()
                throws IncorrectTypeException
Gets an Array value. May return null.

Returns:
an Array value, or null.
Throws:
IncorrectTypeException - If the data type is not ARRAY

getBigInt

public java.math.BigInteger getBigInt()
                               throws IncorrectTypeException
Gets a big integer value. May return null.

Returns:
big integer value or null.
Throws:
IncorrectTypeException - If the data type is not BIGINT.

getBigIntAsLong

public java.lang.Long getBigIntAsLong()
                               throws IncorrectTypeException
Gets a SQL_BIGINT value as a Long. May return null. Note: This will not check for overflow if a BigInteger value was set on this object before.

Returns:
big integer value as a Long or null.
Throws:
IncorrectTypeException - If the data type is not BIGINT.

getBinary

public byte[] getBinary()
                 throws IncorrectTypeException
Gets a binary value. May return null.

Returns:
binary value or null.
Throws:
IncorrectTypeException - If the data type is not binary.

getBit

public java.lang.Boolean getBit()
                         throws IncorrectTypeException
Gets a bit value. May return null.

Returns:
bit value or null.
Throws:
IncorrectTypeException - If the data type is not bit.

getBoolean

public java.lang.Boolean getBoolean()
                             throws IncorrectTypeException
Gets a boolean value. May return null.

Returns:
bit value or null.
Throws:
IncorrectTypeException - If the data type is not bit.

getChar

public java.lang.String getChar()
                         throws IncorrectTypeException
Gets a char value in String form. May return null.

Returns:
char value or null.
Throws:
IncorrectTypeException - If the data type is not char.

getDate

public java.sql.Date getDate()
                      throws IncorrectTypeException
Gets a DATE value. May return null.

Returns:
DATE value or null.
Throws:
IncorrectTypeException - If the data type is not DATE.

getDecimal

public java.math.BigDecimal getDecimal()
                                throws IncorrectTypeException
Gets a decimal value. May return null.

Returns:
decimal value or null.
Throws:
IncorrectTypeException - If the data type is not decimal.

getDouble

public java.lang.Double getDouble()
                           throws IncorrectTypeException
Gets a double value. May return null.

Returns:
double value or null.
Throws:
IncorrectTypeException - If the data type is not double.

getFloat

public java.lang.Double getFloat()
                          throws IncorrectTypeException
Gets a float value. May return null.

Returns:
float value or null.
Throws:
IncorrectTypeException - If the data type is not float.

getGuid

public java.util.UUID getGuid()
                       throws IncorrectTypeException
Gets a GUID value. May return null. UUID and GUID are synonyms, hence returning the built-in type of UUID.

Returns:
UUID value or null.
Throws:
IncorrectTypeException - If the data type is not GUID.

getInteger

public java.lang.Long getInteger()
                          throws IncorrectTypeException
Gets an integer value. May return null.

Returns:
integer value or null.
Throws:
IncorrectTypeException - If the data type is not integer.

getInterval

public java.lang.Object getInterval()
                             throws IncorrectTypeException
Gets an interval value. May return null.

Returns:
interval value or null.
Throws:
IncorrectTypeException - If the data type is not interval.

getLongVarBinary

public byte[] getLongVarBinary()
                        throws IncorrectTypeException
Gets a long varbinary value. May return null.

Returns:
long varbinary value or null.
Throws:
IncorrectTypeException - If the data type is not long varbinary.

getLongVarChar

public java.lang.String getLongVarChar()
                                throws IncorrectTypeException
Gets a long varchar value in String form. May return null.

Returns:
long varchar value or null.
Throws:
IncorrectTypeException - If the data type is not long varchar.

getNumeric

public java.math.BigDecimal getNumeric()
                                throws IncorrectTypeException
Gets a numeric value. May return null.

Returns:
numeric value or null.
Throws:
IncorrectTypeException - If the data type is not numeric.

getObject

public java.lang.Object getObject()
Gets the raw object value. May return null.

Returns:
Object value or null.

getReal

public java.lang.Float getReal()
                        throws IncorrectTypeException
Gets a REAL value. May return null.

Returns:
REAL value or null.
Throws:
IncorrectTypeException - If the data type is not REAL.

getSmallInt

public java.lang.Integer getSmallInt()
                              throws IncorrectTypeException
Gets a small integer value. May return null.

Returns:
small integer value or null.
Throws:
IncorrectTypeException - If the data type is not small integer.

getTime

public java.sql.Time getTime()
                      throws IncorrectTypeException
Gets a time value with the YEAR/MONTH/DAY values truncated to 1970/01/01 in the timezone that the time was created in. May return null.

Returns:
time value or null.
Throws:
IncorrectTypeException - If the data type is not time.

getTimestamp

public java.sql.Timestamp getTimestamp()
                                throws IncorrectTypeException
Gets a timestamp value. May return null.

Returns:
timestamp value or null.
Throws:
IncorrectTypeException - If the data type is not timestamp.

getTimestampTz

public TimestampTz getTimestampTz()
                           throws IncorrectTypeException
Gets a timestamp value with timezone.

May return null.

If the time does not have a timezone, the default JVM timezone is supplied.

Returns:
timestamp value with timezone or null.
Throws:
IncorrectTypeException - If the data type is not timestamp.

getTimeTz

public TimeTz getTimeTz()
                 throws IncorrectTypeException
Gets a time value with timezone.

May return null.

If the time does not have a timezone, the default JVM timezone is supplied.

Returns:
time value or null.
Throws:
IncorrectTypeException - If the data type is not time.

getTinyInt

public java.lang.Short getTinyInt()
                           throws IncorrectTypeException
Gets a tiny integer value. May return null.

Returns:
tiny integer value or null.
Throws:
IncorrectTypeException - If the data type is not TINYINT.

getType

public int getType()
Returns the SQL type as defined in java.sql.Types.

Returns:
SQL type for the data.

getVarBinary

public byte[] getVarBinary()
                    throws IncorrectTypeException
Gets a varbinary value. May return null.

Returns:
varbinary value or null.
Throws:
IncorrectTypeException - If the data type is not varbinary.

getVarChar

public java.lang.String getVarChar()
                            throws IncorrectTypeException
Gets a varchar value in String form. May return null.

Returns:
varchar value or null.
Throws:
IncorrectTypeException - If the data type is not varchar.

isNull

public boolean isNull()
Indicates if the associated data is "null".

Returns:
indicates if the associated data is "null".

isSet

public boolean isSet()
Indicates if a value (or null) has been set for this object.

Returns:
indicates if a value (or null) has been set.

setArray

public void setArray(IArray value)
Sets Array data.

Parameters:
value - An Array value.

setBigInt

public void setBigInt(java.math.BigInteger value)
Sets big integer data.

Parameters:
value - A big integer value.

setBigInt

public void setBigInt(long value)
Sets big integer data.

Parameters:
value - A big integer value.

setBinary

public void setBinary(byte[] value)
Sets binary data.

May set value to null.

When used in conjunction with a binary column/parameter, the length of a non-null value must match the column length.

Parameters:
value - A binary value or null.

setBit

public void setBit(boolean value)
Sets bit data.

Parameters:
value - A bit value.

setBit

public void setBit(java.lang.Boolean value)
Sets bit data. May set value to null.

Parameters:
value - A bit value or null.

setBoolean

public void setBoolean(boolean value)
Sets boolean data.

Parameters:
value - A bit value.

setBoolean

public void setBoolean(java.lang.Boolean value)
Sets boolean data. May set value to null.

Parameters:
value - A bit value or null.

setChar

public void setChar(java.lang.String value)
Sets char data.

May set value to null.

When used in conjunction with a char column/parameter, the length of non-null input must match the column length.

Parameters:
value - A String char value or null.

setData

public void setData(int javaSqlType,
                    java.lang.Object data)
             throws IncorrectTypeException
Sets the data stored in the DataWrapper.

data must be of the appropriate Java object type for the given SQL type javaSqlType.

The SQL type must fit within a 16-bit signed integer, and must correspond to a valid SQL type for ODBC.

Parameters:
javaSqlType - A valid SQL type, from java.sql.Types.
data - Data to be stored.
Throws:
IncorrectTypeException - If javaSqlType is not recognized, or data's Java object type is not appropriate given javaSqlType.

setDate

public void setDate(int year,
                    int month,
                    int dayOfMonth)
Sets the Date in the default timezone.

Parameters:
year - Year.
month - Month (January = 0, February = 1, ...).
dayOfMonth - Day of the month.

setDate

public void setDate(java.sql.Date value)
Sets DATE data. May set value to null. If it is not null it should be in the default timezone.

Parameters:
value - A DATE value or null.

setDecimal

public void setDecimal(java.math.BigDecimal value)
Sets decimal data. May set value to null. When used in conjunction with a decimal column/parameter, the scale must match the column scale and the precision must be equal to or greater than the column precision.

Parameters:
value - A decimal value or null.

setDouble

public void setDouble(double value)
Sets double data.

Parameters:
value - A double value.

setDouble

public void setDouble(java.lang.Double value)
Sets double data. May set value to null.

Parameters:
value - A double value or null.

setFloat

public void setFloat(double value)
Sets float data.

Parameters:
value - A float value.

setFloat

public void setFloat(java.lang.Double value)
Sets float data. May set value to null.

Parameters:
value - A float value or null.

setGuid

public void setGuid(java.util.UUID value)
Sets GUID data. May set value to null. UUID and GUID are synonyms, hence returning the built-in type of UUID.

Parameters:
value - A UUID value or null.

setInteger

public void setInteger(long value)
Sets integer data.

Parameters:
value - An integer value.

setInteger

public void setInteger(java.lang.Long value)
Sets integer data. May set value to null.

Parameters:
value - An integer value or null.

setInterval

public void setInterval(java.lang.Object value)
Sets interval data. May set value to null.

Parameters:
value - An interval value or null.

setLongVarBinary

public void setLongVarBinary(byte[] value)
Sets long varbinary data.

May set value to null.

When used in conjunction with a long varbinary column/parameter, the length of a non-null value must be equal to or less than the column length.

Parameters:
value - A long varbinary value or null.

setLongVarChar

public void setLongVarChar(java.lang.String value)
Sets long varchar data.

May set value to null.

When used in conjunction with a long varchar column/parameter, the length of non-null input must be less than or equal to the column length.

Parameters:
value - A String long varchar value or null.

setNull

public void setNull(int javaSqlType)
Sets the associated data to be "null" with the given SQL type.

The SQL type must fit within a 16-bit signed integer, and must correspond to a valid SQL type for ODBC.

Parameters:
javaSqlType - A valid SQL type, from java.sql.Types.

setNumeric

public void setNumeric(java.math.BigDecimal value)
Sets numeric data. May set value to null. When used in conjunction with a numeric column/parameter, the scale and precision of the input must match the column scale and precision.

Parameters:
value - A numeric value or null.

setReal

public void setReal(float value)
Sets REAL data.

Parameters:
value - A REAL value.

setReal

public void setReal(java.lang.Float value)
Sets REAL data. May set value to null.

Parameters:
value - A REAL value or null.

setSmallInt

public void setSmallInt(int value)
Sets small integer data.

Parameters:
value - A small integer value.

setSmallInt

public void setSmallInt(java.lang.Integer value)
Sets small integer data. May set value to null.

Parameters:
value - A small integer value or null.

setTime

public void setTime(int hour,
                    int minute,
                    int second)
Sets time data.

Parameters:
hour - Hour on the 24-hour clock (0 to 23).
minute - Minute.
second - Second.

setTime

public void setTime(int hour,
                    int minute,
                    int second,
                    int fraction)
Sets time data.

Parameters:
hour - Hour on the 24-hour clock (0 to 23).
minute - Minute.
second - Second.
fraction - Fractional seconds (in nanoseconds)

setTime

public void setTime(java.sql.Time value)
Sets time data. May set value to null. If it is not null it should be in the default timezone.

Parameters:
value - A time value or null.

setTime

public void setTime(TimeTz value)
Sets time data. May set value to null.

Parameters:
value - A time with timezone value or null.

setTimestamp

public void setTimestamp(int year,
                         int month,
                         int dayOfMonth,
                         int hour,
                         int minute,
                         int second,
                         int nanos)
Sets timestamp data.

Parameters:
year - Year.
month - Month (January = 0, February = 1, ...).
dayOfMonth - Day of month.
hour - Hour on the 24-hour clock (0 to 23).
minute - Minute.
second - Second.
nanos - Nanosecond.

setTimestamp

public void setTimestamp(java.sql.Timestamp value)
Sets timestamp data. May set value to null.

Parameters:
value - A timestamp value or null.

setTimestamp

public void setTimestamp(TimestampTz value)
Sets timestamp data. May set value to null.

Parameters:
value - A timestamp with timezone value or null.

setTinyInt

public void setTinyInt(short value)
Sets tiny integer data.

Parameters:
value - A tiny integer value.

setTinyInt

public void setTinyInt(java.lang.Short value)
Sets tiny integer data. May set value to null.

Parameters:
value - A tiny integer value or null.

setVarBinary

public void setVarBinary(byte[] value)
Sets varbinary data.

May set value to null.

When used in conjunction with a varbinary column/parameter, the length of a non-null value must be equal to or less than the column length.

Parameters:
value - A varbinary value or null.

setVarChar

public void setVarChar(java.lang.String value)
Sets varchar data.

May set value to null.

When used in conjunction with a varchar column/parameter, the length of non-null input must be less than or equal to the column length.

Parameters:
value - A String value or null.

setWVarChar

public void setWVarChar(java.lang.String value)
Sets wvarchar data.

May set value to null.

When used in conjunction with a varchar column/parameter, the length of non-null input must be less than or equal to the column length.

Parameters:
value - A String value or null.

setWChar

public void setWChar(java.lang.String value)
Sets wchar data.

May set value to null.

When used in conjunction with a varchar column/parameter, the length of non-null input must be less than or equal to the column length.

Parameters:
value - A String value or null.

setWLongVarChar

public void setWLongVarChar(java.lang.String value)
Sets wchar data.

May set value to null.

When used in conjunction with a varchar column/parameter, the length of non-null input must be less than or equal to the column length.

Parameters:
value - A String value or null.

toString

public java.lang.String toString()
Get the object as a string.

Overrides:
toString in class java.lang.Object
Returns:
String value.


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.