Class CrossConverters
java.lang.Object
org.apache.derby.client.am.CrossConverters
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Agentprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalprivate static final BigDecimalstatic final intValue used to signal unknown length of data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Datedate_valueOf(String s, 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) final BigDecimalgetBigDecimalFromString(String source) (package private) final booleangetBooleanFromDouble(double source) (package private) final booleangetBooleanFromFloat(float source) (package private) final booleangetBooleanFromInt(int source) (package private) final booleangetBooleanFromLong(long source) (package private) final booleangetBooleanFromShort(short source) (package private) final booleangetBooleanFromString(String source) Get a boolean value from a CHAR column.(package private) final bytegetByteFromBoolean(boolean source) (package private) final bytegetByteFromDouble(double source) (package private) final bytegetByteFromFloat(float source) (package private) final bytegetByteFromInt(int source) (package private) final bytegetByteFromLong(long source) (package private) final bytegetByteFromShort(short source) (package private) final bytegetByteFromString(String source) (package private) final DategetDateFromString(String source, Calendar cal) (package private) final doublegetDoubleFromBoolean(boolean source) (package private) final doublegetDoubleFromString(String source) (package private) final floatgetFloatFromBoolean(boolean source) (package private) final floatgetFloatFromDouble(double source) (package private) final floatgetFloatFromString(String source) static intgetInputJdbcType(int jdbcType) Convert the input targetJdbcType to the correct JdbcType used by CrossConverters.(package private) final intgetIntFromBoolean(boolean source) (package private) final intgetIntFromDouble(double source) (package private) final intgetIntFromFloat(float source) (package private) final intgetIntFromLong(long source) (package private) final intgetIntFromString(String source) (package private) final longgetLongFromBoolean(boolean source) (package private) final longgetLongFromDouble(double source) (package private) final longgetLongFromFloat(float source) (package private) final longgetLongFromString(String source) (package private) final shortgetShortFromBoolean(boolean source) (package private) final shortgetShortFromDouble(double source) (package private) final shortgetShortFromFloat(float source) (package private) final shortgetShortFromInt(int source) (package private) final shortgetShortFromLong(long source) (package private) final shortgetShortFromString(String source) (package private) final StringgetStringFromBytes(byte[] bytes) (package private) final TimegetTimeFromString(String source, Calendar cal) (package private) final TimestampgetTimestampFromString(String source, Calendar cal) private static voidinitDatePortion(Calendar cal, String date) Initialize the date components of ajava.util.Calendarfrom a string on the format YYYY-MM-DD.private static voidinitTimePortion(Calendar cal, String time) Initialize the time components of ajava.util.Calendarfrom a string on the format HH:MM:SS.private static byteprivate static intprivate static longprivate static shortparseShort(String s) (package private) final booleansetBooleanFromObject(Object source, int sourceType) (package private) final bytesetByteFromObject(Object source, int sourceType) private byte[]setBytesFromStream(InputStream is, int length) (package private) final ObjectsetObject(int targetType, boolean source) (package private) final ObjectsetObject(int targetType, byte source) (package private) final ObjectsetObject(int targetType, byte[] source) (package private) final ObjectsetObject(int targetType, double source) (package private) final ObjectsetObject(int targetType, float source) (package private) final ObjectsetObject(int targetType, int source) (package private) final ObjectsetObject(int targetType, long source) (package private) final ObjectsetObject(int targetType, short source) (package private) final Object(package private) final Object(package private) final Object(package private) final ObjectsetObject(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 ObjectsetObjectFromBinaryStream(int targetType, InputStream source, int length) (package private) final ObjectsetObjectFromCharacterStream(int targetType, InputStream source, Charset encoding, int length) private StringsetStringFromReader(Reader r, int length) private StringsetStringFromStream(InputStream is, Charset encoding, int length) private static voidskipPadding(String s, int i, int length) private static Timetime_valueOf(String s, Calendar cal) Convert a string to a time in the specified calendar.private static Timestamptimestamp_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
Datevalue 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.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:
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- ifchdoesn'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.Timevalue 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.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:
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.Timestampvalue 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
-