Top Description Fields Constructors Methods
org.hsqldb.types

public Class CharacterType

extends Type
Class Inheritance
Known Direct Subclasses
org.hsqldb.types.ClobType
Imports
java.math.BigDecimal, org.hsqldb.OpTypes, .Session, .SessionInterface, .Tokens, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.ArrayUtil, .StringConverter, .StringUtil

Type subclass for CHARACTER, VARCHAR, etc.

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.9.0
Version
2.7.2

Field Summary

Modifier and TypeField and Description
pack-priv static CharacterType[]
pack-priv final Charset
pack-priv final Collation
pack-priv static final int
pack-priv static final int
private static final int
public static final long
pack-priv final String
Inherited from org.hsqldb.types.Type:
emptyArrayjdbcConvertTypesOTHERprecisionscaleSQL_ALL_TYPESSQL_ARRAY_ALL_TYPESSQL_BIGINTSQL_BINARYSQL_BINARY_16SQL_BINARY_DEFAULTSQL_BITSQL_BIT_VARYINGSQL_BIT_VARYING_MAX_LENGTHSQL_BLOBSQL_BOOLEANSQL_CHARSQL_CHAR_DEFAULTSQL_CHAR_UUIDSQL_CLOBSQL_DATESQL_DECIMALSQL_DECIMAL_BIGINT_SQRSQL_DECIMAL_DEFAULTSQL_DOUBLESQL_GUIDSQL_INTEGERSQL_INTERVAL_DAYSQL_INTERVAL_DAY_MAX_PRECISIONSQL_INTERVAL_DAY_TO_HOURSQL_INTERVAL_DAY_TO_MINUTESQL_INTERVAL_DAY_TO_SECONDSQL_INTERVAL_DAY_TO_SECOND_MAX_PRECISIONSQL_INTERVAL_HOURSQL_INTERVAL_HOUR_MAX_PRECISIONSQL_INTERVAL_HOUR_TO_MINUTESQL_INTERVAL_HOUR_TO_SECONDSQL_INTERVAL_MINUTESQL_INTERVAL_MINUTE_MAX_PRECISIONSQL_INTERVAL_MINUTE_TO_SECONDSQL_INTERVAL_MONTHSQL_INTERVAL_MONTH_MAX_PRECISIONSQL_INTERVAL_SECONDSQL_INTERVAL_SECOND_MAX_FRACTIONSQL_INTERVAL_SECOND_MAX_FRACTION_MAX_PRECISIONSQL_INTERVAL_SECOND_MAX_PRECISIONSQL_INTERVAL_YEARSQL_INTERVAL_YEAR_MAX_PRECISIONSQL_INTERVAL_YEAR_TO_MONTHSQL_INTERVAL_YEAR_TO_MONTH_MAX_PRECISIONSQL_NUMERICSQL_SMALLINTSQL_TIMESQL_TIME_MAXSQL_TIME_WITH_TIME_ZONESQL_TIME_WITH_TIME_ZONE_MAXSQL_TIMESTAMPSQL_TIMESTAMP_NO_FRACTIONSQL_TIMESTAMP_WITH_TIME_ZONESQL_TIMESTAMP_WITH_TIME_ZONE_MAXSQL_VARBINARYSQL_VARBINARY_DEFAULTSQL_VARCHARSQL_VARCHAR_DEFAULTSQL_VARCHAR_LONGTINYINTtypeAliasestypeCodetypeComparisonGrouptypeDataGrouptypeNamesuserTypeModifier

Constructor Summary

AccessConstructor and Description
public
CharacterType(Collation collation, int type, long precision)

public
CharacterType(int type, long precision)

Always ASCII collation

public
CharacterType(String name, long precision)

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public int
canMoveFrom(Type otherType)

Overrides org.hsqldb.types.Type.canMoveFrom.

When canConvertFrom() is true, can convert without changing the object

public Object
castOrConvertToType(SessionInterface session, Object a, Type otherType, boolean cast)

public Object
castToType(SessionInterface session, Object a, Type otherType)

Overrides org.hsqldb.types.Type.castToType.

Explicit casts are handled by this method.

public int
compare(Session session, Object a, Object b)

Implements abstract org.hsqldb.types.Type.compare.

public int
compare(Session session, Object a, Object b, int opType)

Overrides org.hsqldb.types.Type.compare.

