Top Description Fields Constructors Methods
org.apache.derby.iapi.types

public Class SQLVarchar

extends SQLChar
Class Inheritance
Known Direct Subclasses
org.apache.derby.iapi.types.CollatorSQLVarchar, org.apache.derby.iapi.types.SQLClob, org.apache.derby.iapi.types.SQLLongvarchar
Imports
java.sql.Clob, java.text.RuleBasedCollator, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.StoredFormatIds, org.apache.derby.shared.common.sanity.SanityManager

SQLVarchar represents a VARCHAR value with UCS_BASIC collation. SQLVarchar is mostly the same as SQLChar, so it is implemented as a subclass of SQLChar. Only those methods with different behavior are implemented here.

Field Summary

Inherited from org.apache.derby.iapi.types.SQLChar:
_clobValuearg_passerCHAR_HEADER_GENERATORRETURN_SPACE_THRESHOLDstream

Constructor Summary

AccessConstructor and Description
public
public
public
public
SQLVarchar(char[] val)

This is a special constructor used when we need to represent a password as a VARCHAR (see DERBY-866).

Method Summary

Modifier and TypeMethod and Description
public DataValueDescriptor
cloneValue(boolean
any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false
forceMaterialization
)

Overrides org.apache.derby.iapi.types.SQLChar.cloneValue.

Implements org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Clone this DataValueDescriptor.

public DataValueDescriptor
getNewNull()

Overrides org.apache.derby.iapi.types.SQLChar.getNewNull.

Implements org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Get a new null value of the same type as this data value.

public int
public String
public StringDataValue
getValue(RuleBasedCollator collatorForComparison)

Overrides org.apache.derby.iapi.types.SQLChar.getValue.

Implements org.apache.derby.iapi.types.StringDataValue.getValue.

Gets either SQLChar/SQLVarchar/SQLLongvarchar/SQLClob(base classes) or CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarch/CollatorSQLClob (subclasses).

protected final int

Returns:

minimum reasonable growby size
growBy
()

Overrides org.apache.derby.iapi.types.SQLChar.growBy.

returns the reasonable minimum amount by which the array can grow .

public void
normalize(DataTypeDescriptor
The type to normalize the source column to
desiredType
,
DataValueDescriptor
The value to normalize
source
)

Overrides org.apache.derby.iapi.types.SQLChar.normalize.

Implements org.apache.derby.iapi.types.DataValueDescriptor.normalize.

Normalization method - this method may be called when putting a value into a SQLVarchar, for example, when inserting into a SQLVarchar column.

protected void
public int
Inherited from org.apache.derby.iapi.types.SQLChar:
ansiTrimcharLengthcloneHoldercomparecompareconcatenatecopyStateequalsestimateMemoryUsagegetBooleangetBytegetCharArraygetCollationKeygetCollatorForCollationgetDategetDategetDoublegetFloatgetIntgetLengthgetLocaleFindergetLonggetNewVarchargetObjectgetRawDataAndZeroItgetShortgetStreamgetStreamHeaderGeneratorgetStreamWithDescriptorgetStringgetTimegetTimegetTimestampgetTimestampgetTraceStringgreaterOrEqualsgreaterThanhashCodehashCodeForCollationhasNonBlankCharsisNulllessOrEqualslessThanlikelikeloadStreamlocatelowernotEqualsreadExternalreadExternalreadExternalClobFromArrayreadExternalFromArrayrestoreToNullreturnStreamsetBigDecimalsetFromsetIntosetLocaleFindersetObjectForCastsetStreamsetStreamHeaderFormatsetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValueFromResultSetsetWidthstringComparestringComparestringComparesubstringthrowStreamingIOExceptiontoStringtypeToBigDecimalupperwriteClobUTFwriteExternalzeroRawData

Constructor Detail

SQLVarcharback to summary
public SQLVarchar()
SQLVarcharback to summary
public SQLVarchar(String val)
SQLVarcharback to summary
public SQLVarchar(Clob val)
SQLVarcharback to summary
public SQLVarchar(char[] val)

