Package org.apache.derby.client.am
Class CrossConverters
java.lang.Object
org.apache.derby.client.am.CrossConverters
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Agent
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
private static final BigDecimal
static final int
Value used to signal unknown length of data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Date
date_valueOf
(String s, 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) final BigDecimal
getBigDecimalFromString
(String source) (package private) final boolean
getBooleanFromDouble
(double source) (package private) final boolean
getBooleanFromFloat
(float source) (package private) final boolean
getBooleanFromInt
(int source) (package private) final boolean
getBooleanFromLong
(long source) (package private) final boolean
getBooleanFromShort
(short source) (package private) final boolean
getBooleanFromString
(String source) Get a boolean value from a CHAR column.(package private) final byte
getByteFromBoolean
(boolean source) (package private) final byte
getByteFromDouble
(double source) (package private) final byte
getByteFromFloat
(float source) (package private) final byte
getByteFromInt
(int source) (package private) final byte
getByteFromLong
(long source) (package private) final byte
getByteFromShort
(short source) (package private) final byte
getByteFromString
(String source) (package private) final Date
getDateFromString
(String source, Calendar cal) (package private) final double
getDoubleFromBoolean
(boolean source) (package private) final double
getDoubleFromString
(String source) (package private) final float
getFloatFromBoolean
(boolean source) (package private) final float
getFloatFromDouble
(double source) (package private) final float
getFloatFromString
(String source) static int
getInputJdbcType
(int jdbcType) Convert the input targetJdbcType to the correct JdbcType used by CrossConverters.(package private) final int
getIntFromBoolean
(boolean source) (package private) final int
getIntFromDouble
(double source) (package private) final int
getIntFromFloat
(float source) (package private) final int
getIntFromLong
(long source) (package private) final int
getIntFromString
(String source) (package private) final long
getLongFromBoolean
(boolean source) (package private) final long
getLongFromDouble
(double source) (package private) final long
getLongFromFloat
(float source) (package private) final long
getLongFromString
(String source) (package private) final short
getShortFromBoolean
(boolean source) (package private) final short
getShortFromDouble
(double source) (package private) final short
getShortFromFloat
(float source) (package private) final short
getShortFromInt
(int source) (package private) final short
getShortFromLong
(long source) (package private) final short
getShortFromString
(String source) (package private) final String
getStringFromBytes
(byte[] bytes) (package private) final Time
getTimeFromString
(String source, Calendar cal) (package private) final Timestamp
getTimestampFromString
(String source, Calendar cal) private static void
initDatePortion
(Calendar cal, String date) Initialize the date components of ajava.util.Calendar
from a string on the format YYYY-MM-DD.private static void
initTimePortion
(Calendar cal, String time) Initialize the time components of ajava.util.Calendar
from a string on the format HH:MM:SS.private static byte
private static int
private static long
private static short
parseShort
(String s) (package private) final boolean
setBooleanFromObject
(Object source, int sourceType) (package private) final byte
setByteFromObject
(Object source, int sourceType) private byte[]
setBytesFromStream
(InputStream is, int length) (package private) final Object
setObject
(int targetType, boolean source) (package private) final Object
setObject
(int targetType, byte source) (package private) final Object
setObject
(int targetType, byte[] source) (package private) final Object
setObject
(int targetType, double source) (package private) final Object
setObject
(int targetType, float source) (package private) final Object
setObject
(int targetType, int source) (package private) final Object
setObject
(int targetType, long source) (package private) final Object
setObject
(int targetType, short source) (package private) final Object
(package private) final Object
(package private) final Object
(package private) final Object
setObject
(int targetType, BigDecimal source) (package private) final Object
(package private) final Object
(package private) final Object
(package private) final Object
(package private) final Object
(package private) final Object
setObjectFromBinaryStream
(int targetType, InputStream source, int length) (package private) final Object
setObjectFromCharacterStream
(int targetType, InputStream source, Charset encoding, int length) private String
setStringFromReader
(Reader r, int length) private String
setStringFromStream
(InputStream is, Charset encoding, int length) private static void
skipPadding
(String s, int i, int length) private static Time
time_valueOf
(String s, Calendar cal) Convert a string to a time in the specified calendar.private static Timestamp
timestamp_valueOf
(String s, Calendar cal) Convert a string to a timestamp in the specified calendar.
-
Field Details
-
UNKNOWN_LENGTH
public static final int UNKNOWN_LENGTHValue used to signal unknown length of data.- See Also:
-
bdMaxByteValue__
-
bdMinByteValue__
-
bdMaxShortValue__
-
bdMinShortValue__
-
bdMaxIntValue__
-
bdMinIntValue__
-
bdMaxLongValue__
-
bdMinLongValue__
-
bdMaxFloatValue__
-
bdMinFloatValue__
-
bdMaxDoubleValue__
-
bdMinDoubleValue__
-
bdZero__
-
bdOne__
-
agent_
-
-
Constructor Details
-
CrossConverters
CrossConverters(Agent agent)
-
-
Method Details
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setBooleanFromObject
- Throws:
SqlException
-
setByteFromObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
getInputJdbcType
public static int getInputJdbcType(int jdbcType) Convert the input targetJdbcType to the correct JdbcType used by CrossConverters. -
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setStringFromReader
- Throws:
SqlException
-
setObjectFromCharacterStream
final Object setObjectFromCharacterStream(int targetType, InputStream source, Charset encoding, int length) throws SqlException - Throws:
SqlException
-
setStringFromStream
private String setStringFromStream(InputStream is, Charset encoding, int length) throws SqlException - Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObjectFromBinaryStream
final Object setObjectFromBinaryStream(int targetType, InputStream source, int length) throws SqlException - Throws:
SqlException
-
setBytesFromStream
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
setObject
- Throws:
SqlException
-
getBooleanFromShort
- Throws:
SqlException
-
getBooleanFromInt
- Throws:
SqlException
-
getBooleanFromLong
- Throws:
SqlException
-
getBooleanFromFloat
- Throws:
SqlException
-
getBooleanFromDouble
- Throws:
SqlException
-
getBooleanFromString
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
- Throws:
SqlException
-
getByteFromInt
- Throws:
SqlException
-
getByteFromLong
- Throws:
SqlException
-
getByteFromFloat
- Throws:
SqlException
-
getByteFromDouble
- Throws:
SqlException
-
getByteFromBoolean
- Throws:
SqlException
-
getByteFromString
- Throws:
SqlException
-
getShortFromInt
- Throws:
SqlException
-
getShortFromLong
- Throws:
SqlException
-
getShortFromFloat
- Throws:
SqlException
-
getShortFromDouble
- Throws:
SqlException
-
getShortFromBoolean
- Throws:
SqlException
-
getShortFromString
- Throws:
SqlException
-
getIntFromLong
- Throws:
SqlException
-
getIntFromFloat
- Throws:
SqlException
-
getIntFromDouble
- Throws:
SqlException
-
getIntFromBoolean
- Throws:
SqlException
-
getIntFromString
- Throws:
SqlException
-
getLongFromFloat
- Throws:
SqlException
-
getLongFromDouble
- Throws:
SqlException
-
getLongFromBoolean
- Throws:
SqlException
-
getLongFromString
- Throws:
SqlException
-
getFloatFromDouble
- Throws:
SqlException
-
getFloatFromBoolean
- Throws:
SqlException
-
getFloatFromString
- Throws:
SqlException
-
getDoubleFromBoolean
- Throws:
SqlException
-
getDoubleFromString
- Throws:
SqlException
-
getBigDecimalFromString
- Throws:
SqlException
-
getStringFromBytes
- Throws:
SqlException
-
getDateFromString
- Throws:
SqlException
-
getTimeFromString
- Throws:
SqlException
-
getTimestampFromString
- Throws:
SqlException
-
date_valueOf
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:
IllegalArgumentException
- if the format of the string is invalid
-
initDatePortion
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:
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:
IllegalArgumentException
- ifch
doesn't represent a digit
-
time_valueOf
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:
IllegalArgumentException
- if the format of the string is invalid
-
initTimePortion
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:
IllegalArgumentException
- if the time string is not on the format HH:MM:SS
-
timestamp_valueOf
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:
IllegalArgumentException
- if the format of the string is invalid
-
parseByte
- Throws:
NumberFormatException
-
parseShort
- Throws:
NumberFormatException
-
parseInt
- Throws:
NumberFormatException
-
parseLong
- Throws:
NumberFormatException
-
skipPadding
- Throws:
NumberFormatException
-