public class SQLChar extends DataType implements StringDataValue, StreamStorable
The state may be in char[], a String, a Clob, or an unread stream, depending on how the datatype was created.
Stream notes:
When the datatype comes from the database layer and the length of the bytes necessary to store the datatype on disk exceeds the size of a page of the container holding the data then the store returns a stream rather than reading all the bytes into a char[] or String. The hope is that the usual usage case is that data never need be expanded in the derby layer, and that client can just be given a stream that can be read a char at a time through the jdbc layer. Even though SQLchar's can't ever be this big, this code is shared by all the various character datatypes including SQLClob which is expected to usually larger than a page.
The state can also be a stream in the case of insert/update where the client has used a jdbc interface to set the value as a stream rather than char[]. In this case the hope is that the usual usage case is that stream never need be read until it is passed to store, read once, and inserted into the database.
| Modifier and Type | Field and Description |
|---|---|
protected java.sql.Clob |
_clobValue
The value as a user-created Clob
|
(package private) char[][] |
arg_passer |
private static int |
BASE_MEMORY_USAGE |
private static char[] |
BLANKS
Static array that can be used for blank padding.
|
protected static StreamHeaderGenerator |
CHAR_HEADER_GENERATOR
Stream header generator for CHAR, VARCHAR and LONG VARCHAR.
|
private java.text.CollationKey |
cKey |
private static int |
GROWBY_FOR_CHAR
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 reasonable growby size.
|
private LocaleFinder |
localeFinder |
private static char |
PAD
The pad character (space).
|
private char[] |
rawData |
private int |
rawLength |
protected static int |
RETURN_SPACE_THRESHOLD
threshold, that decides when we return space back to the VM
see getString() where it is used
|
(package private) java.io.InputStream |
stream
The value as a stream in the on-disk format.
|
private java.lang.String |
value
Fields of the class
|
BOTH, COLLATION_DERIVATION_EXPLICIT, COLLATION_DERIVATION_IMPLICIT, COLLATION_DERIVATION_NONE, COLLATION_TYPE_TERRITORY_BASED, COLLATION_TYPE_TERRITORY_BASED_IDENTICAL, COLLATION_TYPE_TERRITORY_BASED_PRIMARY, COLLATION_TYPE_TERRITORY_BASED_SECONDARY, COLLATION_TYPE_TERRITORY_BASED_TERTIARY, COLLATION_TYPE_UCS_BASIC, LEADING, TRAILINGUNKNOWN_LOGICAL_LENGTHORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHANIGNORE_PRECISION| Constructor and Description |
|---|
SQLChar()
no-arg constructor, required by Formattable.
|
SQLChar(char[] val)
This is a special constructor used when we need to represent a password
as a VARCHAR (see DERBY-866).
|
SQLChar(java.sql.Clob val) |
SQLChar(java.lang.String val) |
| Modifier and Type | Method and Description |
|---|---|
StringDataValue |
ansiTrim(int trimType,
StringDataValue trimChar,
StringDataValue result)
The SQL Ansi trim function.
|
private static void |
appendBlanks(char[] ca,
int offset,
int howMany)
Private/Protected methods of This class:
|
NumberDataValue |
charLength(NumberDataValue result)
This method implements the char_length function for char.
|
DataValueDescriptor |
cloneHolder()
Shallow clone a StreamStorable without objectifying.
|
DataValueDescriptor |
cloneValue(boolean forceMaterialization)
Clone this DataValueDescriptor.
|
int |
compare(DataValueDescriptor other)
Compare this Orderable with a given Orderable for the purpose of
index positioning.
|
boolean |
compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
Compare this Orderable with a given Orderable for the purpose of
qualification and sorting.
|
StringDataValue |
concatenate(StringDataValue leftOperand,
StringDataValue rightOperand,
StringDataValue result)
The SQL concatenation '||' operator.
|
protected void |
copyState(SQLChar other) |
private void |
copyState(java.lang.String otherValue,
char[] otherRawData,
int otherRawLength,
java.text.CollationKey otherCKey,
java.io.InputStream otherStream,
java.sql.Clob otherClobValue,
LocaleFinder otherLocaleFinder) |
BooleanDataValue |
equals(DataValueDescriptor left,
DataValueDescriptor right)
The = operator as called from the language module, as opposed to
the storage module.
|
int |
estimateMemoryUsage()
Estimate the memory usage in bytes of the data value and the overhead of the class.
|
private void |
formatJDBCDate(java.util.Calendar cal,
java.lang.StringBuffer sb) |
private void |
formatJDBCTime(java.util.Calendar cal,
java.lang.StringBuffer sb) |
boolean |
getBoolean()
Get Boolean from a SQLChar.
|
byte |
getByte()
Get Byte from a SQLChar.
|
char[] |
getCharArray()
Get a char array.
|
private int |
getClobLength() |
protected java.text.CollationKey |
getCollationKey()
This method gets called for the collation sensitive char classes ie
CollatorSQLChar, CollatorSQLVarchar, CollatorSQLLongvarchar,
CollatorSQLClob.
|
protected java.text.RuleBasedCollator |
getCollatorForCollation() |
java.sql.Date |
getDate(java.util.Calendar cal)
Get date from a SQLChar.
|
static java.sql.Date |
getDate(java.util.Calendar cal,
java.lang.String str,
LocaleFinder localeFinder)
Static function to Get date from a string.
|
double |
getDouble()
Get double from a SQLChar.
|
float |
getFloat()
Get float from a SQLChar.
|
int |
getInt()
Get int from a SQLChar.
|
int |
getLength()
Gets the length of the data value.
|
private java.util.Locale |
getLocale() |
protected LocaleFinder |
getLocaleFinder() |
long |
getLong()
Get long from a SQLChar.
|
DataValueDescriptor |
getNewNull()
Get a new null value of the same type as this data value.
|
protected StringDataValue |
getNewVarchar()
Get a SQLVarchar for a built-in string function.
|
java.lang.Object |
getObject()
Gets the value in the data value descriptor as a int.
|
char[] |
getRawDataAndZeroIt()
This is a special accessor used when we wrap passwords in VARCHARs.
|
short |
getShort()
Get Short from a SQLChar.
|
java.io.InputStream |
getStream()
Gets the value in the data stream descriptor as an InputStream.
|
StreamHeaderGenerator |
getStreamHeaderGenerator()
Returns the default stream header generator for the string data types.
|
CharacterStreamDescriptor |
getStreamWithDescriptor()
Returns a descriptor for the input stream for this character data value.
|
java.lang.String |
getString()
If possible, use getCharArray() if you don't really
need a string.
|
java.sql.Time |
getTime(java.util.Calendar cal)
Get time from a SQLChar.
|
static java.sql.Time |
getTime(java.util.Calendar cal,
java.lang.String str,
LocaleFinder localeFinder)
Static function to Get Time from a string.
|
java.sql.Timestamp |
getTimestamp(java.util.Calendar cal)
Get Timestamp from a SQLChar.
|
static java.sql.Timestamp |
getTimestamp(java.util.Calendar cal,
java.lang.String str,
LocaleFinder localeFinder)
Static function to Get Timestamp from a string.
|
java.lang.String |
getTraceString()
Gets a trace representation for debugging.
|
int |
getTypeFormatId()
Return my format identifier.
|
java.lang.String |
getTypeName()
Get the SQL name of the datatype
|
private int |
getUTF8Length(java.lang.String string,
int start,
int end)
Get the number of bytes needed to represent a string in modified
UTF-8, which is the encoding used by
writeExternal() and
writeUTF(). |
StringDataValue |
getValue(java.text.RuleBasedCollator collatorForComparison)
Gets either SQLChar/SQLVarchar/SQLLongvarchar/SQLClob(base classes) or
CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarch/CollatorSQLClob
(subclasses).
|
BooleanDataValue |
greaterOrEquals(DataValueDescriptor left,
DataValueDescriptor right)
The >= operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
greaterThan(DataValueDescriptor left,
DataValueDescriptor right)
The > operator as called from the language module, as opposed to
the storage module.
|
protected int |
growBy()
returns the reasonable minimum amount by
which the array can grow .
|
int |
hashCode() |
(package private) int |
hashCodeForCollation()
Hash code implementation for collator sensitive subclasses.
|
protected void |
hasNonBlankChars(java.lang.String source,
int start,
int end) |
boolean |
isNull()
see if the String value is null.
|
BooleanDataValue |
lessOrEquals(DataValueDescriptor left,
DataValueDescriptor right)
The <= operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
lessThan(DataValueDescriptor left,
DataValueDescriptor right)
The < operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
like(DataValueDescriptor pattern)
This method implements the like function for char (with no escape value).
|
BooleanDataValue |
like(DataValueDescriptor pattern,
DataValueDescriptor escape)
This method implements the like function for char with an escape value.
|
void |
loadStream()
Set the value by reading the stream and
converting it to an object form.
|
NumberDataValue |
locate(StringDataValue searchFrom,
NumberDataValue start,
NumberDataValue result)
This method implements the locate function for char.
|
StringDataValue |
lower(StringDataValue result)
Convert the string to lower case.
|
void |
normalize(DataTypeDescriptor desiredType,
DataValueDescriptor source)
Normalization method - this method may be called when putting
a value into a SQLChar, for example, when inserting into a SQLChar
column.
|
protected void |
normalize(DataTypeDescriptor desiredType,
java.lang.String sourceValue) |
BooleanDataValue |
notEquals(DataValueDescriptor left,
DataValueDescriptor right)
The <> operator as called from the language module, as opposed to
the storage module.
|
private int |
rawGetClobLength() |
void |
readExternal(java.io.ObjectInput in) |
protected void |
readExternal(java.io.ObjectInput in,
int utflen,
int knownStrLen)
Restores the data value from the source stream, materializing the value
in memory.
|
protected void |
readExternalClobFromArray(ArrayInputStream in,
int charLen)
Reads a CLOB from the source stream and materializes the value in a
character array.
|
void |
readExternalFromArray(ArrayInputStream in)
Reads in a string from the specified data input stream.
|
private void |
resetForMaterialization()
Resets state after materializing value from an array.
|
void |
restoreToNull()
Restore this object to its (SQL)null value.
|
java.io.InputStream |
returnStream()
Public Methods of StreamStorable interface:
|
void |
setBigDecimal(java.lang.Number bigDecimal)
Only to be called when an application through JDBC is setting a
SQLChar to a java.math.BigDecimal.
|
protected void |
setFrom(DataValueDescriptor theValue)
Set the value of this DataValueDescriptor based on the value
of the specified DataValueDescriptor.
|
void |
setInto(java.sql.PreparedStatement ps,
int position)
Set the value into a PreparedStatement.
|
protected void |
setLocaleFinder(LocaleFinder localeFinder) |
void |
setObjectForCast(java.lang.Object theValue,
boolean instanceOfResultType,
java.lang.String resultTypeClassName)
Allow any Java type to be cast to a character type using
Object.toString.
|
void |
setStream(java.io.InputStream newStream)
Set this value to the on-disk format stream.
|
void |
setStreamHeaderFormat(java.lang.Boolean inSoftUpgradeMode)
Sets the mode for the database being accessed.
|
void |
setValue(boolean theValue)
Set the value.
|
void |
setValue(byte theValue)
Set the value of this DataValueDescriptor to the given byte value
At DataType level just throws an error lower classes will override
|
void |
setValue(byte[] theValue)
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Clob theValue)
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Date theValue,
java.util.Calendar cal)
Set the value of this DataValueDescriptor.
|
void |
setValue(double theValue)
Set the value of this DataValueDescriptor to the given double value
At DataType level just throws an error lower classes will override
|
void |
setValue(float theValue)
Set the value of this DataValueDescriptor to the given float value
At DataType level just throws an error lower classes will override
|
void |
setValue(java.io.InputStream theStream,
int valueLength)
Set the value from the stream which is in the on-disk format.
|
void |
setValue(int theValue)
Set the value of this DataValueDescriptor to the given int value
At DataType level just throws an error lower classes will override
|
void |
setValue(long theValue)
Set the value of this DataValueDescriptor to the given long value
At DataType level just throws an error lower classes will override
|
void |
setValue(short theValue)
Set the value of this DataValueDescriptor to the given short value
At DataType level just throws an error lower classes will override
|
void |
setValue(java.lang.String theValue)
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Time theValue,
java.util.Calendar cal)
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Timestamp theValue,
java.util.Calendar cal)
Set the value of this DataValueDescriptor.
|
void |
setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
Set the value based on the value for the specified DataValueDescriptor
from the specified ResultSet.
|
void |
setWidth(int desiredWidth,
int desiredScale,
boolean errorOnTrunc)
Set the width of the to the desired value.
|
protected static int |
stringCompare(char[] op1,
int leftlen,
char[] op2,
int rightlen)
Compare two Strings using standard SQL semantics.
|
protected int |
stringCompare(SQLChar char1,
SQLChar char2)
Compare two SQLChars.
|
protected static int |
stringCompare(java.lang.String op1,
java.lang.String op2)
Compare two Strings using standard SQL semantics.
|
ConcatableDataValue |
substring(NumberDataValue start,
NumberDataValue length,
ConcatableDataValue result,
int maxLen)
The SQL substr() function.
|
protected void |
throwStreamingIOException(java.io.IOException ioe)
Wraps an
IOException in a StandardException then throws
the wrapping exception. |
java.lang.String |
toString() |
private java.lang.String |
trimInternal(int trimType,
char trimChar,
java.lang.String source)
This function public for testing purposes.
|
int |
typePrecedence()
Each built-in type in JSQL has a precedence.
|
int |
typeToBigDecimal()
CHAR/VARCHAR/LONG VARCHAR implementation.
|
StringDataValue |
upper(StringDataValue result)
Convert the string to upper case.
|
protected void |
writeClobUTF(java.io.ObjectOutput out)
Writes the header and the user data for a CLOB to the destination stream.
|
void |
writeExternal(java.io.ObjectOutput out)
Writes a non-Clob data value to the modified UTF-8 format used by Derby.
|
private static void |
writeUTF(java.io.ObjectOutput out,
int c)
Write a single character to a stream in the modified UTF-8 format.
|
private void |
writeUTF(java.io.ObjectOutput out,
int strLen,
boolean isRaw,
java.io.Reader characterReader)
Writes the user data value to a stream in the modified UTF-8 format.
|
void |
zeroRawData()
Zero out the wrapped char[] so that it can't be memory-sniffed.
|
checkHostVariable, coalesce, compare, compare, compareTo, dataTypeConversion, equals, flip, genericSetObject, getBytes, getTypeName, hasStream, in, invalidFormat, isNotNull, isNullOp, outOfRange, recycle, setInto, setObject, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatchprivate static final char PAD
protected static final int RETURN_SPACE_THRESHOLD
private static final int GROWBY_FOR_CHAR
private static final int BASE_MEMORY_USAGE
private static final char[] BLANKS
protected static final StreamHeaderGenerator CHAR_HEADER_GENERATOR
private java.lang.String value
private char[] rawData
private int rawLength
private java.text.CollationKey cKey
protected java.sql.Clob _clobValue
java.io.InputStream stream
private LocaleFinder localeFinder
char[][] arg_passer
public SQLChar()
public SQLChar(java.lang.String val)
public SQLChar(java.sql.Clob val)
public SQLChar(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 keep track of the following:
private static void appendBlanks(char[] ca,
int offset,
int howMany)
public char[] getRawDataAndZeroIt()
This is a special accessor used when we wrap passwords in VARCHARs. This accessor copies the wrapped char[] and then fills it with 0s so that the password can't be memory-sniffed. For more information, see the comment on the SQLChar( char[] ) constructor.
public void zeroRawData()
Zero out the wrapped char[] so that it can't be memory-sniffed. This helps us protect passwords. See the comment on the SQLChar( char[] ) constructor.
public boolean getBoolean()
throws StandardException
Return false for only "0" or "false" for false. No case insensitivity. Everything else is true.
The above matches JCC and the client driver.
getBoolean in interface DataValueDescriptorgetBoolean in class DataTypeStandardException - Thrown on errorDataValueDescriptor.getBoolean()public byte getByte()
throws StandardException
Uses java standard Byte.parseByte() to perform coercion.
getByte in interface DataValueDescriptorgetByte in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getByte()public short getShort()
throws StandardException
Uses java standard Short.parseShort() to perform coercion.
getShort in interface DataValueDescriptorgetShort in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getShort()public int getInt()
throws StandardException
Uses java standard Short.parseInt() to perform coercion.
getInt in interface DataValueDescriptorgetInt in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getInt()public long getLong()
throws StandardException
Uses java standard Short.parseLong() to perform coercion.
getLong in interface DataValueDescriptorgetLong in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getLong()public float getFloat()
throws StandardException
Uses java standard Float.floatValue() to perform coercion.
getFloat in interface DataValueDescriptorgetFloat in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getFloat()public double getDouble()
throws StandardException
Uses java standard Double.doubleValue() to perform coercion.
getDouble in interface DataValueDescriptorgetDouble in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getDouble()public java.sql.Date getDate(java.util.Calendar cal)
throws StandardException
getDate in interface DataValueDescriptorgetDate in class DataTypecal - calendar for object creationStandardException - thrown on failure to convertDataValueDescriptor.getDate(java.util.Calendar)public static java.sql.Date getDate(java.util.Calendar cal,
java.lang.String str,
LocaleFinder localeFinder)
throws StandardException
StandardException - thrown on failure to convertDataValueDescriptor.getDate(java.util.Calendar)public java.sql.Time getTime(java.util.Calendar cal)
throws StandardException
getTime in interface DataValueDescriptorgetTime in class DataTypecal - calendar for object creationStandardException - thrown on failure to convertDataValueDescriptor.getTime(java.util.Calendar)public static java.sql.Time getTime(java.util.Calendar cal,
java.lang.String str,
LocaleFinder localeFinder)
throws StandardException
StandardException - thrown on failure to convertDataValueDescriptor.getTime(java.util.Calendar)public java.sql.Timestamp getTimestamp(java.util.Calendar cal)
throws StandardException
getTimestamp in interface DataValueDescriptorgetTimestamp in class DataTypecal - calendar for object creationStandardException - thrown on failure to convertDataValueDescriptor.getTimestamp(java.util.Calendar)public static java.sql.Timestamp getTimestamp(java.util.Calendar cal,
java.lang.String str,
LocaleFinder localeFinder)
throws StandardException
StandardException - thrown on failure to convertDataValueDescriptor.getTimestamp(java.util.Calendar)public java.io.InputStream returnStream()
returnStream in interface StreamStorablepublic void setStream(java.io.InputStream newStream)
setStream in interface StreamStorablepublic void loadStream()
throws StandardException
StreamStorableloadStream in interface StreamStorableStandardException - on errorpublic java.lang.Object getObject()
throws StandardException
DataTypegetObject in interface DataValueDescriptorgetObject in class DataTypeStandardException - Thrown on errorpublic java.io.InputStream getStream()
throws StandardException
DataTypegetStream in interface DataValueDescriptorgetStream in class DataTypeStandardException - Thrown on errorDataValueDescriptor.hasStream(),
StringDataValue.getStreamWithDescriptor()public CharacterStreamDescriptor getStreamWithDescriptor() throws StandardException
getStreamWithDescriptor in interface StringDataValueStandardException - if the value isn't represented by a streamSQLClob.getStreamWithDescriptor()public int typeToBigDecimal()
throws StandardException
typeToBigDecimal in interface DataValueDescriptortypeToBigDecimal in class DataTypeStandardException - Conversion is not possiblepublic int getLength()
throws StandardException
DataValueDescriptorgetLength in interface DataValueDescriptorStandardException - Thrown on errorprotected void throwStreamingIOException(java.io.IOException ioe)
throws StandardException
IOException in a StandardException then throws
the wrapping exception.ioe - the IOException to wrapStandardException - the wrapping exceptionpublic java.lang.String getTypeName()
DataValueDescriptorgetTypeName in interface DataValueDescriptorpublic java.lang.String getString()
throws StandardException
getString in interface DataValueDescriptorStandardException - Thrown on errorpublic char[] getCharArray()
throws StandardException
WARNING: may return a character array that has spare characters at the end. MUST be used in conjunction with getLength() to be safe.
getCharArray in interface StringDataValueStandardException - Thrown on errorpublic int getTypeFormatId()
getTypeFormatId in interface TypedFormatTypedFormat.getTypeFormatId()public boolean isNull()
isNull in interface StorableStorable.isNull()public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
First, two bytes are written to the output stream as if by the
writeShort method giving the number of bytes to
follow. This value is the number of bytes actually written out,
not the length of the string. Following the length, each character
of the string is output, in sequence, using the UTF-8 encoding
for the character.
writeExternal in interface java.io.Externalizablejava.io.IOException - if an I/O error occurs.DataInputStreamprivate final void writeUTF(java.io.ObjectOutput out,
int strLen,
boolean isRaw,
java.io.Reader characterReader)
throws java.io.IOException
out - destination streamstrLen - string length of the valueisRaw - true if the source is rawData, false
if the source is valuecharacterReader - Reader from _clobValue if it existsjava.io.IOException - if writing to the destination stream failsprivate static void writeUTF(java.io.ObjectOutput out,
int c)
throws java.io.IOException
out - the destination streamc - the character to writejava.io.IOException - if writing to the destination stream failsprotected final void writeClobUTF(java.io.ObjectOutput out)
throws java.io.IOException
out - destination streamjava.io.IOException - if writing to the destination stream failspublic void readExternalFromArray(ArrayInputStream in) throws java.io.IOException
The first two bytes are read as if by
readUnsignedShort. This value gives the number of
following bytes that are in the encoded string, not
the length of the resulting string. The following bytes are then
interpreted as bytes encoding characters in the UTF-8 format
and are converted into characters.
This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.
readExternalFromArray in interface DataValueDescriptorreadExternalFromArray in class DataTypein - a data input stream.java.io.EOFException - if the input stream reaches the end
before all the bytes.java.io.IOException - if an I/O error occurs.java.io.UTFDataFormatException - if the bytes do not represent a
valid UTF-8 encoding of a Unicode string.DataInputStream.readUnsignedShort(),
Externalizable.readExternal(java.io.ObjectInput)protected void readExternalClobFromArray(ArrayInputStream in, int charLen) throws java.io.IOException
in - source streamcharLen - the char length of the value, or 0 if unknownjava.io.IOException - if reading from the source failsprivate void resetForMaterialization()
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException
readExternal in interface java.io.Externalizablejava.io.IOExceptionprotected void readExternal(java.io.ObjectInput in,
int utflen,
int knownStrLen)
throws java.io.IOException
in - the source streamutflen - the byte length, or 0 if unknownknownStrLen - the char length, or 0 if unknownjava.io.UTFDataFormatException - if an encoding error is detectedjava.io.IOException - if reading the stream failsprotected int growBy()
public void restoreToNull()
StorablerestoreToNull in interface StorableStorable.restoreToNull()public boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws StandardException
DataValueDescriptorcompare in interface DataValueDescriptorcompare in class DataTypeop - Orderable.ORDER_OP_EQUALS means do an = comparison.
Orderable.ORDER_OP_LESSTHAN means compare this < other.
Orderable.ORDER_OP_LESSOREQUALS means compare this <= other.other - The DataValueDescriptor to compare this one to.orderedNulls - True means to treat nulls as ordered values,
that is, treat SQL null as equal to null, and less
than all other values.
False means to treat nulls as unknown values,
that is, the result of any comparison with a null
is the UNKNOWN truth value.unknownRV - The return value to use if the result of the
comparison is the UNKNOWN truth value. In other
words, if orderedNulls is false, and a null is
involved in the comparison, return unknownRV.
This parameter is not used orderedNulls is true.StandardException - thrown on errorpublic int compare(DataValueDescriptor other) throws StandardException
DataValueDescriptorcompare in interface DataValueDescriptorother - The Orderable to compare this one to.StandardException - thrown on errorpublic DataValueDescriptor cloneHolder()
cloneHolder in interface DataValueDescriptorcloneHolder in class DataTypepublic DataValueDescriptor cloneValue(boolean forceMaterialization)
DataValueDescriptor
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.
cloneValue in interface DataValueDescriptorforceMaterialization - any streams representing the data value will
be materialized if true, the data value will be kept as a
stream if possible if falseDataValueDescriptor with the same initial
value as this.DataValueDescriptor.cloneValue(boolean)public DataValueDescriptor getNewNull()
DataValueDescriptorgetNewNull in interface DataValueDescriptorDataValueDescriptor.getNewNull()public StringDataValue getValue(java.text.RuleBasedCollator collatorForComparison)
StringDataValuegetValue in interface StringDataValueStringDataValue.getValue(RuleBasedCollator)public final void setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
throws java.sql.SQLException
DataValueDescriptorsetValueFromResultSet in interface DataValueDescriptorresultSet - The specified ResultSet.colNumber - The 1-based column # into the resultSet.isNullable - Whether or not the column is nullable
(No need to call wasNull() if not)java.sql.SQLException - Thrown on errorDataValueDescriptor.setValueFromResultSet(java.sql.ResultSet, int, boolean)public final void setInto(java.sql.PreparedStatement ps,
int position)
throws java.sql.SQLException,
StandardException
setInto in interface DataValueDescriptorsetInto in class DataTypejava.sql.SQLException - thrown by the PreparedStatement objectStandardException - thrown by me accessing my value.public void setValue(java.sql.Clob theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in interface StringDataValuesetValue in class DataTypetheValue - The Clob value to set this DataValueDescriptor topublic void setValue(java.lang.String theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The BigDecimal value to set this DataValueDescriptor topublic void setValue(boolean theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - Contains the boolean value to set this toStandardExceptionpublic void setValue(int theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(double theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(float theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(short theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(long theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(byte theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(byte[] theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The byte value to set this DataValueDescriptor toStandardExceptionpublic void setBigDecimal(java.lang.Number bigDecimal)
throws StandardException
setBigDecimal in interface DataValueDescriptorsetBigDecimal in class DataTypebigDecimal - required to be a BigDecimal or null.StandardExceptionpublic void setValue(java.sql.Date theValue,
java.util.Calendar cal)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The Date value to set this DataValueDescriptor tocal - The time zone from the calendar is used to construct the database date valueStandardException - Thrown on errorpublic void setValue(java.sql.Time theValue,
java.util.Calendar cal)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The Time value to set this DataValueDescriptor tocal - The time zone from the calendar is used to construct the database time valueStandardException - Thrown on errorpublic void setValue(java.sql.Timestamp theValue,
java.util.Calendar cal)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The Timestamp value to set this DataValueDescriptor tocal - The time zone from the calendar is used to construct the database timestamp valueStandardException - Thrown on errorprivate void formatJDBCDate(java.util.Calendar cal,
java.lang.StringBuffer sb)
private void formatJDBCTime(java.util.Calendar cal,
java.lang.StringBuffer sb)
public final void setValue(java.io.InputStream theStream,
int valueLength)
setValue in interface DataValueDescriptorsetValue in class DataTypetheStream - On disk format of the streamvalueLength - length of the logical value in characters, or
DataValueDescriptor.UNKNOWN_LOGICAL_LENGTHpublic void setObjectForCast(java.lang.Object theValue,
boolean instanceOfResultType,
java.lang.String resultTypeClassName)
throws StandardException
setObjectForCast in interface DataValueDescriptorsetObjectForCast in class DataTypetheValue - The new valueinstanceOfResultType - Whether or not the new value
is an instanceof the result type.resultTypeClassName - The class name of the resulting (declared) type
(for error messages only).StandardException - thrown on failureDataValueDescriptor.setObjectForCast(java.lang.Object, boolean, java.lang.String)protected void setFrom(DataValueDescriptor theValue) throws StandardException
DataTypesetFrom in class DataTypetheValue - The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value.StandardExceptionpublic void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException
normalize in interface DataValueDescriptornormalize in class DataTypedesiredType - The type to normalize the source column tosource - The value to normalizeStandardException - Thrown for null into
non-nullable column, and for
truncation errorprotected void normalize(DataTypeDescriptor desiredType, java.lang.String sourceValue) throws StandardException
StandardExceptionprotected final void hasNonBlankChars(java.lang.String source,
int start,
int end)
throws StandardException
StandardExceptionpublic void setWidth(int desiredWidth,
int desiredScale,
boolean errorOnTrunc)
throws StandardException
setWidth in interface VariableSizeDataValuedesiredWidth - the desired lengthdesiredScale - the desired scale (ignored)errorOnTrunc - throw an error on truncationStandardException - Thrown when errorOnTrunc
is true and when a shrink will truncate non-white
spaces.private int getUTF8Length(java.lang.String string,
int start,
int end)
throws StandardException
writeExternal() and
writeUTF().string - the string whose length to calculatestart - start index (inclusive)end - end index (exclusive)StandardExceptionpublic BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
equals in interface DataValueDescriptorequals in class DataTypeleft - The value on the left side of the =right - The value on the right side of the =StandardException - Thrown on errorpublic BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
notEquals in interface DataValueDescriptornotEquals in class DataTypeleft - The value on the left side of the <>right - The value on the right side of the <>StandardException - Thrown on errorpublic BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
lessThan in interface DataValueDescriptorlessThan in class DataTypeleft - The value on the left side of the <right - The value on the right side of the <StandardException - Thrown on errorpublic BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
greaterThan in interface DataValueDescriptorgreaterThan in class DataTypeleft - The value on the left side of the >right - The value on the right side of the >StandardException - Thrown on errorpublic BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
lessOrEquals in interface DataValueDescriptorlessOrEquals in class DataTypeleft - The value on the left side of the <=right - The value on the right side of the <=StandardException - Thrown on errorpublic BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
greaterOrEquals in interface DataValueDescriptorgreaterOrEquals in class DataTypeleft - The value on the left side of the >=right - The value on the right side of the >=StandardException - Thrown on errorpublic NumberDataValue charLength(NumberDataValue result) throws StandardException
charLength in interface ConcatableDataValueresult - The result of a previous call to this method, null
if not called yetStandardException - Thrown on errorConcatableDataValue.charLength(NumberDataValue)public StringDataValue concatenate(StringDataValue leftOperand, StringDataValue rightOperand, StringDataValue result) throws StandardException
StringDataValueconcatenate in interface StringDataValueleftOperand - String on the left hand side of '||'rightOperand - String on the right hand side of '||'result - The result of a previous call to this method,
null if not called yet.StandardException - Thrown on errorStringDataValue.concatenate(org.apache.derby.iapi.types.StringDataValue, org.apache.derby.iapi.types.StringDataValue, org.apache.derby.iapi.types.StringDataValue)public BooleanDataValue like(DataValueDescriptor pattern) throws StandardException
like in interface StringDataValuepattern - The pattern to useStandardException - Thrown on errorpublic BooleanDataValue like(DataValueDescriptor pattern, DataValueDescriptor escape) throws StandardException
like in interface StringDataValuepattern - The pattern to useescape - the escape characterStandardException - Thrown on errorpublic NumberDataValue locate(StringDataValue searchFrom, NumberDataValue start, NumberDataValue result) throws StandardException
locate in interface StringDataValuesearchFrom - - The string to search fromstart - - The position to search from in string searchFromresult - - The object to return
Note: use getString() to get the string to search for.StandardException - Thrown on errorpublic ConcatableDataValue substring(NumberDataValue start, NumberDataValue length, ConcatableDataValue result, int maxLen) throws StandardException
substring in interface ConcatableDataValuestart - Start of substrlength - Length of substrresult - The result of a previous call to this method,
null if not called yet.maxLen - Maximum length of the resultStandardException - Thrown on errorprivate java.lang.String trimInternal(int trimType,
char trimChar,
java.lang.String source)
trimType - Type of trim (LEADING, TRAILING, or BOTH)trimChar - Character to trimsource - String from which to trim trimCharpublic StringDataValue ansiTrim(int trimType, StringDataValue trimChar, StringDataValue result) throws StandardException
StringDataValueansiTrim in interface StringDataValuetrimType - Type of trim (LEADING, TRAILING, or BOTH)trimChar - Character to trim from this SQLChar (may be null)result - The result of a previous call to this method,
null if not called yet.StandardExceptionpublic StringDataValue upper(StringDataValue result) throws StandardException
StringDataValueupper in interface StringDataValueresult - The result (reusable - allocate if null).StandardException - Thrown on errorStringDataValue.upper(org.apache.derby.iapi.types.StringDataValue)public StringDataValue lower(StringDataValue result) throws StandardException
StringDataValuelower in interface StringDataValueresult - The result (reusable - allocate if null).StandardException - Thrown on errorStringDataValue.lower(org.apache.derby.iapi.types.StringDataValue)public int typePrecedence()
DataTypetypePrecedence in interface DataValueDescriptortypePrecedence in class DataTypeDataValueDescriptor.typePrecedence()protected static int stringCompare(java.lang.String op1,
java.lang.String op2)
op1 - The first Stringop2 - The second Stringprotected int stringCompare(SQLChar char1, SQLChar char2) throws StandardException
StandardException - Thrown on errorprotected static int stringCompare(char[] op1,
int leftlen,
char[] op2,
int rightlen)
op1 - The first Stringop2 - The second Stringprotected java.text.CollationKey getCollationKey()
throws StandardException
StandardExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectint hashCodeForCollation()
protected StringDataValue getNewVarchar() throws StandardException
StandardException - Thrown on errorprotected void setLocaleFinder(LocaleFinder localeFinder)
private java.util.Locale getLocale()
throws StandardException
StandardException - Thrown on errorprotected java.text.RuleBasedCollator getCollatorForCollation()
throws StandardException
StandardExceptionprotected LocaleFinder getLocaleFinder()
public int estimateMemoryUsage()
DataValueDescriptorestimateMemoryUsage in interface DataValueDescriptorprotected void copyState(SQLChar other)
private void copyState(java.lang.String otherValue,
char[] otherRawData,
int otherRawLength,
java.text.CollationKey otherCKey,
java.io.InputStream otherStream,
java.sql.Clob otherClobValue,
LocaleFinder otherLocaleFinder)
public java.lang.String getTraceString()
throws StandardException
getTraceString in interface DataValueDescriptorgetTraceString in class DataTypeStandardException - if getting the data value fails.DataValueDescriptor.getString()public StreamHeaderGenerator getStreamHeaderGenerator()
getStreamHeaderGenerator in interface StringDataValueStringDataValue.setStreamHeaderFormat(java.lang.Boolean)public void setStreamHeaderFormat(java.lang.Boolean inSoftUpgradeMode)
setStreamHeaderFormat in interface StringDataValueinSoftUpgradeMode - true if the database is being accessed
in soft upgrade mode, false if not, and null if
unknownprivate int getClobLength()
throws StandardException
StandardExceptionprivate int rawGetClobLength()
throws java.sql.SQLException
java.sql.SQLExceptionApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.