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 Clob | _clobValue
The value as a user-created Clob |
| pack-priv char[][] | |
| private static final int | |
| private static final char[] | BLANKS
Static array that can be used for blank padding. |
| protected static final StreamHeaderGenerator | CHAR_HEADER_GENERATOR
Stream header generator for CHAR, VARCHAR and LONG VARCHAR. |
| private CollationKey | |
| private static final 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 | |
| private static final char | PAD
The pad character (space). |
| private char[] | |
| private int | |
| protected static final int | RETURN_SPACE_THRESHOLD
threshold, that decides when we return space back to the VM see getString() where it is used |
| pack-priv InputStream | stream
The value as a stream in the on-disk format. |
| private String | value
Fields of the class |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | SQLChar(char[] val)
This is a special constructor used when we need to represent a password as a VARCHAR (see DERBY-866). |
| Modifier and Type | Method and Description |
|---|---|
| public StringDataValue | Returns: A StringDataValue containing the result of the trim.Type of trim (LEADING, TRAILING, or BOTH) trimType, StringDataValue Character to trim from this SQLChar (may be null) trimChar, StringDataValue The result of a previous call to this method,
null if not called yet. result)Implements org. The SQL Ansi trim function. |
| private static void | |
| public NumberDataValue | Returns: A SQLInteger containing the length of the char valueThe result of a previous call to this method, null
if not called yet result)Implements org. This method implements the char_length function for char. |
| public DataValueDescriptor | cloneHolder()
Overrides org. Implements org. Shallow clone a StreamStorable without objectifying. |
| public DataValueDescriptor | cloneValue(boolean
any streams representing the data value will
be materialized if forceMaterialization)true, the data value will be kept as a
stream if possible if falseImplements org. Clone this DataValueDescriptor. |
| public boolean | compare(int
Orderable.ORDER_OP_EQUALS means do an = comparison.
Orderable.ORDER_OP_LESSTHAN means compare this < other.
Orderable.ORDER_OP_LESSOREQUALS means compare this <= other. op, DataValueDescriptor The DataValueDescriptor to compare this one to. other, boolean 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. orderedNulls, boolean 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. unknownRV)Overrides org. Implements org. Compare this Orderable with a given Orderable for the purpose of qualification and sorting. |
| public int | compare(DataValueDescriptor
The Orderable to compare this one to. other)Implements org. Compare this Orderable with a given Orderable for the purpose of index positioning. |
| public StringDataValue | concatenate(StringDataValue
String on the left hand side of '||' leftOperand, StringDataValue String on the right hand side of '||' rightOperand, StringDataValue The result of a previous call to this method,
null if not called yet. result)Implements org. The SQL concatenation '||' operator. |
| protected void | |
| private void | copyState(String otherValue, char[] otherRawData, int otherRawLength, CollationKey otherCKey, InputStream otherStream, Clob otherClobValue, LocaleFinder otherLocaleFinder)
|
| public BooleanDataValue | Returns: A SQL boolean value telling whether the two parameters are equalThe value on the left side of the = left, DataValueDescriptor The value on the right side of the = right)Overrides org. Implements org. The = operator as called from the language module, as opposed to the storage module. |
| public int | estimateMemoryUsage()
Implements org. Estimate the memory usage in bytes of the data value and the overhead of the class. |
| private void | |
| private void | |
| public boolean | getBoolean()
Overrides org. Implements org. Get Boolean from a SQLChar. |
| public byte | getByte()
Overrides org. Implements org. Get Byte from a SQLChar. |
| public char[] | getCharArray()
Implements org. Get a char array. |
| private int | |
| protected CollationKey | Returns: CollationKey obtained using Collator on the stringThis method gets called for the collation sensitive char classes ie CollatorSQLChar, CollatorSQLVarchar, CollatorSQLLongvarchar, CollatorSQLClob. |
| protected RuleBasedCollator | |
| public Date | getDate(Calendar
calendar for object creation cal)Overrides org. Implements org. Get date from a SQLChar. |
| public static Date | getDate(Calendar cal, String str, LocaleFinder localeFinder)
Static function to Get date from a string. |
| public double | getDouble()
Overrides org. Implements org. Get double from a SQLChar. |
| public float | getFloat()
Overrides org. Implements org. Get float from a SQLChar. |
| public int | getInt()
Overrides org. Implements org. Get int from a SQLChar. |
| public int | getLength()
Implements org. Gets the length of the data value. |
| private Locale | |
| protected LocaleFinder | |
| public long | getLong()
Overrides org. Implements org. Get long from a SQLChar. |
| public DataValueDescriptor | getNewNull()
Implements org. Get a new null value of the same type as this data value. |
| protected StringDataValue | |
| public Object | getObject()
Overrides org. Implements org. Gets the value in the data value descriptor as a Java Object. |
| public char[] | |
| public short | getShort()
Overrides org. Implements org. Get Short from a SQLChar. |
| public InputStream | getStream()
Overrides org. Implements org. Gets the value in the data value descriptor as a stream of bytes. |
| public StreamHeaderGenerator | Returns: A stream header generator.Implements org. Returns the default stream header generator for the string data types. |
| public CharacterStreamDescriptor | Returns: Nothing, throws exception.Implements org. Returns a descriptor for the input stream for this character data value. |
| public String | getString()
Implements org. If possible, use getCharArray() if you don't really need a string. |
| public Time | getTime(Calendar
calendar for object creation cal)Overrides org. Implements org. Get time from a SQLChar. |
| public static Time | getTime(Calendar cal, String str, LocaleFinder localeFinder)
Static function to Get Time from a string. |
| public Timestamp | getTimestamp(Calendar
calendar for object creation cal)Overrides org. Implements org. Get Timestamp from a SQLChar. |
| public static Timestamp | getTimestamp(Calendar cal, String str, LocaleFinder localeFinder)
Static function to Get Timestamp from a string. |
| public String | Returns: a trace representation of this SQL Type.Overrides org. Implements org. Gets a trace representation for debugging. |
| public int | getTypeFormatId()
Implements org. Return my format identifier. |
| public String | getTypeName()
Implements org. Get the SQL name of the datatype |
| private int | getUTF8Length(String
the string whose length to calculate string, int start index (inclusive) start, int end index (exclusive) end)Get the number of bytes needed to represent a string in modified
UTF-8, which is the encoding used by |
| public StringDataValue | getValue(RuleBasedCollator collatorForComparison)
Implements org. Gets either SQLChar/SQLVarchar/SQLLongvarchar/SQLClob(base classes) or CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarch/CollatorSQLClob (subclasses). |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the first operand is greater than or equal to the second operandThe value on the left side of the operator left, DataValueDescriptor The value on the right side of the operator right)Overrides org. Implements org. The >= operator as called from the language module, as opposed to the storage module. |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the first operand is greater than the second operandThe value on the left side of the operator left, DataValueDescriptor The value on the right side of the operator right)Overrides org. Implements org. The > operator as called from the language module, as opposed to the storage module. |
| protected int | Returns: minimum reasonable growby sizereturns the reasonable minimum amount by which the array can grow . |
| public int | |
| pack-priv int | |
| protected final void | |
| public boolean | isNull()
Implements org. see if the String value is null. |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the first operand is less than or equal to the second operandThe value on the left side of the operator left, DataValueDescriptor The value on the right side of the operator right)Overrides org. Implements org. The <= operator as called from the language module, as opposed to the storage module. |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the first operand is less than the second operandThe value on the left side of the operator left, DataValueDescriptor The value on the right side of the operator right)Overrides org. Implements org. The < operator as called from the language module, as opposed to the storage module. |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the first operand is like the second operandThe pattern to use pattern)Implements org. This method implements the like function for char (with no escape value). |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the first operand is like the second operandThe pattern to use pattern, DataValueDescriptor the escape character escape)Implements org. This method implements the like function for char with an escape value. |
| public void | loadStream()
Implements org. Set the value by reading the stream and converting it to an object form. |
| public NumberDataValue | Returns: The position in searchFrom the fist occurrence of this.value. 0 is returned if searchFrom does not contain this.value.- The string to search from searchFrom, NumberDataValue - The position to search from in string searchFrom start, NumberDataValue - The object to return
Note: use getString() to get the string to search for. result)Implements org. This method implements the locate function for char. |
| public StringDataValue | lower(StringDataValue
The result (reusable - allocate if null). result)Implements org. Convert the string to lower case. |
| public void | normalize(DataTypeDescriptor
The type to normalize the source column to desiredType, DataValueDescriptor The value to normalize source)Overrides org. Implements org. Normalization method - this method may be called when putting a value into a SQLChar, for example, when inserting into a SQLChar column. |
| protected void | |
| public BooleanDataValue | Returns: A SQL boolean value telling whether the two parameters are not equalThe value on the left side of the operator left, DataValueDescriptor The value on the right side of the operator right)Overrides org. Implements org. The <> operator as called from the language module, as opposed to the storage module. |
| private int | |
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. |
| protected void | readExternal(ObjectInput
the source stream in, int the byte length, or utflen, final int 0 if unknownthe char length, or knownStrLen)0 if unknownRestores the data value from the source stream, materializing the value in memory. |
| protected void | readExternalClobFromArray(ArrayInputStream
source stream in, int the char length of the value, or charLen)0 if unknownReads a CLOB from the source stream and materializes the value in a character array. |
| public void | readExternalFromArray(ArrayInputStream
a data input stream. in)Overrides org. Implements org. Reads in a string from the specified data input stream. |
| private void | |
| public void | restoreToNull()
Implements org. Restore this object to its (SQL)null value. |
| public InputStream | returnStream()
Implements org. Public Methods of StreamStorable interface: |
| public void | setBigDecimal(BigDecimal
required to be a BigDecimal or null. bigDecimal)Overrides org. Implements org. Only to be called when an application through JDBC is setting a SQLChar to a java.math.BigDecimal. |
| protected void | setFrom(DataValueDescriptor
The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value. theValue)Overrides org. Set the value of this DataValueDescriptor based on the value of the specified DataValueDescriptor. |
| public final void | setInto(PreparedStatement ps, int position)
Overrides org. Implements org. Set the value into a PreparedStatement. |
| protected void | |
| public void | setObjectForCast(Object
The new value theValue, boolean Whether or not the new value
is an instanceof the result type. instanceOfResultType, String The class name of the resulting (declared) type
(for error messages only). resultTypeClassName)Overrides org. Implements org. Allow any Java type to be cast to a character type using Object.toString. |
| public void | setStream(InputStream
The new stream to use newStream)Implements org. Set this value to the on-disk format stream. |
| public void | setStreamHeaderFormat(Boolean
true if the database is being accessed
in soft upgrade mode, false if not, and null if
unknownImplements org. Sets the mode for the database being accessed. |
| public void | setValue(Clob
The Clob value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Stuff a StringDataValue with a Clob. |
| public void | setValue(String
The String value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor. |
| public void | setValue(boolean
Contains the boolean value to set this to theValue)Overrides org. Implements org. Set the value. |
| public void | setValue(int
The value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor to the given int value |
| public void | setValue(double
The value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor to the given double value |
| public void | setValue(float
A Double containing the value to set this
DataValueDescriptor to. Null means set the value
to SQL null. theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor to the given double value |
| public void | setValue(short
The value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor to the given short value |
| public void | setValue(long
The value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor to the given long value |
| public void | setValue(byte
The value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor to the given byte value |
| public void | setValue(byte[]
The byte value to set this DataValueDescriptor to theValue)Overrides org. Implements org. Set the value of this DataValueDescriptor. |
| public void | setValue(Date
The Date value to set this DataValueDescriptor to theValue, Calendar The time zone from the calendar is used to construct the database date value cal)Overrides org. Implements org. Set the value of this DataValueDescriptor. |
| public void | setValue(Time
The Time value to set this DataValueDescriptor to theValue, Calendar The time zone from the calendar is used to construct the database time value cal)Overrides org. Implements org. Set the value of this DataValueDescriptor. |
| public void | setValue(Timestamp
The Timestamp value to set this DataValueDescriptor to theValue, Calendar The time zone from the calendar is used to construct the database timestamp value cal)Overrides org. Implements org. Set the value of this DataValueDescriptor. |
| public final void | setValue(InputStream
On disk format of the stream theStream, int length of the logical value in characters, or
valueLength)DataValueDescriptor.UNKNOWN_LOGICAL_LENGTHOverrides org. Implements org. Set the value from the stream which is in the on-disk format. |
| public final void | setValueFromResultSet(ResultSet
The specified ResultSet. resultSet, int The 1-based column # into the resultSet. colNumber, boolean Whether or not the column is nullable
(No need to call wasNull() if not) isNullable)Implements org. Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet. |
| public void | setWidth(int
the desired length desiredWidth, int the desired scale (ignored) desiredScale, boolean throw an error on truncation errorOnTrunc)Implements org. Set the width of the to the desired value. |
| protected static int | Returns: -1 - op1 < op2 0 - op1 == op2 1 - op1 > op2The first String op1, String The second String op2)Compare two Strings using standard SQL semantics. |
| protected int | |
| protected static int | Returns: -1 - op1 < op2 0 - op1 == op2 1 - op1 > op2The first String op1, int leftlen, char[] The second String op2, int rightlen)Compare two Strings using standard SQL semantics. |
| public ConcatableDataValue | Returns: A ConcatableDataValue containing the result of the substr()Start of substr start, NumberDataValue Length of substr length, ConcatableDataValue The result of a previous call to this method,
null if not called yet. result, int Maximum length of the result maxLen)Implements org. The SQL substr() function. |
| protected void | throwStreamingIOException(IOException
the ioe)IOException to wrapWraps an |
| public String | |
| private String | Returns: A String containing the result of the trim.Type of trim (LEADING, TRAILING, or BOTH) trimType, char Character to trim trimChar, String String from which to trim trimChar source)This function public for testing purposes. |
| public int | typePrecedence()
Overrides org. Implements org. Each built-in type in JSQL has a precedence. |
| public int | typeToBigDecimal()
Overrides org. Implements org. CHAR/VARCHAR/LONG VARCHAR implementation. |
| public StringDataValue | upper(StringDataValue
The result (reusable - allocate if null). result)Implements org. Convert the string to upper case. |
| protected final void | writeClobUTF(ObjectOutput
destination stream out)Writes the header and the user data for a CLOB to the destination stream. |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. Writes a non-Clob data value to the modified UTF-8 format used by Derby. |
| private final void | writeUTF(ObjectOutput
destination stream out, int string length of the value strLen, final boolean true if the source is rawData, false
if the source is valueReader from _clobValue if it exists characterReader)Writes the user data value to a stream in the modified UTF-8 format. |
| private static void | writeUTF(ObjectOutput
the destination stream out, int the character to write c)Write a single character to a stream in the modified UTF-8 format. |
| public void |