public Object
public Object
public Object
convertToDefaultType(SessionInterface session, Object a)

Implements abstract org.hsqldb.types.Type.convertToDefaultType.

Relaxes SQL parameter type enforcement, allowing long strings.

public void
public String
public String
public Object
convertToType(SessionInterface session, Object a, Type otherType)

Implements abstract org.hsqldb.types.Type.convertToType.

Same as castToType except for CHARACTER values.

public Object
convertToTypeJDBC(SessionInterface session, Object a, Type otherType)

Overrides org.hsqldb.types.Type.convertToTypeJDBC.

Convert type for JDBC reads.

public Object
public int
public boolean
equals(Object other)

Overrides org.hsqldb.types.Type.equals.

can add collation and charset equality

public Type
getAggregateType(Type other)

Implements abstract org.hsqldb.types.Type.getAggregateType.

Common type used in comparison operations.

public Charset
public Type
getCharacterType(long length)

public static CharacterType
getCharacterType(int type, long length)

public static CharacterType
getCharacterType(int type, long length, Collation collation)

public Collation
public Type
getCombinedType(Session session, Type other, int operation)

Implements abstract org.hsqldb.types.Type.getCombinedType.

For concatenation

public String
getDefinition()

Implements abstract org.hsqldb.types.Type.getDefinition.

Returns the full definition of the type, including parameters

public String
getFullNameString()

Overrides org.hsqldb.types.Type.getFullNameString.

Returns the name of the type

public Class<T>
public String
getJDBCClassName()

Implements abstract org.hsqldb.types.Type.getJDBCClassName.

Returns the JDBC class name of type, if it exists, otherwise the HSQLDB class name.

public int
getJDBCTypeCode()

Implements abstract org.hsqldb.types.Type.getJDBCTypeCode.

Returns the JDBC type number of type, if it exists, otherwise the HSQLDB / SQL type.

public long
public String
getNameString()

Implements abstract org.hsqldb.types.Type.getNameString.

Returns the name of the type

private String
public static int
getRightTrimSize(String s, char trim)

public int
getSQLGenericTypeCode()

Overrides org.hsqldb.types.Type.getSQLGenericTypeCode.

Returns the generic SQL CLI type number of type, if it exists, otherwise the HSQLDB type.

public boolean
public Object
lower(Session session, Object data)

public Boolean
match(Session session, String string, String[] array)

Matches the string against array containing part strings.

public Object
overlay(SessionInterface session, Object data, Object overlay, long offset, long length, boolean hasLength)

public static String
padString(String s, int length)

public long
position(SessionInterface session, Object data, Object otherData, Type otherType, long offset)

public int
public boolean
public long
size(SessionInterface session, Object data)

public Object
substring(SessionInterface session, Object data, long offset, long length, boolean hasLength, boolean trailing)

public static LongPair
substringParams(long dataLength, long start, long length, boolean hasLength)

length must not be negative

public Object
trim(SessionInterface session, Object data, char trim, boolean leading, boolean trailing)

public Object
upper(Session session, Object data)

Memory limits apply to Upper and Lower implementations with Clob data

Inherited from org.hsqldb.types.Type:
absoluteacceptsFractionalPrecisionacceptsScaleaddarrayLimitCardinalitycanBeAssignedFromcanCompareDirectcardinalitycollectionBaseTypecomparecompareToTypeRangecompileconvertSQLToJavaconvertToJSONdivideduplicategetAggregateTypegetCatalogNamegetChangeTimestampgetComponentsgetDefaultArrayTypegetDefaultTypegetDefaultTypeWithSizegetDegreegetHSQLDBTypeCodegetJDBCPrecisiongetJDBCScalegetJDBCTypeCodegetMaxScalegetNamegetOwnergetPrecisionRadixgetReferencesgetSchemaNamegetSQLgetTypegetTypegetTypegetTypeDefinitiongetTypeForJDBCConvertTokengetTypeNrhashCodehashCodeisArrayTypeisBinaryTypeisBitTypeisBooleanTypeisDateOrTimestampTypeisDateTimeTypeisDateTimeTypeWithZoneisDecimalTypeisDistinctTypeisDomainTypeisExactNumberTypeisIntegralTypeisIntervalDaySecondTypeisIntervalTypeisIntervalYearMonthTypeisLobTypeisMultisetTypeisNegativeisNumberTypeisObjectTypeisRowTypeisStructuredTypeisSupportedSQLTypeisTimestampTypeisTimeTypeisUUIDTypematchesmultiplynegatesubtract

