Package org.apache.derby.client.am
Class CrossConverters
- java.lang.Object
-
- org.apache.derby.client.am.CrossConverters
-
final class CrossConverters extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private Agent
agent_
private static java.math.BigDecimal
bdMaxByteValue__
private static java.math.BigDecimal
bdMaxDoubleValue__
private static java.math.BigDecimal
bdMaxFloatValue__
private static java.math.BigDecimal
bdMaxIntValue__
private static java.math.BigDecimal
bdMaxLongValue__
private static java.math.BigDecimal
bdMaxShortValue__
private static java.math.BigDecimal
bdMinByteValue__
private static java.math.BigDecimal
bdMinDoubleValue__
private static java.math.BigDecimal
bdMinFloatValue__
private static java.math.BigDecimal
bdMinIntValue__
private static java.math.BigDecimal
bdMinLongValue__
private static java.math.BigDecimal
bdMinShortValue__
private static java.math.BigDecimal
bdOne__
private static java.math.BigDecimal
bdZero__
static int
UNKNOWN_LENGTH
Value used to signal unknown length of data.
-
Constructor Summary
Constructors Constructor Description CrossConverters(Agent agent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.sql.Date
date_valueOf(java.lang.String s, java.util.Calendar cal)
Convert a string to a date in the specified calendar.private static int
digit(char ch)
Convert a character to a digit.(package private) java.math.BigDecimal
getBigDecimalFromString(java.lang.String source)
(package private) boolean
getBooleanFromDouble(double source)
(package private) boolean
getBooleanFromFloat(float source)
(package private) boolean
getBooleanFromInt(int source)
(package private) boolean
getBooleanFromLong(long source)
(package private) boolean
getBooleanFromShort(short source)
(package private) boolean
getBooleanFromString(java.lang.String source)
Get a boolean value from a CHAR column.(package private) byte
getByteFromBoolean(boolean source)
(package private) byte
getByteFromDouble(double source)
(package private) byte
getByteFromFloat(float source)
(package private) byte
getByteFromInt(int source)
(package private) byte
getByteFromLong(long source)
(package private) byte
getByteFromShort(short source)
(package private) byte
getByteFromString(java.lang.String source)
(package private) java.sql.Date
getDateFromString(java.lang.String source, java.util.Calendar cal)
(package private) double
getDoubleFromBoolean(boolean source)
(package private) double
getDoubleFromString(java.lang.String source)
(package private) float
getFloatFromBoolean(boolean source)
(package private) float
getFloatFromDouble(double source)
(package private) float
getFloatFromString(java.lang.String source)
static int
getInputJdbcType(int jdbcType)
Convert the input targetJdbcType to the correct JdbcType used by CrossConverters.(package private) int
getIntFromBoolean(boolean source)
(package private) int
getIntFromDouble(double source)
(package private) int
getIntFromFloat(float source)
(package private) int
getIntFromLong(long source)
(package private) int
getIntFromString(java.lang.String source)
(package private) long
getLongFromBoolean(boolean source)
(package private) long
getLongFromDouble(double source)
(package private) long
getLongFromFloat(float source)
(package private) long
getLongFromString(java.lang.String source)
(package private) short
getShortFromBoolean(boolean source)
(package private) short
getShortFromDouble(double source)
(package private) short
getShortFromFloat(float source)
(package private) short
getShortFromInt(int source)
(package private) short
getShortFromLong(long source)
(package private) short
getShortFromString(java.lang.String source)
(package private) java.lang.String
getStringFromBytes(byte[] bytes)
(package private) java.sql.Time
getTimeFromString(java.lang.String source, java.util.Calendar cal)
(package private) java.sql.Timestamp
getTimestampFromString(java.lang.String source, java.util.Calendar cal)
private static void
initDatePortion(java.util.Calendar cal, java.lang.String date)
Initialize the date components of ajava.util.Calendar
from a string on the format YYYY-MM-DD.private static void
initTimePortion(java.util.Calendar cal, java.lang.String time)
Initialize the time components of ajava.util.Calendar
from a string on the format HH:MM:SS.private static byte
parseByte(java.lang.String s)
private static int
parseInt(java.lang.String s)
private static long
parseLong(java.lang.String s)
private static short
parseShort(java.lang.String s)
(package private) boolean
setBooleanFromObject(java.lang.Object source, int sourceType)
(package private) byte
setByteFromObject(java.lang.Object source, int sourceType)
private byte[]
setBytesFromStream(java.io.InputStream is, int length)
(package private) java.lang.Object
setObject(int targetType, boolean source)
(package private) java.lang.Object
setObject(int targetType, byte source)
(package private) java.lang.Object
setObject(int targetType, byte[] source)
(package private) java.lang.Object
setObject(int targetType, double source)
(package private) java.lang.Object
setObject(int targetType, float source)
(package private) java.lang.Object
setObject(int targetType, int source)
(package private) java.lang.Object
setObject(int targetType, long source)
(package private) java.lang.Object
setObject(int targetType, short source)
(package private) java.lang.Object
setObject(int targetType, java.io.Reader source, int length)
(package private) java.lang.Object
setObject(int targetType, java.lang.Object source)
(package private) java.lang.Object
setObject(int targetDriverType, java.lang.String source)
(package private) java.lang.Object
setObject(int targetType, java.math.BigDecimal source)
(package private) java.lang.Object
setObject(int targetType, java.sql.Blob source)
(package private) java.lang.Object
setObject(int targetType, java.sql.Clob source)
(package private) java.lang.Object
setObject(int targetType, java.sql.Date source)
(package private) java.lang.Object
setObject(int targetType, java.sql.Time source)
(package private) java.lang.Object
setObject(int targetType, java.sql.Timestamp source)
(package private) java.lang.Object
setObjectFromBinaryStream(int targetType, java.io.InputStream source, int length)
(package private) java.lang.Object
setObjectFromCharacterStream(int targetType, java.io.InputStream source, java.nio.charset.Charset encoding, int length)
private java.lang.String
setStringFromReader(java.io.Reader r, int length)
private java.lang.String
setStringFromStream(java.io.InputStream is, java.nio.charset.Charset encoding, int length)
private static void
skipPadding(java.lang.String s, int i, int length)
private static java.sql.Time
time_valueOf(java.lang.String s, java.util.Calendar cal)
Convert a string to a time in the specified calendar.private static java.sql.Timestamp
timestamp_valueOf(java.lang.String s, java.util.Calendar cal)
Convert a string to a timestamp in the specified calendar.
-
-
-
Field Detail
-
UNKNOWN_LENGTH
public static final int UNKNOWN_LENGTH
Value used to signal unknown length of data.- See Also:
- Constant Field Values
-
bdMaxByteValue__
private static final java.math.BigDecimal bdMaxByteValue__
-
bdMinByteValue__
private static final java.math.BigDecimal bdMinByteValue__
-
bdMaxShortValue__
private static final java.math.BigDecimal bdMaxShortValue__
-
bdMinShortValue__
private static final java.math.BigDecimal bdMinShortValue__
-
bdMaxIntValue__
private static final java.math.BigDecimal bdMaxIntValue__
-
bdMinIntValue__
private static final java.math.BigDecimal bdMinIntValue__
-
bdMaxLongValue__
private static final java.math.BigDecimal bdMaxLongValue__
-
bdMinLongValue__
private static final java.math.BigDecimal bdMinLongValue__
-
bdMaxFloatValue__
private static final java.math.BigDecimal bdMaxFloatValue__
-
bdMinFloatValue__
private static final java.math.BigDecimal bdMinFloatValue__
-
bdMaxDoubleValue__
private static final java.math.BigDecimal bdMaxDoubleValue__
-
bdMinDoubleValue__
private static final java.math.BigDecimal bdMinDoubleValue__
-
bdZero__
private static final java.math.BigDecimal bdZero__
-
bdOne__
private static final java.math.BigDecimal bdOne__
-
agent_
private final Agent agent_
-
-
Constructor Detail
-
CrossConverters
CrossConverters(Agent agent)
-
-
Method Detail
-
setObject
final java.lang.Object setObject(int targetType, boolean source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, byte source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, short source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, int source) throws SqlException
- Throws:
SqlException
-
setBooleanFromObject
final boolean setBooleanFromObject(java.lang.Object source, int sourceType) throws SqlException
- Throws:
SqlException
-
setByteFromObject
final byte setByteFromObject(java.lang.Object source, int sourceType) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, long source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, float source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, double source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.math.BigDecimal source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.sql.Date source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.sql.Time source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.sql.Timestamp source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetDriverType, java.lang.String source) throws SqlException
- Throws:
SqlException
-
getInputJdbcType
public static int getInputJdbcType(int jdbcType)
Convert the input targetJdbcType to the correct JdbcType used by CrossConverters.
-
setObject
final java.lang.Object setObject(int targetType, byte[] source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.io.Reader source, int length) throws SqlException
- Throws:
SqlException
-
setStringFromReader
private java.lang.String setStringFromReader(java.io.Reader r, int length) throws SqlException
- Throws:
SqlException
-
setObjectFromCharacterStream
final java.lang.Object setObjectFromCharacterStream(int targetType, java.io.InputStream source, java.nio.charset.Charset encoding, int length) throws SqlException
- Throws:
SqlException
-
setStringFromStream
private java.lang.String setStringFromStream(java.io.InputStream is, java.nio.charset.Charset encoding, int length) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.sql.Blob source) throws SqlException
- Throws:
SqlException
-
setObjectFromBinaryStream
final java.lang.Object setObjectFromBinaryStream(int targetType, java.io.InputStream source, int length) throws SqlException
- Throws:
SqlException
-
setBytesFromStream
private byte[] setBytesFromStream(java.io.InputStream is, int length) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.sql.Clob source) throws SqlException
- Throws:
SqlException
-
setObject
final java.lang.Object setObject(int targetType, java.lang.Object source) throws SqlException
- Throws:
SqlException
-
getBooleanFromShort
final boolean getBooleanFromShort(short source) throws SqlException
- Throws:
SqlException
-
getBooleanFromInt
final boolean getBooleanFromInt(int source) throws SqlException
- Throws:
SqlException
-
getBooleanFromLong
final boolean getBooleanFromLong(long source) throws SqlException
- Throws:
SqlException
-
getBooleanFromFloat
final boolean getBooleanFromFloat(float source) throws SqlException
- Throws:
SqlException
-
getBooleanFromDouble
final boolean getBooleanFromDouble(double source) throws SqlException
- Throws:
SqlException
-
getBooleanFromString
final boolean getBooleanFromString(java.lang.String source)
Get a boolean value from a CHAR column. In order to match the embedded driver and JCC we return false iff the CHAR value is "0" or "false".
Leading and trailing whitespace is removed from the input string before it's compared to "0" and "false". No other normalization is performed. Specifically, no case conversion is performed, so the comparison is case sensitive, and everything that doesn't exactly match "0" or "false" will be considered true.
- Parameters:
source
- the value of a CHAR column- Returns:
- false if source is "0" or "false", true otherwise
-
getByteFromShort
final byte getByteFromShort(short source) throws SqlException
- Throws:
SqlException
-
getByteFromInt
final byte getByteFromInt(int source) throws SqlException
- Throws:
SqlException
-
getByteFromLong
final byte getByteFromLong(long source) throws SqlException
- Throws:
SqlException
-
getByteFromFloat
final byte getByteFromFloat(float source) throws SqlException
- Throws:
SqlException
-
getByteFromDouble
final byte getByteFromDouble(double source) throws SqlException
- Throws:
SqlException
-
getByteFromBoolean
final byte getByteFromBoolean(boolean source) throws SqlException
- Throws:
SqlException
-
getByteFromString
final byte getByteFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getShortFromInt
final short getShortFromInt(int source) throws SqlException
- Throws:
SqlException
-
getShortFromLong
final short getShortFromLong(long source) throws SqlException
- Throws:
SqlException
-
getShortFromFloat
final short getShortFromFloat(float source) throws SqlException
- Throws:
SqlException
-
getShortFromDouble
final short getShortFromDouble(double source) throws SqlException
- Throws:
SqlException
-
getShortFromBoolean
final short getShortFromBoolean(boolean source) throws SqlException
- Throws:
SqlException
-
getShortFromString
final short getShortFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getIntFromLong
final int getIntFromLong(long source) throws SqlException
- Throws:
SqlException
-
getIntFromFloat
final int getIntFromFloat(float source) throws SqlException
- Throws:
SqlException
-
getIntFromDouble
final int getIntFromDouble(double source) throws SqlException
- Throws:
SqlException
-
getIntFromBoolean
final int getIntFromBoolean(boolean source) throws SqlException
- Throws:
SqlException
-
getIntFromString
final int getIntFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getLongFromFloat
final long getLongFromFloat(float source) throws SqlException
- Throws:
SqlException
-
getLongFromDouble
final long getLongFromDouble(double source) throws SqlException
- Throws:
SqlException
-
getLongFromBoolean
final long getLongFromBoolean(boolean source) throws SqlException
- Throws:
SqlException
-
getLongFromString
final long getLongFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getFloatFromDouble
final float getFloatFromDouble(double source) throws SqlException
- Throws:
SqlException
-
getFloatFromBoolean
final float getFloatFromBoolean(boolean source) throws SqlException
- Throws:
SqlException
-
getFloatFromString
final float getFloatFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getDoubleFromBoolean
final double getDoubleFromBoolean(boolean source) throws SqlException
- Throws:
SqlException
-
getDoubleFromString
final double getDoubleFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getBigDecimalFromString
final java.math.BigDecimal getBigDecimalFromString(java.lang.String source) throws SqlException
- Throws:
SqlException
-
getStringFromBytes
final java.lang.String getStringFromBytes(byte[] bytes) throws SqlException
- Throws:
SqlException
-
getDateFromString
final java.sql.Date getDateFromString(java.lang.String source, java.util.Calendar cal) throws SqlException
- Throws:
SqlException
-
getTimeFromString
final java.sql.Time getTimeFromString(java.lang.String source, java.util.Calendar cal) throws SqlException
- Throws:
SqlException
-
getTimestampFromString
final java.sql.Timestamp getTimestampFromString(java.lang.String source, java.util.Calendar cal) throws SqlException
- Throws:
SqlException
-
date_valueOf
private static java.sql.Date date_valueOf(java.lang.String s, java.util.Calendar cal)
Convert a string to a date in the specified calendar. Accept the same format asDate.valueOf()
.- Parameters:
s
- the string to parsecal
- the calendar (or null to use the default calendar)- Returns:
- a
Date
value that represents the date in the calendarcal
- Throws:
java.lang.IllegalArgumentException
- if the format of the string is invalid
-
initDatePortion
private static void initDatePortion(java.util.Calendar cal, java.lang.String date)
Initialize the date components of ajava.util.Calendar
from a string on the format YYYY-MM-DD. All other components are left untouched.- Parameters:
cal
- the calendar whose date components to initializedate
- a string representing a date- Throws:
java.lang.IllegalArgumentException
- if the date string is not on the format YYYY-MM-DD
-
digit
private static int digit(char ch)
Convert a character to a digit.- Parameters:
ch
- the character- Returns:
- the corresponding digit (0-9)
- Throws:
java.lang.IllegalArgumentException
- ifch
doesn't represent a digit
-
time_valueOf
private static java.sql.Time time_valueOf(java.lang.String s, java.util.Calendar cal)
Convert a string to a time in the specified calendar. Accept the same format asjava.sql.Time.valueOf()
.- Parameters:
s
- the string to parsecal
- the calendar (or null to use the default calendar)- Returns:
- a
java.sql.Time
value that represents the time in the calendarcal
- Throws:
java.lang.IllegalArgumentException
- if the format of the string is invalid
-
initTimePortion
private static void initTimePortion(java.util.Calendar cal, java.lang.String time)
Initialize the time components of ajava.util.Calendar
from a string on the format HH:MM:SS. All other components are left untouched.- Parameters:
cal
- the calendar whose time components to initializetime
- a string representing a time- Throws:
java.lang.IllegalArgumentException
- if the time string is not on the format HH:MM:SS
-
timestamp_valueOf
private static java.sql.Timestamp timestamp_valueOf(java.lang.String s, java.util.Calendar cal)
Convert a string to a timestamp in the specified calendar. Accept the same format asjava.sql.Timestamp.valueOf()
.- Parameters:
s
- the string to parsecal
- the calendar (or null to use the default calendar)- Returns:
- a
java.sql.Timestamp
value that represents the timestamp in the calendarcal
- Throws:
java.lang.IllegalArgumentException
- if the format of the string is invalid
-
parseByte
private static byte parseByte(java.lang.String s) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
parseShort
private static short parseShort(java.lang.String s) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
parseInt
private static int parseInt(java.lang.String s) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
parseLong
private static long parseLong(java.lang.String s) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
skipPadding
private static void skipPadding(java.lang.String s, int i, int length) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
-