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 Agentagent_private static java.math.BigDecimalbdMaxByteValue__private static java.math.BigDecimalbdMaxDoubleValue__private static java.math.BigDecimalbdMaxFloatValue__private static java.math.BigDecimalbdMaxIntValue__private static java.math.BigDecimalbdMaxLongValue__private static java.math.BigDecimalbdMaxShortValue__private static java.math.BigDecimalbdMinByteValue__private static java.math.BigDecimalbdMinDoubleValue__private static java.math.BigDecimalbdMinFloatValue__private static java.math.BigDecimalbdMinIntValue__private static java.math.BigDecimalbdMinLongValue__private static java.math.BigDecimalbdMinShortValue__private static java.math.BigDecimalbdOne__private static java.math.BigDecimalbdZero__static intUNKNOWN_LENGTHValue 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.Datedate_valueOf(java.lang.String s, java.util.Calendar cal)Convert a string to a date in the specified calendar.private static intdigit(char ch)Convert a character to a digit.(package private) java.math.BigDecimalgetBigDecimalFromString(java.lang.String source)(package private) booleangetBooleanFromDouble(double source)(package private) booleangetBooleanFromFloat(float source)(package private) booleangetBooleanFromInt(int source)(package private) booleangetBooleanFromLong(long source)(package private) booleangetBooleanFromShort(short source)(package private) booleangetBooleanFromString(java.lang.String source)Get a boolean value from a CHAR column.(package private) bytegetByteFromBoolean(boolean source)(package private) bytegetByteFromDouble(double source)(package private) bytegetByteFromFloat(float source)(package private) bytegetByteFromInt(int source)(package private) bytegetByteFromLong(long source)(package private) bytegetByteFromShort(short source)(package private) bytegetByteFromString(java.lang.String source)(package private) java.sql.DategetDateFromString(java.lang.String source, java.util.Calendar cal)(package private) doublegetDoubleFromBoolean(boolean source)(package private) doublegetDoubleFromString(java.lang.String source)(package private) floatgetFloatFromBoolean(boolean source)(package private) floatgetFloatFromDouble(double source)(package private) floatgetFloatFromString(java.lang.String source)static intgetInputJdbcType(int jdbcType)Convert the input targetJdbcType to the correct JdbcType used by CrossConverters.(package private) intgetIntFromBoolean(boolean source)(package private) intgetIntFromDouble(double source)(package private) intgetIntFromFloat(float source)(package private) intgetIntFromLong(long source)(package private) intgetIntFromString(java.lang.String source)(package private) longgetLongFromBoolean(boolean source)(package private) longgetLongFromDouble(double source)(package private) longgetLongFromFloat(float source)(package private) longgetLongFromString(java.lang.String source)(package private) shortgetShortFromBoolean(boolean source)(package private) shortgetShortFromDouble(double source)(package private) shortgetShortFromFloat(float source)(package private) shortgetShortFromInt(int source)(package private) shortgetShortFromLong(long source)(package private) shortgetShortFromString(java.lang.String source)(package private) java.lang.StringgetStringFromBytes(byte[] bytes)(package private) java.sql.TimegetTimeFromString(java.lang.String source, java.util.Calendar cal)(package private) java.sql.TimestampgetTimestampFromString(java.lang.String source, java.util.Calendar cal)private static voidinitDatePortion(java.util.Calendar cal, java.lang.String date)Initialize the date components of ajava.util.Calendarfrom a string on the format YYYY-MM-DD.private static voidinitTimePortion(java.util.Calendar cal, java.lang.String time)Initialize the time components of ajava.util.Calendarfrom a string on the format HH:MM:SS.private static byteparseByte(java.lang.String s)private static intparseInt(java.lang.String s)private static longparseLong(java.lang.String s)private static shortparseShort(java.lang.String s)(package private) booleansetBooleanFromObject(java.lang.Object source, int sourceType)(package private) bytesetByteFromObject(java.lang.Object source, int sourceType)private byte[]setBytesFromStream(java.io.InputStream is, int length)(package private) java.lang.ObjectsetObject(int targetType, boolean source)(package private) java.lang.ObjectsetObject(int targetType, byte source)(package private) java.lang.ObjectsetObject(int targetType, byte[] source)(package private) java.lang.ObjectsetObject(int targetType, double source)(package private) java.lang.ObjectsetObject(int targetType, float source)(package private) java.lang.ObjectsetObject(int targetType, int source)(package private) java.lang.ObjectsetObject(int targetType, long source)(package private) java.lang.ObjectsetObject(int targetType, short source)(package private) java.lang.ObjectsetObject(int targetType, java.io.Reader source, int length)(package private) java.lang.ObjectsetObject(int targetType, java.lang.Object source)(package private) java.lang.ObjectsetObject(int targetDriverType, java.lang.String source)(package private) java.lang.ObjectsetObject(int targetType, java.math.BigDecimal source)(package private) java.lang.ObjectsetObject(int targetType, java.sql.Blob source)(package private) java.lang.ObjectsetObject(int targetType, java.sql.Clob source)(package private) java.lang.ObjectsetObject(int targetType, java.sql.Date source)(package private) java.lang.ObjectsetObject(int targetType, java.sql.Time source)(package private) java.lang.ObjectsetObject(int targetType, java.sql.Timestamp source)(package private) java.lang.ObjectsetObjectFromBinaryStream(int targetType, java.io.InputStream source, int length)(package private) java.lang.ObjectsetObjectFromCharacterStream(int targetType, java.io.InputStream source, java.nio.charset.Charset encoding, int length)private java.lang.StringsetStringFromReader(java.io.Reader r, int length)private java.lang.StringsetStringFromStream(java.io.InputStream is, java.nio.charset.Charset encoding, int length)private static voidskipPadding(java.lang.String s, int i, int length)private static java.sql.Timetime_valueOf(java.lang.String s, java.util.Calendar cal)Convert a string to a time in the specified calendar.private static java.sql.Timestamptimestamp_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
Datevalue 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.Calendarfrom 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- ifchdoesn'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.Timevalue 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.Calendarfrom 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.Timestampvalue 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
-
-