This is a special constructor used when we need to represent a password as a VARCHAR (see DERBY-866). If you need a general-purpose constructor for char[] values and you want to re-use this constructor, make sure to read the comment on the SQLChar( char[] ) constructor.

Method Detail

cloneValueback to summary
public DataValueDescriptor cloneValue(boolean forceMaterialization)

Overrides org.apache.derby.iapi.types.SQLChar.cloneValue.

Implements org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Clone this DataValueDescriptor. Results in a new object that has the same value as this but can be modified independently.

Even though the objects can be modified independently regardless of the value of forceMaterialization, both the clone and the original may be dependent on the store state if forceMaterialization is set to false. An example is if you need to access the value you just read using cloneValue after the current transaction has ended, or after the source result set has been closed.

Parameters
forceMaterialization:boolean

any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false

Returns:DataValueDescriptor

A clone of the DataValueDescriptor with the same initial value as this.

See Also
DataValueDescriptor#cloneValue
getNewNullback to summary
public DataValueDescriptor getNewNull()

Overrides org.apache.derby.iapi.types.SQLChar.getNewNull.

Implements org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Get a new null value of the same type as this data value.

See Also
DataValueDescriptor#getNewNull
getTypeFormatIdback to summary
public int getTypeFormatId()

Overrides org.apache.derby.iapi.types.SQLChar.getTypeFormatId.

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Return my format identifier.

Returns:int

Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

The identifier. (A UUID stuffed in an array of 16 bytes).

See Also
org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
getTypeNameback to summary
public String getTypeName()

Overrides org.apache.derby.iapi.types.SQLChar.getTypeName.

Implements org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Get the SQL name of the datatype

Returns:String

The SQL name of the datatype

getValueback to summary
public StringDataValue getValue(RuleBasedCollator collatorForComparison)

Overrides org.apache.derby.iapi.types.SQLChar.getValue.

Implements org.apache.derby.iapi.types.StringDataValue.getValue.

Doc from org.apache.derby.iapi.types.StringDataValue.getValue.

Gets either SQLChar/SQLVarchar/SQLLongvarchar/SQLClob(base classes) or CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarch/CollatorSQLClob (subclasses). Whether this method returns the base class or the subclass depends on the value of the RuleBasedCollator. If RuleBasedCollator is null, then the object returned would be baseclass otherwise it would be subcalss.

See Also
StringDataValue#getValue(RuleBasedCollator)
growByback to summary
protected final int growBy()

Overrides org.apache.derby.iapi.types.SQLChar.growBy.

returns the reasonable minimum amount by which the array can grow . See readExternal. when we know that the array needs to grow by at least one byte, it is not performant to grow by just one byte instead this amount is used to provide a resonable growby size.

Returns:int

minimum reasonable growby size

normalizeback to summary
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException

Overrides org.apache.derby.iapi.types.SQLChar.normalize.

Implements org.apache.derby.iapi.types.DataValueDescriptor.normalize.

Normalization method - this method may be called when putting a value into a SQLVarchar, for example, when inserting into a SQLVarchar column. See NormalizeResultSet in execution.

Parameters
desiredType:DataTypeDescriptor

The type to normalize the source column to

source:DataValueDescriptor

The value to normalize

Exceptions
StandardException:
Thrown for null into non-nullable column, and for truncation error
normalizeback to summary
protected void normalize(DataTypeDescriptor desiredType, String sourceValue) throws StandardException

Overrides org.apache.derby.iapi.types.SQLChar.normalize.

typePrecedenceback to summary
public int typePrecedence()

Overrides org.apache.derby.iapi.types.SQLChar.typePrecedence.

Implements org.apache.derby.iapi.types.DataValueDescriptor.typePrecedence.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.typePrecedence.

Each built-in type in JSQL has a precedence. This precedence determines how to do type promotion when using binary operators. For example, float has a higher precedence than int, so when adding an int to a float, the result type is float. The precedence for some types is arbitrary. For example, it doesn't matter what the precedence of the boolean type is, since it can't be mixed with other types. But the precedence for the number types is critical. The SQL standard requires that exact numeric types be promoted to approximate numeric when one operator uses both. Also, the precedence is arranged so that one will not lose precision when promoting a type.

Returns:int

The precedence of this type.