Class BinaryType
- java.lang.Object
-
- org.hsqldb.types.Type
-
- org.hsqldb.types.BinaryType
-
- All Implemented Interfaces:
- java.lang.Cloneable, SchemaObject
public class BinaryType extends Type
Type implementation for BINARY, VARBINARY and (part) BLOB.SQL:2008 Standard specifies silent truncation of zero bytes at the end of the binary strings used for assignment and contatenation.
* A binary string of type BINARY VALYING and BLOB when assigned to a column of similar type but shorter maximum length.
The behaviour is similar to trimming of space characters from strings of CHARACTER VARYING and CLOB types.
In most real-world use-cases, all the bytes of variable-length binary values stored in a database are significant and should not be discarded.
HSQLDB follows the Standard completely, despite this inadequecy.
Comparison of binary values follows the Standard. When two values are not the same length and all the bytes of the shorter value equal the initial sequence of bytes of the longer value, then the shorter value is the smaller. The Standard treats this determination as implementation dependent.
BIT types, which were part of the SQL:1999, can be converted to and from BINARY. The BIT strings may be padded with zero bits for byte alignment.
As an extension to the Standard, HSQLDB supports cast from CHARACTER types to BINARY. The length of the string must be even and all character must be hexadecimal characters.
- Since:
- 1.9.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hsqldb.types.Type
Type.TypedComparator
-
Nested classes/interfaces inherited from interface org.hsqldb.SchemaObject
SchemaObject.ConstraintTypes, SchemaObject.Deferable, SchemaObject.Nullability, SchemaObject.ParameterModes, SchemaObject.ReferentialAction, SchemaObject.ViewCheckModes
-
-
Field Summary
Fields Modifier and Type Field and Description static longmaxBinaryPrecision-
Fields inherited from class org.hsqldb.types.Type
emptyArray, jdbcConvertTypes, OTHER, precision, scale, SQL_ALL_TYPES, SQL_ARRAY_ALL_TYPES, SQL_BIGINT, SQL_BINARY, SQL_BINARY_16, SQL_BINARY_DEFAULT, SQL_BIT, SQL_BIT_VARYING, SQL_BIT_VARYING_MAX_LENGTH, SQL_BLOB, SQL_BOOLEAN, SQL_CHAR, SQL_CHAR_16, SQL_CHAR_DEFAULT, SQL_CLOB, SQL_DATE, SQL_DECIMAL, SQL_DECIMAL_BIGINT_SQR, SQL_DECIMAL_DEFAULT, SQL_DOUBLE, SQL_INTEGER, SQL_INTERVAL_DAY, SQL_INTERVAL_DAY_MAX_PRECISION, SQL_INTERVAL_DAY_TO_HOUR, SQL_INTERVAL_DAY_TO_MINUTE, SQL_INTERVAL_DAY_TO_SECOND, SQL_INTERVAL_DAY_TO_SECOND_MAX_PRECISION, SQL_INTERVAL_HOUR, SQL_INTERVAL_HOUR_MAX_PRECISION, SQL_INTERVAL_HOUR_TO_MINUTE, SQL_INTERVAL_HOUR_TO_SECOND, SQL_INTERVAL_MINUTE, SQL_INTERVAL_MINUTE_MAX_PRECISION, SQL_INTERVAL_MINUTE_TO_SECOND, SQL_INTERVAL_MONTH, SQL_INTERVAL_MONTH_MAX_PRECISION, SQL_INTERVAL_SECOND, SQL_INTERVAL_SECOND_MAX_FRACTION, SQL_INTERVAL_SECOND_MAX_FRACTION_MAX_PRECISION, SQL_INTERVAL_SECOND_MAX_PRECISION, SQL_INTERVAL_YEAR, SQL_INTERVAL_YEAR_MAX_PRECISION, SQL_INTERVAL_YEAR_TO_MONTH, SQL_INTERVAL_YEAR_TO_MONTH_MAX_PRECISION, SQL_NUMERIC, SQL_SMALLINT, SQL_TIME, SQL_TIME_WITH_TIME_ZONE, SQL_TIMESTAMP, SQL_TIMESTAMP_NO_FRACTION, SQL_TIMESTAMP_WITH_TIME_ZONE, SQL_VARBINARY, SQL_VARBINARY_DEFAULT, SQL_VARCHAR, SQL_VARCHAR_DEFAULT, TINYINT, typeAliases, typeCode, typeComparisonGroup, typeDataGroup, typeNames, userTypeModifier
-
Fields inherited from interface org.hsqldb.SchemaObject
ASSERTION, CATALOG, CHARSET, COLLATION, COLUMN, CONSTRAINT, CURSOR, DOMAIN, FUNCTION, GRANTEE, INDEX, LABEL, PARAMETER, PROCEDURE, ROUTINE, SCHEMA, SEARCH, SEQUENCE, SERVER, SPECIFIC_ROUTINE, SUBQUERY, TABLE, TRANSITION, TRIGGER, TYPE, VARIABLE, VIEW, WRAPPER
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanacceptsPrecision()booleancanConvertFrom(Type otherType)intcanMoveFrom(Type otherType)Can convert without changing the objectjava.lang.ObjectcastToType(SessionInterface session, java.lang.Object a, Type otherType)Explicit casts are handled by this method.intcompare(Session session, java.lang.Object a, java.lang.Object b)java.lang.Objectconcat(Session session, java.lang.Object a, java.lang.Object b)java.lang.ObjectconvertJavaToSQL(SessionInterface session, java.lang.Object a)java.lang.ObjectconvertSQLToJava(SessionInterface session, java.lang.Object a)java.lang.ObjectconvertToDefaultType(SessionInterface session, java.lang.Object a)Converts the object to the given type without limit checks.java.lang.StringconvertToSQLString(java.lang.Object a)java.lang.StringconvertToString(java.lang.Object a)java.lang.ObjectconvertToType(SessionInterface session, java.lang.Object a, Type otherType)Same as castToType except for CHARACTER values.java.lang.ObjectconvertToTypeLimits(SessionInterface session, java.lang.Object a)intdisplaySize()TypegetAggregateType(Type other)Common type used in comparison opertions.static BinaryTypegetBinaryType(int type, long precision)TypegetCombinedType(Session session, Type other, int operation)Returns type for concatjava.lang.StringgetDefinition()Returns the full definition of the type, including parametersjava.lang.ClassgetJDBCClass()java.lang.StringgetJDBCClassName()Returns the JDBC class name of type, if it exists, otherwise the HSQLDB class name.intgetJDBCTypeCode()Returns the JDBC type number of type, if it exists, otherwise the HSQLDB / SQL type.longgetMaxPrecision()java.lang.StringgetNameFullString()java.lang.StringgetNameString()Returns the name of the typebooleanisBinaryType()BlobDataoverlay(Session session, BlobData data, BlobData overlay, long offset, long length, boolean hasLength)longposition(SessionInterface session, BlobData data, BlobData otherData, Type otherType, long offset)intprecedenceDegree(Type other)relaxes the SQL standard list to avoid problems with covnersion of literals and java method parameter type issuesbooleanrequiresPrecision()BlobDatasubstring(SessionInterface session, BlobData data, long offset, long length, boolean hasLength)BlobDatatrim(Session session, BlobData data, int trim, boolean leading, boolean trailing)-
Methods inherited from class org.hsqldb.types.Type
absolute, acceptsFractionalPrecision, acceptsScale, add, arrayLimitCardinality, canBeAssignedFrom, cardinality, collectionBaseType, compare, compare, compareToTypeRange, compile, convertToTypeJDBC, divide, duplicate, equals, getAggregateType, getCatalogName, getChangeTimestamp, getCharacterSet, getCollation, getComponents, getDefaultArrayType, getDefaultType, getDefaultTypeWithSize, getFullNameString, getHSQLDBTypeCode, getJDBCPrecision, getJDBCScale, getJDBCTypeCode, getMaxScale, getName, getOwner, getPrecisionRadix, getReferences, getSchemaName, getSQL, getSQLGenericTypeCode, getType, getType, getType, getTypeDefinition, getTypeForJDBCConvertToken, getTypeNr, hashCode, isArrayType, isBitType, isBooleanType, isCharacterType, isDateOrTimestampType, isDateTimeType, isDateTimeTypeWithZone, isDecimalType, isDistinctType, isDomainType, isExactNumberType, isIntegralType, isIntervalType, isLobType, isMultisetType, isNumberType, isObjectType, isRowType, isStructuredType, isSupportedSQLType, matches, multiply, negate, newComparator, subtract
-
-
-
-
Field Detail
-
maxBinaryPrecision
public static final long maxBinaryPrecision
- See Also:
- Constant Field Values
-
-
Method Detail
-
displaySize
public int displaySize()
- Specified by:
displaySizein classType
-
getJDBCTypeCode
public int getJDBCTypeCode()
Description copied from class:TypeReturns the JDBC type number of type, if it exists, otherwise the HSQLDB / SQL type.- Specified by:
getJDBCTypeCodein classType
-
getJDBCClass
public java.lang.Class getJDBCClass()
- Specified by:
getJDBCClassin classType
-
getJDBCClassName
public java.lang.String getJDBCClassName()
Description copied from class:TypeReturns the JDBC class name of type, if it exists, otherwise the HSQLDB class name.- Specified by:
getJDBCClassNamein classType
-
getNameString
public java.lang.String getNameString()
Description copied from class:TypeReturns the name of the type- Specified by:
getNameStringin classType
-
getNameFullString
public java.lang.String getNameFullString()
-
getDefinition
public java.lang.String getDefinition()
Description copied from class:TypeReturns the full definition of the type, including parameters- Specified by:
getDefinitionin classType
-
isBinaryType
public boolean isBinaryType()
- Overrides:
isBinaryTypein classType
-
acceptsPrecision
public boolean acceptsPrecision()
- Overrides:
acceptsPrecisionin classType
-
getMaxPrecision
public long getMaxPrecision()
- Overrides:
getMaxPrecisionin classType
-
requiresPrecision
public boolean requiresPrecision()
- Overrides:
requiresPrecisionin classType
-
precedenceDegree
public int precedenceDegree(Type other)
relaxes the SQL standard list to avoid problems with covnersion of literals and java method parameter type issues- Overrides:
precedenceDegreein classType
-
getAggregateType
public Type getAggregateType(Type other)
Description copied from class:TypeCommon type used in comparison opertions. other must be comparable with this.- Specified by:
getAggregateTypein classType
-
getCombinedType
public Type getCombinedType(Session session, Type other, int operation)
Returns type for concat- Specified by:
getCombinedTypein classType
-
compare
public int compare(Session session, java.lang.Object a, java.lang.Object b)
-
convertToTypeLimits
public java.lang.Object convertToTypeLimits(SessionInterface session, java.lang.Object a)
- Specified by:
convertToTypeLimitsin classType
-
castToType
public java.lang.Object castToType(SessionInterface session, java.lang.Object a, Type otherType)
Description copied from class:TypeExplicit 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.- Overrides:
castToTypein classType
-
convertToType
public java.lang.Object convertToType(SessionInterface session, java.lang.Object a, Type otherType)
Description copied from class:TypeSame as castToType except for CHARACTER values. Perform string truncation of trailing spaces only. For other long strings, it raises an exception.- Specified by:
convertToTypein classType
-
convertJavaToSQL
public java.lang.Object convertJavaToSQL(SessionInterface session, java.lang.Object a)
- Overrides:
convertJavaToSQLin classType
-
convertSQLToJava
public java.lang.Object convertSQLToJava(SessionInterface session, java.lang.Object a)
- Overrides:
convertSQLToJavain classType
-
convertToDefaultType
public java.lang.Object convertToDefaultType(SessionInterface session, java.lang.Object a)
Description copied from class:TypeConverts the object to the given type without limit checks. Used for JDBC writes.- Specified by:
convertToDefaultTypein classType
-
convertToString
public java.lang.String convertToString(java.lang.Object a)
- Specified by:
convertToStringin classType
-
convertToSQLString
public java.lang.String convertToSQLString(java.lang.Object a)
- Specified by:
convertToSQLStringin classType
-
canConvertFrom
public boolean canConvertFrom(Type otherType)
- Specified by:
canConvertFromin classType
-
canMoveFrom
public int canMoveFrom(Type otherType)
Description copied from class:TypeCan convert without changing the object- Overrides:
canMoveFromin classType- Returns:
- 0 always, 1 range check required, -1 never
-
position
public long position(SessionInterface session, BlobData data, BlobData otherData, Type otherType, long offset)
-
substring
public BlobData substring(SessionInterface session, BlobData data, long offset, long length, boolean hasLength)
-
trim
public BlobData trim(Session session, BlobData data, int trim, boolean leading, boolean trailing)
-
overlay
public BlobData overlay(Session session, BlobData data, BlobData overlay, long offset, long length, boolean hasLength)
-
concat
public java.lang.Object concat(Session session, java.lang.Object a, java.lang.Object b)
-
getBinaryType
public static BinaryType getBinaryType(int type, long precision)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG