java.io.Externalizable
, java.io.Serializable
, java.lang.Comparable
, Formatable
, Storable
, StreamStorable
, TypedFormat
, ConcatableDataValue
, DataValueDescriptor
, Orderable
, StringDataValue
, VariableSizeDataValue
CollatorSQLClob
public class SQLClob extends SQLVarchar
Modifier and Type | Class | Description |
---|---|---|
private static class |
SQLClob.HeaderInfo |
Holder class for header information gathered from the raw byte header in
the stream.
|
Modifier and Type | Field | Description |
---|---|---|
private CharacterStreamDescriptor |
csd |
The descriptor for the stream.
|
private java.lang.Boolean |
inSoftUpgradeMode |
Tells if the database is being accessed in soft upgrade mode.
|
private static int |
MAX_STREAM_HEADER_LENGTH |
The maximum number of bytes used by the stream header.
|
private static StreamHeaderGenerator |
TEN_FIVE_CLOB_HEADER_GENERATOR |
The header generator used for 10.5 databases.
|
private static StreamHeaderGenerator |
TEN_FOUR_CLOB_HEADER_GENERATOR |
The header generator used for 10.4 (or older) databases.
|
UNKNOWN_LOGICAL_LENGTH
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
_clobValue, arg_passer, CHAR_HEADER_GENERATOR, RETURN_SPACE_THRESHOLD, stream
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, TRAILING
IGNORE_PRECISION
Constructor | Description |
---|---|
SQLClob() |
|
SQLClob(java.lang.String val) |
|
SQLClob(java.sql.Clob val) |
Modifier and Type | Method | Description |
---|---|---|
DataValueDescriptor |
cloneValue(boolean forceMaterialization) |
Returns a clone of this CLOB value.
|
boolean |
getBoolean() |
Get Boolean from a SQLChar.
|
byte |
getByte() |
Get Byte from a SQLChar.
|
byte[] |
getBytes() |
Gets the value in the data value descriptor as a byte[].
|
java.sql.Date |
getDate(java.util.Calendar cal) |
Get date from a SQLChar.
|
double |
getDouble() |
Get double from a SQLChar.
|
float |
getFloat() |
Get float from a SQLChar.
|
int |
getInt() |
Get int from a SQLChar.
|
int |
getLength() |
Returns the character length of this Clob.
|
long |
getLong() |
Get long from a SQLChar.
|
DataValueDescriptor |
getNewNull() |
Get a new null value of the same type as this data value.
|
java.lang.Object |
getObject() |
Gets the value in the data value descriptor as a int.
|
short |
getShort() |
Get Short from a SQLChar.
|
StreamHeaderGenerator |
getStreamHeaderGenerator() |
Returns a stream header generator for a Clob.
|
CharacterStreamDescriptor |
getStreamWithDescriptor() |
Returns a descriptor for the input stream for this CLOB value.
|
java.sql.Time |
getTime(java.util.Calendar cal) |
Get time from a SQLChar.
|
java.sql.Timestamp |
getTimestamp(java.util.Calendar cal) |
Get Timestamp from a SQLChar.
|
java.lang.String |
getTraceString() |
Gets a trace representation of the CLOB for debugging.
|
int |
getTypeFormatId() |
Return my format identifier.
|
java.lang.String |
getTypeName() |
Get the SQL name of the datatype
|
StringDataValue |
getValue(java.text.RuleBasedCollator collatorForComparison) |
Gets either SQLChar/SQLVarchar/SQLLongvarchar/SQLClob(base classes) or
CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarch/CollatorSQLClob
(subclasses).
|
boolean |
hasStream() |
Tells if this CLOB value is, or will be, represented by a stream.
|
private SQLClob.HeaderInfo |
investigateHeader(byte[] hdr,
int bytesRead) |
Investigates the header and returns length information.
|
void |
normalize(DataTypeDescriptor desiredType,
DataValueDescriptor sourceValue) |
Normalization method - this method may be called when putting
a value into a SQLClob, for example, when inserting into a SQLClob
column.
|
void |
readExternal(java.io.ObjectInput in) |
Reads and materializes the CLOB value from the stream.
|
void |
readExternalFromArray(ArrayInputStream in) |
Reads and materializes the CLOB value from the stream.
|
void |
restoreToNull() |
Restore this object to its (SQL)null value.
|
private void |
rewindStream(java.io.InputStream in,
long offset) |
Rewinds the stream to the beginning and then skips the specified number
of bytes.
|
void |
setBigDecimal(java.math.BigDecimal bigDecimal) |
Only to be called when an application through JDBC is setting a
SQLChar to a java.math.BigDecimal.
|
(package private) void |
setObject(java.lang.Object theValue) |
Set the value from an non-null Java.sql.Clob object.
|
void |
setStream(java.io.InputStream stream) |
Sets a new stream for this CLOB.
|
void |
setStreamHeaderFormat(java.lang.Boolean inSoftUpgradeMode) |
Tells whether the database is being accessed in soft upgrade mode or not.
|
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(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(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.sql.Date theValue,
java.util.Calendar cal) |
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.
|
int |
typePrecedence() |
Each built-in type in JSQL has a precedence.
|
int |
typeToBigDecimal() |
CHAR/VARCHAR/LONG VARCHAR implementation.
|
void |
writeExternal(java.io.ObjectOutput out) |
Writes the CLOB data value to the given destination stream using the
modified UTF-8 format.
|
checkHostVariable, coalesce, compare, compare, compareTo, dataTypeConversion, equals, flip, genericSetObject, getTypeName, in, invalidFormat, isNotNull, isNullOp, outOfRange, recycle, setInto, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch
checkHostVariable, coalesce, compare, compare, in, isNotNull, isNullOp, recycle, setInto, setToNull, setValue, setValue, setValue, setValue, setValue, setValue
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
ansiTrim, charLength, cloneHolder, compare, compare, concatenate, copyState, equals, estimateMemoryUsage, getCharArray, getCollationKey, getCollatorForCollation, getDate, getLocaleFinder, getNewVarchar, getRawDataAndZeroIt, getStream, getString, getTime, getTimestamp, greaterOrEquals, greaterThan, hashCode, hashCodeForCollation, hasNonBlankChars, isNull, lessOrEquals, lessThan, like, like, loadStream, locate, lower, notEquals, readExternal, readExternalClobFromArray, returnStream, setFrom, setInto, setLocaleFinder, setObjectForCast, setValue, setValue, setValue, setValueFromResultSet, setWidth, stringCompare, stringCompare, stringCompare, substring, throwStreamingIOException, toString, upper, writeClobUTF, zeroRawData
growBy, normalize
private static final StreamHeaderGenerator TEN_FOUR_CLOB_HEADER_GENERATOR
private static final StreamHeaderGenerator TEN_FIVE_CLOB_HEADER_GENERATOR
private static final int MAX_STREAM_HEADER_LENGTH
Use the length specified by the ten five header generator.
private CharacterStreamDescriptor csd
null
, which is also true if the descriptor hasen't been
constructed yet.
Note: Always check if stream
is non-null before using
the information stored in the descriptor internally.private java.lang.Boolean inSoftUpgradeMode
public SQLClob()
public SQLClob(java.lang.String val)
public SQLClob(java.sql.Clob val)
public java.lang.String getTypeName()
DataValueDescriptor
getTypeName
in interface DataValueDescriptor
getTypeName
in class SQLVarchar
public DataValueDescriptor cloneValue(boolean forceMaterialization)
Unlike the other binary types, CLOBs can be very large. We try to clone the underlying stream when possible to avoid having to materialize the value into memory.
cloneValue
in interface DataValueDescriptor
cloneValue
in class SQLVarchar
forceMaterialization
- any streams representing the data value will
be materialized if true
, the data value will be kept as a
stream if possible if false
DataValueDescriptor.cloneValue(boolean)
public DataValueDescriptor getNewNull()
DataValueDescriptor
getNewNull
in interface DataValueDescriptor
getNewNull
in class SQLVarchar
DataValueDescriptor.getNewNull()
public StringDataValue getValue(java.text.RuleBasedCollator collatorForComparison)
StringDataValue
getValue
in interface StringDataValue
getValue
in class SQLVarchar
StringDataValue.getValue(RuleBasedCollator)
public int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
getTypeFormatId
in class SQLVarchar
TypedFormat.getTypeFormatId()
public int typePrecedence()
DataType
typePrecedence
in interface DataValueDescriptor
typePrecedence
in class SQLVarchar
DataValueDescriptor.typePrecedence()
public boolean getBoolean() throws StandardException
SQLChar
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 DataValueDescriptor
getBoolean
in class SQLChar
StandardException
- Thrown on errorDataValueDescriptor.getBoolean()
public byte getByte() throws StandardException
SQLChar
Uses java standard Byte.parseByte() to perform coercion.
getByte
in interface DataValueDescriptor
getByte
in class SQLChar
StandardException
- thrown on failure to convertDataValueDescriptor.getByte()
public short getShort() throws StandardException
SQLChar
Uses java standard Short.parseShort() to perform coercion.
getShort
in interface DataValueDescriptor
getShort
in class SQLChar
StandardException
- thrown on failure to convertDataValueDescriptor.getShort()
public int getInt() throws StandardException
SQLChar
Uses java standard Short.parseInt() to perform coercion.
getInt
in interface DataValueDescriptor
getInt
in class SQLChar
StandardException
- thrown on failure to convertDataValueDescriptor.getInt()
public int getLength() throws StandardException
If the value is stored as a stream, the stream header will be read. If the stream header doesn't contain the stream length, the whole stream will be decoded to determine the length.
getLength
in interface DataValueDescriptor
getLength
in class SQLChar
StandardException
- if obtaining the length failspublic long getLong() throws StandardException
SQLChar
Uses java standard Short.parseLong() to perform coercion.
getLong
in interface DataValueDescriptor
getLong
in class SQLChar
StandardException
- thrown on failure to convertDataValueDescriptor.getLong()
public float getFloat() throws StandardException
SQLChar
Uses java standard Float.floatValue() to perform coercion.
getFloat
in interface DataValueDescriptor
getFloat
in class SQLChar
StandardException
- thrown on failure to convertDataValueDescriptor.getFloat()
public double getDouble() throws StandardException
SQLChar
Uses java standard Double.doubleValue() to perform coercion.
getDouble
in interface DataValueDescriptor
getDouble
in class SQLChar
StandardException
- thrown on failure to convertDataValueDescriptor.getDouble()
public int typeToBigDecimal() throws StandardException
SQLChar
typeToBigDecimal
in interface DataValueDescriptor
typeToBigDecimal
in class SQLChar
StandardException
- Conversion is not possiblepublic byte[] getBytes() throws StandardException
DataType
getBytes
in interface DataValueDescriptor
getBytes
in class DataType
StandardException
- Thrown on errorpublic java.sql.Date getDate(java.util.Calendar cal) throws StandardException
SQLChar
getDate
in interface DataValueDescriptor
getDate
in class SQLChar
cal
- calendar for object creationStandardException
- thrown on failure to convertDataValueDescriptor.getDate(java.util.Calendar)
public java.lang.Object getObject() throws StandardException
DataType
getObject
in interface DataValueDescriptor
getObject
in class SQLChar
StandardException
- Thrown on errorpublic CharacterStreamDescriptor getStreamWithDescriptor() throws StandardException
The descriptor contains information about header data, current positions, length, whether the stream should be buffered or not, and if the stream is capable of repositioning itself.
When this method returns, the stream is positioned on the first character position, such that the next read will return the first character in the stream.
getStreamWithDescriptor
in interface StringDataValue
getStreamWithDescriptor
in class SQLChar
null
is returned instead of a descriptor.StandardException
- if obtaining the descriptor failsgetStreamWithDescriptor()
public boolean hasStream()
hasStream
in interface DataValueDescriptor
hasStream
in class DataType
true
if the value is represented by a stream,
false
otherwise.DataValueDescriptor.getStream()
,
StringDataValue.getStreamWithDescriptor()
public java.sql.Time getTime(java.util.Calendar cal) throws StandardException
SQLChar
getTime
in interface DataValueDescriptor
getTime
in class SQLChar
cal
- calendar for object creationStandardException
- thrown on failure to convertDataValueDescriptor.getTime(java.util.Calendar)
public java.sql.Timestamp getTimestamp(java.util.Calendar cal) throws StandardException
SQLChar
getTimestamp
in interface DataValueDescriptor
getTimestamp
in class SQLChar
cal
- calendar for object creationStandardException
- thrown on failure to convertDataValueDescriptor.getTimestamp(java.util.Calendar)
public final java.lang.String getTraceString() throws StandardException
getTraceString
in interface DataValueDescriptor
getTraceString
in class SQLChar
StandardException
- if getting the data value fails.DataValueDescriptor.getString()
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor sourceValue) throws StandardException
normalize
in interface DataValueDescriptor
normalize
in class SQLVarchar
desiredType
- The type to normalize the source column tosourceValue
- The value to normalizeStandardException
- Thrown for null into
non-nullable column, and for
truncation errorpublic void setValue(java.sql.Time theValue, java.util.Calendar cal) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- 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
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The Timestamp value to set this DataValueDescriptor tocal
- The time zone from the calendar is used to construct the database timestamp valueStandardException
- Thrown on errorpublic void setValue(java.sql.Date theValue, java.util.Calendar cal) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- 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 setBigDecimal(java.math.BigDecimal bigDecimal) throws StandardException
SQLChar
setBigDecimal
in interface DataValueDescriptor
setBigDecimal
in class SQLChar
bigDecimal
- required to be a BigDecimal or null.StandardException
public final void setStream(java.io.InputStream stream)
setStream
in interface StreamStorable
setStream
in class SQLChar
stream
- the new streampublic final void restoreToNull()
Storable
restoreToNull
in interface Storable
restoreToNull
in class SQLChar
Storable.restoreToNull()
public void setValue(int theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(double theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(float theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(short theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(long theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(byte theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(boolean theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- Contains the boolean value to set this toStandardException
public void setValue(byte[] theValue) throws StandardException
DataType
setValue
in interface DataValueDescriptor
setValue
in class SQLChar
theValue
- The byte value to set this DataValueDescriptor toStandardException
final void setObject(java.lang.Object theValue) throws StandardException
setObject
in class DataType
StandardException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class SQLChar
out
- destination streamjava.io.IOException
- if writing to the destination stream failsDataInputStream
public StreamHeaderGenerator getStreamHeaderGenerator()
NOTE: To guarantee a successful generation, one of the following two conditions must be met at header or EOF generation time:
setStreamHeaderFormat
has been invoked before the header
generator was obtained.getStreamHeaderGenerator
in interface StringDataValue
getStreamHeaderGenerator
in class SQLChar
StringDataValue.setStreamHeaderFormat(java.lang.Boolean)
public void setStreamHeaderFormat(java.lang.Boolean inSoftUpgradeMode)
setStreamHeaderFormat
in interface StringDataValue
setStreamHeaderFormat
in class SQLChar
inSoftUpgradeMode
- TRUE
if the database is accessed in
soft upgrade mode, FALSE
is not, or null
if unknownprivate SQLClob.HeaderInfo investigateHeader(byte[] hdr, int bytesRead) throws java.io.IOException
hdr
- the raw header bytesbytesRead
- number of bytes written into the raw header bytes arrayjava.io.IOException
- if the header format is invalid, or the stream
seems to have been corruptedpublic void readExternal(java.io.ObjectInput in) throws java.io.IOException
readExternal
in interface java.io.Externalizable
readExternal
in class SQLChar
in
- source streamjava.io.UTFDataFormatException
- if an encoding error is detectedjava.io.IOException
- if reading from the stream fails, or the content of
the stream header is invalidpublic void readExternalFromArray(ArrayInputStream in) throws java.io.IOException
readExternalFromArray
in interface DataValueDescriptor
readExternalFromArray
in class SQLChar
in
- source streamjava.io.UTFDataFormatException
- if an encoding error is detectedjava.io.IOException
- if reading from the stream fails, or the content of
the stream header is invalidDataInputStream.readUnsignedShort()
,
Externalizable.readExternal(java.io.ObjectInput)
private void rewindStream(java.io.InputStream in, long offset) throws java.io.IOException
in
- input stream to rewindoffset
- number of bytes to skipjava.io.IOException
- if resetting or reading from the stream failsApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.