Field Detail

charArrayback to summary
pack-priv static CharacterType[] charArray
charsetback to summary
pack-priv final Charset charset
collationback to summary
pack-priv final Collation collation
defaultCharPrecisionback to summary
pack-priv static final int defaultCharPrecision
defaultVarcharPrecisionback to summary
pack-priv static final int defaultVarcharPrecision
fixedTypesLengthback to summary
private static final int fixedTypesLength
maxCharPrecisionback to summary
public static final long maxCharPrecision
nameStringback to summary
pack-priv final String nameString

Constructor Detail

CharacterTypeback to summary
public CharacterType(Collation collation, int type, long precision)
CharacterTypeback to summary
public CharacterType(int type, long precision)

Always ASCII collation

CharacterTypeback to summary
public CharacterType(String name, long precision)

Method Detail

acceptsPrecisionback to summary
public boolean acceptsPrecision()

Overrides org.hsqldb.types.Type.acceptsPrecision.

canConvertFromback to summary
public boolean canConvertFrom(Type otherType)

Implements abstract org.hsqldb.types.Type.canConvertFrom.

canMoveFromback to summary
public int canMoveFrom(Type otherType)

Overrides org.hsqldb.types.Type.canMoveFrom.

Doc from org.hsqldb.types.Type.canMoveFrom.

When canConvertFrom() is true, can convert without changing the object

castOrConvertToTypeback to summary
public Object castOrConvertToType(SessionInterface session, Object a, Type otherType, boolean cast)
castToTypeback to summary
public Object castToType(SessionInterface session, Object a, Type otherType)

Overrides org.hsqldb.types.Type.castToType.

Doc from org.hsqldb.types.Type.castToType.

Explicit casts are handled by this method. SQL standard 6.12 rules for enforcement of size, precision and scale are implemented. For CHARACTER values, it performs truncation in all cases of long strings.

compareback to summary
public int compare(Session session, Object a, Object b)

Implements abstract org.hsqldb.types.Type.compare.

compareback to summary
public int compare(Session session, Object a, Object b, int opType)

Overrides org.hsqldb.types.Type.compare.

concatback to summary
public Object concat(Session session, Object a, Object b)

Overrides org.hsqldb.types.Type.concat.

convertJavaToSQLback to summary
public Object convertJavaToSQL(SessionInterface session, Object a)

Overrides org.hsqldb.types.Type.convertJavaToSQL.

convertToDefaultTypeback to summary
public Object convertToDefaultType(SessionInterface session, Object a)

Implements abstract org.hsqldb.types.Type.convertToDefaultType.

Relaxes SQL parameter type enforcement, allowing long strings.

convertToJSONback to summary
public void convertToJSON(Object a, StringBuilder sb)

Overrides org.hsqldb.types.Type.convertToJSON.

convertToSQLStringback to summary
public String convertToSQLString(Object a)

Implements abstract org.hsqldb.types.Type.convertToSQLString.

convertToStringback to summary
public String convertToString(Object a)

Implements abstract org.hsqldb.types.Type.convertToString.

convertToTypeback to summary
public Object convertToType(SessionInterface session, Object a, Type otherType)

Implements abstract org.hsqldb.types.Type.convertToType.

Doc from org.hsqldb.types.Type.convertToType.

Same as castToType except for CHARACTER values. Perform string truncation of trailing spaces only. For other long strings, it raises an exception.

convertToTypeJDBCback to summary
public Object convertToTypeJDBC(SessionInterface session, Object a, Type otherType)

Overrides org.hsqldb.types.Type.convertToTypeJDBC.

Doc from org.hsqldb.types.Type.convertToTypeJDBC.

Convert type for JDBC reads. Same as convertToType, but supports non-standard SQL conversions supported by JDBC

convertToTypeLimitsback to summary
public Object convertToTypeLimits(SessionInterface session, Object a)

Implements abstract org.hsqldb.types.Type.convertToTypeLimits.

displaySizeback to summary
public int displaySize()

Implements abstract org.hsqldb.types.Type.displaySize.

equalsback to summary
public boolean equals(Object other)

Overrides org.hsqldb.types.Type.equals.

can add collation and charset equality

