Package org.apache.derby.iapi.types
Interface DataValueFactory
- All Known Implementing Classes:
DataValueFactoryImpl
public interface DataValueFactory
This interface is how we get data values of different types.
For any method that takes a 'previous' argument it is required
that the caller pass in an object of the same class that would
be returned by the call if null was passed for previous.
-
Method Summary
Modifier and TypeMethodDescriptiongetBitDataValue
(byte[] value) Get a SQL bit with the given value.getBitDataValue
(byte[] value, BitDataValue previous) getBlobDataValue
(byte[] value, BitDataValue previous) Get a SQL Blob with the given value.getBlobDataValue
(Blob value, BitDataValue previous) Get a SQL Blob with the given value.getCharacterCollator
(int collationType) Return the RuleBasedCollator depending on the collation type.getCharDataValue
(String value) Get a new SQLChar object to represent a SQL CHAR (UCS_BASIC) with the given value.getCharDataValue
(String value, StringDataValue previous) Get a SQLChar object to represent a SQL CHAR (UCS_BASIC with the given value.getCharDataValue
(String value, StringDataValue previous, int collationType) Get a StringDataValue to represent a SQL CHAR with the passed in collationType.getClobDataValue
(String value, StringDataValue previous) Get a SQLClob object to represent a SQL CLOB (UCS_BASIC) with the given value.getClobDataValue
(String value, StringDataValue previous, int collationType) Get a StringDataValue to represent a SQL LONG VARCHAR with the passed in collationType.getClobDataValue
(Clob value, StringDataValue previous) Get a SQLClob object to represent a SQL CLOB (UCS_BASIC) with the given value.getClobDataValue
(Clob value, StringDataValue previous, int collationType) Get a StringDataValue to represent a SQL CLOB with the passed in collationType.getDataValue
(boolean value, BooleanDataValue previous) Get a SQL boolean with the given value.getDataValue
(byte value, NumberDataValue previous) Get a SQL TINYINT with the given value.getDataValue
(char value, NumberDataValue previous) Get a SQL int with a char value.getDataValue
(double value, NumberDataValue previous) Get a SQL double precision with the given value.getDataValue
(float value, NumberDataValue previous) Get a SQL real with the given value.getDataValue
(int value, NumberDataValue previous) Get a SQL int with the given value.getDataValue
(long value, NumberDataValue previous) Get a SQL bigint with the given value.getDataValue
(short value, NumberDataValue previous) Get a SQL SMALLINT with the given value.getDataValue
(Boolean value, BooleanDataValue previous) Get a SQL boolean with the given value.getDataValue
(Byte value, NumberDataValue previous) Get a SQL TINYINT with the given value.getDataValue
(Double value, NumberDataValue previous) Get a SQL double precision with the given value.getDataValue
(Float value, NumberDataValue previous) Get a SQL real with the given value.getDataValue
(Integer value, NumberDataValue previous) Get a SQL int with the given value.getDataValue
(Long value, NumberDataValue previous) Get a SQL bigint with the given value.getDataValue
(Object value, UserDataValue previous) Get a User-defined data value with the given value and type name.getDataValue
(Short value, NumberDataValue previous) Get a SQL smallint with the given value.getDataValue
(Date value, DateTimeDataValue previous) Get a SQL date with the given value.getDataValue
(Time value, DateTimeDataValue previous) Get a SQL time with the given value.getDataValue
(Timestamp value, DateTimeDataValue previous) Get a SQL timestamp with the given value.getDataValue
(RowLocation value, RefDataValue previous) Get a RefDataValue with the given value.getDate
(DataValueDescriptor operand) Implements the SQL date functiongetDateValue
(String dateStr, boolean isJdbcEscape) getDecimalDataValue
(Number value, NumberDataValue previous) Get a SQL DECIMAL with the given value.getLongVarbitDataValue
(byte[] value, BitDataValue previous) Get a SQL Long Bit Varying with the given value.getLongvarcharDataValue
(String value) Get a SQL long varchar with the given value.getLongvarcharDataValue
(String value, StringDataValue previous) Get a SQLLongvarchar object to represent a SQL LONG VARCHAR (UCS_BASIC) with the given value.getLongvarcharDataValue
(String value, StringDataValue previous, int collationType) Get a StringDataValue to represent a SQL LONG VARCHAR with the passed in collationType.getNull
(int formatId, int collationType) Return an object based on the format id and collation type.getNullBit
(BitDataValue dataValue) Get a SQL Bit with a SQL null value.getNullBlob
(BitDataValue dataValue) Get a SQL Blob with a SQL null value.getNullBoolean
(BooleanDataValue dataValue) Get a SQL boolean with a SQL null value.getNullByte
(NumberDataValue dataValue) Get a SQL tinyint with a SQL null value.getNullChar
(StringDataValue dataValue) Get a SQL CHAR (UCS_BASIC) with a SQL null value.getNullChar
(StringDataValue dataValue, int collationType) Get a SQL CHAR set to NULL with collation set to collationType.getNullClob
(StringDataValue dataValue) Get a SQL CLOB (UCS_BASIC) with a SQL null value.getNullClob
(StringDataValue dataValue, int collationType) Get a SQL CLOB set to NULL with collation set to collationType.getNullDate
(DateTimeDataValue dataValue) Get a SQL date with a SQL null value.getNullDecimal
(NumberDataValue dataValue) Get a SQL Decimal/Numeric with a SQL null value.getNullDouble
(NumberDataValue dataValue) Get a SQL double with a SQL null value.getNullFloat
(NumberDataValue dataValue) Get a SQL float with a SQL null value.getNullInteger
(NumberDataValue dataValue) Get a SQL int with a SQL null value.getNullLong
(NumberDataValue dataValue) Get a SQL bigint with a SQL null value.getNullLongVarbit
(BitDataValue dataValue) Get a SQL Long Bit Varying with a SQL null value.getNullLongvarchar
(StringDataValue dataValue) Get a SQL LONG VARCHAR (UCS_BASIC) with a SQL null value.getNullLongvarchar
(StringDataValue dataValue, int collationType) Get a SQL LONG VARCHAR set to NULL with collation set to collationType.getNullObject
(UserDataValue dataValue) Get a User-defined data value with a SQL null value.getNullRef
(RefDataValue dataValue) Get a RefDataValue with a SQL null value.getNullShort
(NumberDataValue dataValue) Get a SQL smallint with a SQL null value.getNullTime
(DateTimeDataValue dataValue) Get a SQL time with a SQL null value.getNullTimestamp
(DateTimeDataValue dataValue) Get a SQL timestamp with a SQL null value.getNullVarbit
(BitDataValue dataValue) Get a SQL Bit Varying with a SQL null value.getNullVarchar
(StringDataValue dataValue) Get a SQL VARCHAR (UCS_BASIC) with a SQL null value.getNullVarchar
(StringDataValue dataValue, int collationType) Get a SQL VARCHAR set to NULL with collation set to collationType.getNullXML
(XMLDataValue dataValue) Get an XML with a SQL null value.getTimestamp
(DataValueDescriptor operand) Implement the timestamp SQL function: construct a SQL timestamp from a string, or timestamp.getTimestamp
(DataValueDescriptor date, DataValueDescriptor time) Construct a SQL timestamp from a date and time.getTimestampValue
(String timestampStr, boolean isJdbcEscape) getTimeValue
(String timeStr, boolean isJdbcEscape) getVarbitDataValue
(byte[] value, BitDataValue previous) Get a SQL bit with the given value.getVarcharDataValue
(String value) Get a SQL varchar with the given value.getVarcharDataValue
(String value, StringDataValue previous) Get a SQLVarhar object to represent a SQL VARCHAR (UCS_BASIC) with the given value.getVarcharDataValue
(String value, StringDataValue previous, int collationType) Get a StringDataValue to represent a SQL VARCHAR with the passed in collationType.getXMLDataValue
(XMLDataValue previous) Get a null XML value.
-
Method Details
-
getDataValue
Get a SQL int with the given value. A null argument means get a SQL null value. Uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getDataValue
Get a SQL int with a char value. A null argument means get a SQL null value. Uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getDataValue
Get a SQL smallint with the given value. A null argument means get a SQL null value. The second arg uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getDataValue
Get a SQL TINYINT with the given value. A null argument means get a SQL null value. The second arg uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getDataValue
Get a SQL bigint with the given value. A null argument means get a SQL null value. The second arg uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getDataValue
Get a SQL real with the given value. A null argument means get a SQL null value. The second arg uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getDataValue
Get a SQL double precision with the given value. A null argument means a SQL null value. The second arg uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
- Thrown on error
-
getDataValue
Get a SQL boolean with the given value. A null argument means get a SQL null value. The second arg uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
-
getLongVarbitDataValue
Get a SQL Long Bit Varying with the given value. A null argument means get a SQL null value. Uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
- Thrown on error
-
getBlobDataValue
Get a SQL Blob with the given value. A null argument means get a SQL null value. Uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
- Thrown on error
-
getBlobDataValue
Get a SQL Blob with the given value. A null argument means get a SQL null value. Uses the previous value (if non-null) to hold the return value.- Throws:
StandardException
- Thrown on error
-
getVarcharDataValue
Get a SQL varchar with the given value. A null argument means get a SQL null value. -
getVarcharDataValue
StringDataValue getVarcharDataValue(String value, StringDataValue previous) throws StandardException Get a SQLVarhar object to represent a SQL VARCHAR (UCS_BASIC) with the given value. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new SQLVarchar will be created and set to the value.- Throws:
StandardException
-
getVarcharDataValue
StringDataValue getVarcharDataValue(String value, StringDataValue previous, int collationType) throws StandardException Get a StringDataValue to represent a SQL VARCHAR with the passed in collationType. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new StringDataValue will be created and set to the value. If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC then the call is the equivalent of the overload without collationType.- Throws:
StandardException
-
getLongvarcharDataValue
Get a SQL long varchar with the given value. A null argument means get a SQL null value. -
getLongvarcharDataValue
StringDataValue getLongvarcharDataValue(String value, StringDataValue previous) throws StandardException Get a SQLLongvarchar object to represent a SQL LONG VARCHAR (UCS_BASIC) with the given value. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new SQLLongvarchar will be created and set to the value.- Throws:
StandardException
-
getLongvarcharDataValue
StringDataValue getLongvarcharDataValue(String value, StringDataValue previous, int collationType) throws StandardException Get a StringDataValue to represent a SQL LONG VARCHAR with the passed in collationType. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new StringDataValue will be created and set to the value. If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC then the call is the equivalent of the overload without collationType.- Throws:
StandardException
-
getClobDataValue
Get a SQLClob object to represent a SQL CLOB (UCS_BASIC) with the given value. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new SQLLongvarchar will be created and set to the value.- Throws:
StandardException
-
getClobDataValue
Get a SQLClob object to represent a SQL CLOB (UCS_BASIC) with the given value. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new SQLLongvarchar will be created and set to the value.- Throws:
StandardException
-
getClobDataValue
StringDataValue getClobDataValue(String value, StringDataValue previous, int collationType) throws StandardException Get a StringDataValue to represent a SQL LONG VARCHAR with the passed in collationType. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new StringDataValue will be created and set to the value. If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC then the call is the equivalent of the overload without collationType.- Throws:
StandardException
-
getClobDataValue
StringDataValue getClobDataValue(Clob value, StringDataValue previous, int collationType) throws StandardException Get a StringDataValue to represent a SQL CLOB with the passed in collationType. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new StringDataValue will be created and set to the value. If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC then the call is the equivalent of the overload without collationType.- Throws:
StandardException
-
getDataValue
Get a User-defined data value with the given value and type name. A null argument means get a SQL null value. The second arg uses the previous value (if non-null) hold the return value. -
getDataValue
Get a RefDataValue with the given value. A null argument means get a SQL null value. Uses the previous value (if non-null) to hold the return value. -
getDataValue
Get a SQL int with the given value. The second arg re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getDataValue
Get a SQL bigint with the given value. The second arg re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getDataValue
Get a SQL real with the given value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
- Thrown on error
-
getDataValue
Get a SQL double precision with the given value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
- Thrown on error
-
getDataValue
Get a SQL SMALLINT with the given value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getDataValue
Get a SQL TINYINT with the given value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getDecimalDataValue
NumberDataValue getDecimalDataValue(Number value, NumberDataValue previous) throws StandardException Get a SQL DECIMAL with the given value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
- Thrown on error
-
getDataValue
Get a SQL boolean with the given value. The second arg re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getBitDataValue
Get a SQL bit with the given value. The second form re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
- Thrown on error
-
getBitDataValue
- Throws:
StandardException
-
getVarbitDataValue
Get a SQL bit with the given value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
- Thrown on error
-
getCharDataValue
Get a new SQLChar object to represent a SQL CHAR (UCS_BASIC) with the given value. A null argument means get a SQL NULL value. -
getCharDataValue
Get a SQLChar object to represent a SQL CHAR (UCS_BASIC with the given value. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new SQLChar will be created and set to the value.- Throws:
StandardException
-
getCharDataValue
StringDataValue getCharDataValue(String value, StringDataValue previous, int collationType) throws StandardException Get a StringDataValue to represent a SQL CHAR with the passed in collationType. A null argument means get a SQL NULL value. If previous is not null (Java reference) then it will be set to the value passed in and returned, otherwise a new StringDataValue will be created and set to the value. If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC then the call is the equivalent of the overload without collationType.- Throws:
StandardException
-
getDataValue
Get a SQL date with the given value. A null argument means get a SQL null value. The second arg re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getDataValue
Get a SQL time with the given value. A null argument means get a SQL null value. The second arg re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getDataValue
DateTimeDataValue getDataValue(Timestamp value, DateTimeDataValue previous) throws StandardException Get a SQL timestamp with the given value. A null argument means get a SQL null value. The second arg re-uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getTimestamp
Implement the timestamp SQL function: construct a SQL timestamp from a string, or timestamp.- Parameters:
operand
- Must be a timestamp or a string convertible to a timestamp.- Throws:
StandardException
-
getTimestamp
DateTimeDataValue getTimestamp(DataValueDescriptor date, DataValueDescriptor time) throws StandardException Construct a SQL timestamp from a date and time.- Parameters:
date
- Must be convertible to a date.time
- Must be convertible to a time.- Throws:
StandardException
-
getDate
Implements the SQL date function- Parameters:
operand
- A date, timestamp, string or integer.- Returns:
- the corresponding date value
- Throws:
StandardException
- if the syntax is invalid or the date is out of range.
-
getDateValue
- Parameters:
dateStr
- A date in one of the DB2 standard date formats or the local format.isJdbcEscape
- If true then the timestamp must be in the JDBC timestamp escape format, otherwise it must be in the DB2 timestamp format.- Returns:
- A DateTimeDataValue
- Throws:
StandardException
- if the syntax is invalid or the date is out of range.
-
getTimeValue
- Parameters:
timeStr
- A date in one of the DB2 standard time formats or the local format.isJdbcEscape
- If true then the timestamp must be in the JDBC time escape format, otherwise it must be in the DB2 time format.- Returns:
- A DateTimeDataValue
- Throws:
StandardException
- if the syntax is invalid or the time is out of range.
-
getTimestampValue
DateTimeDataValue getTimestampValue(String timestampStr, boolean isJdbcEscape) throws StandardException - Parameters:
timestampStr
- A time in string format.isJdbcEscape
- If true then the time must be in the JDBC time escape format, otherwise it must be in the DB2 time format.- Returns:
- An internal timestamp
- Throws:
StandardException
- if the syntax is invalid or the timestamp is out of range.
-
getXMLDataValue
Get a null XML value. Uses the previous value, if non-null, as the data holder to return.- Throws:
StandardException
-
getNullInteger
Get a SQL int with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullShort
Get a SQL smallint with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullByte
Get a SQL tinyint with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullLong
Get a SQL bigint with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullFloat
Get a SQL float with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullDouble
Get a SQL double with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullDecimal
Get a SQL Decimal/Numeric with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullBoolean
Get a SQL boolean with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullBit
Get a SQL Bit with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
- Thrown on error
-
getNullVarbit
Get a SQL Bit Varying with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
- Thrown on error
-
getNullLongVarbit
Get a SQL Long Bit Varying with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
- Thrown on error
-
getNullBlob
Get a SQL Blob with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
- Thrown on error
-
getNullChar
Get a SQL CHAR (UCS_BASIC) with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullChar
Get a SQL CHAR set to NULL with collation set to collationType. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
-
getNullVarchar
Get a SQL VARCHAR (UCS_BASIC) with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullVarchar
StringDataValue getNullVarchar(StringDataValue dataValue, int collationType) throws StandardException Get a SQL VARCHAR set to NULL with collation set to collationType. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
-
getNullLongvarchar
Get a SQL LONG VARCHAR (UCS_BASIC) with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullLongvarchar
StringDataValue getNullLongvarchar(StringDataValue dataValue, int collationType) throws StandardException Get a SQL LONG VARCHAR set to NULL with collation set to collationType. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
-
getNullClob
Get a SQL CLOB (UCS_BASIC) with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullClob
Get a SQL CLOB set to NULL with collation set to collationType. If the supplied value is null then get a new value, otherwise set it to null and return that value.- Throws:
StandardException
-
getNullObject
Get a User-defined data value with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullRef
Get a RefDataValue with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullDate
Get a SQL date with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullTime
Get a SQL time with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullTimestamp
Get a SQL timestamp with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getNullXML
Get an XML with a SQL null value. If the supplied value is null then get a new value, otherwise set it to null and return that value. -
getCharacterCollator
Return the RuleBasedCollator depending on the collation type. If the collation type is UCS_BASIC, then this method will return null. If the collation type is TERRITORY_BASED then the return value will be the Collator derived from the database's locale. If this is the first time Collator is being requested for a database with collation type of TERRITORY_BASED, then we will check to make sure that JVM supports the Collator for the database's locale. If not, we will throw an exception This method will be used when Store code is trying to create a DVD template row using the format ids and the collation types. First a DVD will be constructed just using format id. Then if the DVD is of type StringDataValue, then it will call this method to get the Collator object. If the Collator object returned from this method is null then we will continue to use the default DVDs for the character types, ie the DVDs which just use the JVM's default collation. (This is why, we want this method to return null if we are dealing with UCS_BASIC.) If the Collator object returned is not null, then we will construct collation sensitive DVD for the character types. So, the return value of this method determines if we are going to create a character DVD with default collation or with custom collation.- Parameters:
collationType
- This will be UCS_BASIC or TERRITORY_BASED- Returns:
- Collator null if the collation type is UCS_BASIC. Collator based on territory if the collation type is TERRITORY_BASED
- Throws:
StandardException
-
getNull
Return an object based on the format id and collation type. For format ids which do not correspond to character types, a format id is sufficient to get the right DVD. But for character types, Derby uses same format id for collation sensitive character types and for character types that use the default JVM collation. To get the correct DVD for character types, we need to know the collation type. Using collation type, we will determine if we need to construct collation sensitive DVD and associate the correct RuleBasedCollator with such DVDs.- Parameters:
formatId
- Format id for the DVDcollationType
- this is meaningful only for character types.- Returns:
- DataValueDescriptor which will be constructed using the passed parameters
- Throws:
StandardException
-