/** * Determines whether this column is of a numeric type. * * @return <code>true</code> if this column is of a numeric type */ public boolean isOfNumericType() { return TypeMap.isNumericType(getTypeCode()); }
/** * Determines whether the given default spec is a non-empty spec that shall be used in a DEFAULT * expression. E.g. if the spec is an empty string and the type is a numeric type, then it is * no valid default value whereas if it is a string type, then it is valid. * * @param defaultSpec The default value spec * @param typeCode The JDBC type code * @return <code>true</code> if the default value spec is valid */ protected boolean isValidDefaultValue(String defaultSpec, int typeCode) { return (defaultSpec != null) && ((defaultSpec.length() > 0) || (!TypeMap.isNumericType(typeCode) && !TypeMap.isDateTimeType(typeCode))); }
/** * {@inheritDoc} */ public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(17, 37); builder.append(_name); builder.append(_primaryKey); builder.append(_required); builder.append(_autoIncrement); builder.append(_typeCode); builder.append(_type); builder.append(_scale); builder.append(getParsedDefaultValue()); if (!TypeMap.isNumericType(_typeCode)) { builder.append(_size); } return builder.toHashCode(); }
else if (TypeMap.isNumericType(targetTypeCode))
/** * Prints the default value of the column. * * @param defaultValue The default value * @param typeCode The type code to write the default value for */ protected void printDefaultValue(Object defaultValue, int typeCode) throws IOException { if (defaultValue != null) { boolean shouldUseQuotes = !TypeMap.isNumericType(typeCode); if (shouldUseQuotes) { // characters are only escaped when within a string literal print(getPlatformInfo().getValueQuoteToken()); print(escapeStringValue(defaultValue.toString())); print(getPlatformInfo().getValueQuoteToken()); } else { print(defaultValue.toString()); } } }
/** * {@inheritDoc} */ protected void printDefaultValue(Object defaultValue, int typeCode) throws IOException { if (defaultValue != null) { String defaultValueStr = defaultValue.toString(); boolean shouldUseQuotes = !TypeMap.isNumericType(typeCode) && !defaultValueStr.startsWith("TO_DATE("); if (shouldUseQuotes) { // characters are only escaped when within a string literal print(getPlatformInfo().getValueQuoteToken()); print(escapeStringValue(defaultValueStr)); print(getPlatformInfo().getValueQuoteToken()); } else { print(defaultValueStr); } } }
if (TypeMap.isNumericType(sourceColumn.getTypeCode()) && "VARCHAR".equalsIgnoreCase(targetNativeType))
/** * {@inheritDoc} */ protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException { if (ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn) || ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn)) { String targetNativeType = getNativeType(targetColumn); // Derby currently has the limitation that it cannot convert numeric values // to VARCHAR, though it can convert them to CHAR if (TypeMap.isNumericType(sourceColumn.getTypeCode()) && "VARCHAR".equalsIgnoreCase(targetNativeType)) { targetNativeType = "CHAR"; } print("CAST ("); printIdentifier(getColumnName(sourceColumn)); print(" AS "); print(getSqlType(targetColumn, targetNativeType)); print(")"); } else { printIdentifier(getColumnName(sourceColumn)); } } }