/** * Format a string as a Java string literal. * * @param s the string to convert * @return the Java string literal */ protected static String quote(String s) { return StringUtils.quoteJavaString(s); }
/** * Get the savepoint name for this name or id. * If the name is null, the id is used. * * @param name the name (may be null) * @param id the id * @return the savepoint name */ static String getName(String name, int id) { if (name != null) { return StringUtils.quoteJavaString(name); } return SYSTEM_SAVEPOINT_PREFIX + id; }
/** * Convert a string array to the Java source code that represents this * array. Null will be converted to 'null'. * * @param array the string array * @return the Java source code (including new String[]{}) */ public static String quoteJavaStringArray(String[] array) { if (array == null) { return "null"; } StatementBuilder buff = new StatementBuilder("new String[]{"); for (String a : array) { buff.appendExceptFirst(", "); buff.append(quoteJavaString(a)); } return buff.append('}').toString(); }
/** * Returns the value of the specified column as a java.sql.Time using a * specified time zone. * * @param columnLabel the column label * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Time getTime(String columnLabel, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getTime(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)"); } return DateTimeUtils.convertTime(get(columnLabel), calendar); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a java.sql.Timestamp. * * @param columnLabel the column label * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Timestamp getTimestamp(String columnLabel, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getTimestamp(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)"); } Value value = get(columnLabel); return DateTimeUtils.convertTimestamp(value, calendar); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a java.sql.Date using a * specified time zone. * * @param columnLabel the column label * @param calendar the calendar * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public Date getDate(String columnLabel, Calendar calendar) throws SQLException { try { if (isDebugEnabled()) { debugCode("getDate(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)"); } return DateTimeUtils.convertDate(get(columnLabel), calendar); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a BigDecimal. * * @deprecated use {@link #getBigDecimal(String)} * * @param columnLabel the column label * @param scale the scale of the returned value * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Deprecated @Override public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { try { if (isDebugEnabled()) { debugCode("getBigDecimal(" + StringUtils.quoteJavaString(columnLabel) + ", " + scale + ");"); } if (scale < 0) { throw DbException.getInvalidValueException("scale", scale); } BigDecimal bd = get(columnLabel).getBigDecimal(); return bd == null ? null : ValueDecimal.setScale(bd, scale); } catch (Exception e) { throw logAndConvert(e); } }