getAggregateTypeback to summary
public Type getAggregateType(Type other)

Implements abstract org.hsqldb.types.Type.getAggregateType.

Doc from org.hsqldb.types.Type.getAggregateType.

Common type used in comparison operations. other must be comparable with this.

getCharacterSetback to summary
public Charset getCharacterSet()

Overrides org.hsqldb.types.Type.getCharacterSet.

getCharacterTypeback to summary
public Type getCharacterType(long length)
getCharacterTypeback to summary
public static CharacterType getCharacterType(int type, long length)
getCharacterTypeback to summary
public static CharacterType getCharacterType(int type, long length, Collation collation)
getCollationback to summary
public Collation getCollation()

Overrides org.hsqldb.types.Type.getCollation.

getCombinedTypeback to summary
public Type getCombinedType(Session session, Type other, int operation)

Implements abstract org.hsqldb.types.Type.getCombinedType.

For concatenation

getDefinitionback to summary
public String getDefinition()

Implements abstract org.hsqldb.types.Type.getDefinition.

Doc from org.hsqldb.types.Type.getDefinition.

Returns the full definition of the type, including parameters

getFullNameStringback to summary
public String getFullNameString()

Overrides org.hsqldb.types.Type.getFullNameString.

Doc from org.hsqldb.types.Type.getFullNameString.

Returns the name of the type

getJDBCClassback to summary
public Class<T> getJDBCClass()

Implements abstract org.hsqldb.types.Type.getJDBCClass.

getJDBCClassNameback to summary
public String getJDBCClassName()

Implements abstract org.hsqldb.types.Type.getJDBCClassName.

Doc from org.hsqldb.types.Type.getJDBCClassName.

Returns the JDBC class name of type, if it exists, otherwise the HSQLDB class name.

getJDBCTypeCodeback to summary
public int getJDBCTypeCode()

Implements abstract org.hsqldb.types.Type.getJDBCTypeCode.

Doc from org.hsqldb.types.Type.getJDBCTypeCode.

Returns the JDBC type number of type, if it exists, otherwise the HSQLDB / SQL type.

getMaxPrecisionback to summary
public long getMaxPrecision()

Overrides org.hsqldb.types.Type.getMaxPrecision.

getNameStringback to summary
public String getNameString()

Implements abstract org.hsqldb.types.Type.getNameString.

Doc from org.hsqldb.types.Type.getNameString.

Returns the name of the type

getNameStringPrivateback to summary
private String getNameStringPrivate()
getRightTrimSizeback to summary
public static int getRightTrimSize(String s, char trim)
getSQLGenericTypeCodeback to summary
public int getSQLGenericTypeCode()

Overrides org.hsqldb.types.Type.getSQLGenericTypeCode.

Doc from org.hsqldb.types.Type.getSQLGenericTypeCode.

Returns the generic SQL CLI type number of type, if it exists, otherwise the HSQLDB type. The generic type is returned for DATETIME and INTERVAL types.

isCharacterTypeback to summary
public boolean isCharacterType()

Overrides org.hsqldb.types.Type.isCharacterType.

lowerback to summary
public Object lower(Session session, Object data)
matchback to summary
public Boolean match(Session session, String string, String[] array)

Matches the string against array containing part strings. Null element in array indicates skip one character. Empty string in array indicates skip any number of characters.

overlayback to summary
public Object overlay(SessionInterface session, Object data, Object overlay, long offset, long length, boolean hasLength)
padStringback to summary
public static String padString(String s, int length)
positionback to summary
public long position(SessionInterface session, Object data, Object otherData, Type otherType, long offset)
precedenceDegreeback to summary
public int precedenceDegree(Type other)

Overrides org.hsqldb.types.Type.precedenceDegree.

requiresPrecisionback to summary
public boolean requiresPrecision()

Overrides org.hsqldb.types.Type.requiresPrecision.

sizeback to summary
public long size(SessionInterface session, Object data)
substringback to summary
public Object substring(SessionInterface session, Object data, long offset, long length, boolean hasLength, boolean trailing)
substringParamsback to summary
public static LongPair substringParams(long dataLength, long start, long length, boolean hasLength)

length must not be negative

trimback to summary
public Object trim(SessionInterface session, Object data, char trim, boolean leading, boolean trailing)
upperback to summary
public Object upper(Session session, Object data)

Memory limits apply to Upper and Lower implementations with Clob data