Class SQLClob
- All Implemented Interfaces:
Externalizable, Serializable, Comparable, Formatable, Storable, StreamStorable, TypedFormat, ConcatableDataValue, DataValueDescriptor, Orderable, StringDataValue, VariableSizeDataValue
- Direct Known Subclasses:
CollatorSQLClob
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classHolder class for header information gathered from the raw byte header in the stream. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CharacterStreamDescriptorThe descriptor for the stream.private BooleanTells if the database is being accessed in soft upgrade mode.private static final intThe maximum number of bytes used by the stream header.private static final StreamHeaderGeneratorThe header generator used for 10.5 databases.private static final StreamHeaderGeneratorThe header generator used for 10.4 (or older) databases.Fields inherited from class SQLChar
_clobValue, arg_passer, CHAR_HEADER_GENERATOR, RETURN_SPACE_THRESHOLD, streamFields inherited from interface DataValueDescriptor
UNKNOWN_LOGICAL_LENGTHFields inherited from interface Orderable
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHANFields inherited from interface StringDataValue
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, TRAILINGFields inherited from interface VariableSizeDataValue
IGNORE_PRECISION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloneValue(boolean forceMaterialization) Returns a clone of this CLOB value.booleanGet Boolean from a SQLChar.bytegetByte()Get Byte from a SQLChar.byte[]getBytes()Gets the value in the data value descriptor as a byte[].Get date from a SQLChar.doubleGet double from a SQLChar.floatgetFloat()Get float from a SQLChar.intgetInt()Get int from a SQLChar.intReturns the character length of this Clob.longgetLong()Get long from a SQLChar.Get a new null value of the same type as this data value.Gets the value in the data value descriptor as a int.shortgetShort()Get Short from a SQLChar.Returns a stream header generator for a Clob.Returns a descriptor for the input stream for this CLOB value.Get time from a SQLChar.getTimestamp(Calendar cal) Get Timestamp from a SQLChar.final StringGets a trace representation of the CLOB for debugging.intReturn my format identifier.Get the SQL name of the datatypegetValue(RuleBasedCollator collatorForComparison) Gets either SQLChar/SQLVarchar/SQLLongvarchar/SQLClob(base classes) or CollatorSQLChar/CollatorSQLVarchar/CollatorSQLLongvarch/CollatorSQLClob (subclasses).booleanTells if this CLOB value is, or will be, represented by a stream.private SQLClob.HeaderInfoinvestigateHeader(byte[] hdr, int bytesRead) Investigates the header and returns length information.voidnormalize(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.voidReads and materializes the CLOB value from the stream.voidReads and materializes the CLOB value from the stream.final voidRestore this object to its (SQL)null value.private voidrewindStream(InputStream in, long offset) Rewinds the stream to the beginning and then skips the specified number of bytes.voidsetBigDecimal(BigDecimal bigDecimal) Only to be called when an application through JDBC is setting a SQLChar to a java.math.BigDecimal.(package private) final voidSet the value from an non-null Java.sql.Clob object.final voidsetStream(InputStream stream) Sets a new stream for this CLOB.voidsetStreamHeaderFormat(Boolean inSoftUpgradeMode) Tells whether the database is being accessed in soft upgrade mode or not.voidsetValue(boolean theValue) Set the value.voidsetValue(byte theValue) Set the value of this DataValueDescriptor to the given byte value At DataType level just throws an error lower classes will overridevoidsetValue(byte[] theValue) Set the value of this DataValueDescriptor.voidsetValue(double theValue) Set the value of this DataValueDescriptor to the given double value At DataType level just throws an error lower classes will overridevoidsetValue(float theValue) Set the value of this DataValueDescriptor to the given float value At DataType level just throws an error lower classes will overridevoidsetValue(int theValue) Set the value of this DataValueDescriptor to the given int value At DataType level just throws an error lower classes will overridevoidsetValue(long theValue) Set the value of this DataValueDescriptor to the given long value At DataType level just throws an error lower classes will overridevoidsetValue(short theValue) Set the value of this DataValueDescriptor to the given short value At DataType level just throws an error lower classes will overridevoidSet the value of this DataValueDescriptor.voidSet the value of this DataValueDescriptor.voidSet the value of this DataValueDescriptor.intEach built-in type in JSQL has a precedence.intCHAR/VARCHAR/LONG VARCHAR implementation.voidWrites the CLOB data value to the given destination stream using the modified UTF-8 format.Methods inherited from class SQLVarchar
growBy, normalizeMethods inherited from class SQLChar
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, zeroRawDataMethods inherited from class DataType
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
-
Field Details
-
TEN_FOUR_CLOB_HEADER_GENERATOR
The header generator used for 10.4 (or older) databases. -
TEN_FIVE_CLOB_HEADER_GENERATOR
The header generator used for 10.5 databases. -
MAX_STREAM_HEADER_LENGTH
private static final int MAX_STREAM_HEADER_LENGTHThe maximum number of bytes used by the stream header.Use the length specified by the ten five header generator.
-
csd
The descriptor for the stream. If there is no stream this should benull, which is also true if the descriptor hasen't been constructed yet. Note: Always check ifstreamis non-null before using the information stored in the descriptor internally. -
inSoftUpgradeMode
Tells if the database is being accessed in soft upgrade mode.
-
-
Constructor Details
-
SQLClob
public SQLClob() -
SQLClob
-
SQLClob
-
-
Method Details
-
getTypeName
Description copied from interface:DataValueDescriptorGet the SQL name of the datatype- Specified by:
getTypeNamein interfaceDataValueDescriptor- Overrides:
getTypeNamein classSQLVarchar- Returns:
- The SQL name of the datatype
-
cloneValue
Returns a clone of this CLOB value.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.
- Specified by:
cloneValuein interfaceDataValueDescriptor- Overrides:
cloneValuein classSQLVarchar- Parameters:
forceMaterialization- any streams representing the data value will be materialized iftrue, the data value will be kept as a stream if possible iffalse- Returns:
- A clone of this CLOB value.
- See Also:
-
getNewNull
Description copied from interface:DataValueDescriptorGet a new null value of the same type as this data value.- Specified by:
getNewNullin interfaceDataValueDescriptor- Overrides:
getNewNullin classSQLVarchar- See Also:
-
getValue
Description copied from interface:StringDataValueGets 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.- Specified by:
getValuein interfaceStringDataValue- Overrides:
getValuein classSQLVarchar- See Also:
-
getTypeFormatId
public int getTypeFormatId()Return my format identifier.- Specified by:
getTypeFormatIdin interfaceTypedFormat- Overrides:
getTypeFormatIdin classSQLVarchar- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
- See Also:
-
typePrecedence
public int typePrecedence()Description copied from class:DataTypeEach 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.- Specified by:
typePrecedencein interfaceDataValueDescriptor- Overrides:
typePrecedencein classSQLVarchar- Returns:
- The precedence of this type.
- See Also:
-
getBoolean
Description copied from class:SQLCharGet Boolean from a 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.
- Specified by:
getBooleanin interfaceDataValueDescriptor- Overrides:
getBooleanin classSQLChar- Returns:
- The data value as a boolean.
- Throws:
StandardException- Thrown on error- See Also:
-
getByte
Description copied from class:SQLCharGet Byte from a SQLChar.Uses java standard Byte.parseByte() to perform coercion.
- Specified by:
getBytein interfaceDataValueDescriptor- Overrides:
getBytein classSQLChar- Returns:
- The data value as a byte.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getShort
Description copied from class:SQLCharGet Short from a SQLChar.Uses java standard Short.parseShort() to perform coercion.
- Specified by:
getShortin interfaceDataValueDescriptor- Overrides:
getShortin classSQLChar- Returns:
- The data value as a short.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getInt
Description copied from class:SQLCharGet int from a SQLChar.Uses java standard Short.parseInt() to perform coercion.
- Specified by:
getIntin interfaceDataValueDescriptor- Overrides:
getIntin classSQLChar- Returns:
- The data value as a int.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getLength
Returns the character length of this Clob.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.
- Specified by:
getLengthin interfaceDataValueDescriptor- Overrides:
getLengthin classSQLChar- Returns:
- The character length of this Clob.
- Throws:
StandardException- if obtaining the length fails
-
getLong
Description copied from class:SQLCharGet long from a SQLChar.Uses java standard Short.parseLong() to perform coercion.
- Specified by:
getLongin interfaceDataValueDescriptor- Overrides:
getLongin classSQLChar- Returns:
- The data value as a long.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getFloat
Description copied from class:SQLCharGet float from a SQLChar.Uses java standard Float.floatValue() to perform coercion.
- Specified by:
getFloatin interfaceDataValueDescriptor- Overrides:
getFloatin classSQLChar- Returns:
- The data value as a float.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getDouble
Description copied from class:SQLCharGet double from a SQLChar.Uses java standard Double.doubleValue() to perform coercion.
- Specified by:
getDoublein interfaceDataValueDescriptor- Overrides:
getDoublein classSQLChar- Returns:
- The data value as a double.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
typeToBigDecimal
Description copied from class:SQLCharCHAR/VARCHAR/LONG VARCHAR implementation. Convert to a BigDecimal using getString.- Specified by:
typeToBigDecimalin interfaceDataValueDescriptor- Overrides:
typeToBigDecimalin classSQLChar- Returns:
- Types.CHAR for String conversion through getString Types.DECIMAL for BigDecimal through getObject or Types.BIGINT for long conversion through getLong
- Throws:
StandardException- Conversion is not possible
-
getBytes
Description copied from class:DataTypeGets the value in the data value descriptor as a byte[]. Throws an exception if the data value is not receivable as a Binary or Varbinary.- Specified by:
getBytesin interfaceDataValueDescriptor- Overrides:
getBytesin classDataType- Returns:
- The Binary value as a byte[].
- Throws:
StandardException- Thrown on error
-
getDate
Description copied from class:SQLCharGet date from a SQLChar.- Specified by:
getDatein interfaceDataValueDescriptor- Overrides:
getDatein classSQLChar- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Date.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getObject
Description copied from class:DataTypeGets the value in the data value descriptor as a int. Throws an exception if the data value is not receivable as a int.- Specified by:
getObjectin interfaceDataValueDescriptor- Overrides:
getObjectin classSQLChar- Returns:
- The data value as a int.
- Throws:
StandardException- Thrown on error
-
getStreamWithDescriptor
Returns a descriptor for the input stream for this CLOB value.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.
- Specified by:
getStreamWithDescriptorin interfaceStringDataValue- Overrides:
getStreamWithDescriptorin classSQLChar- Returns:
- A descriptor for the stream, which includes a reference to the
stream itself. If the value cannot be represented as a stream,
nullis returned instead of a descriptor. - Throws:
StandardException- if obtaining the descriptor fails- See Also:
-
hasStream
public boolean hasStream()Tells if this CLOB value is, or will be, represented by a stream.- Specified by:
hasStreamin interfaceDataValueDescriptor- Overrides:
hasStreamin classDataType- Returns:
trueif the value is represented by a stream,falseotherwise.- See Also:
-
getTime
Description copied from class:SQLCharGet time from a SQLChar.- Specified by:
getTimein interfaceDataValueDescriptor- Overrides:
getTimein classSQLChar- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Time.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getTimestamp
Description copied from class:SQLCharGet Timestamp from a SQLChar.- Specified by:
getTimestampin interfaceDataValueDescriptor- Overrides:
getTimestampin classSQLChar- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Timestamp.
- Throws:
StandardException- thrown on failure to convert- See Also:
-
getTraceString
Gets a trace representation of the CLOB for debugging.- Specified by:
getTraceStringin interfaceDataValueDescriptor- Overrides:
getTraceStringin classSQLChar- Returns:
- a trace representation of the CLOB.
- Throws:
StandardException- if getting the data value fails.- See Also:
-
normalize
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor sourceValue) throws StandardException Normalization method - this method may be called when putting a value into a SQLClob, for example, when inserting into a SQLClob column. See NormalizeResultSet in execution. Per the SQL standard ,if the clob column is not big enough to hold the value being inserted,truncation error will result if there are trailing non-blanks. Truncation of trailing blanks is allowed.- Specified by:
normalizein interfaceDataValueDescriptor- Overrides:
normalizein classSQLVarchar- Parameters:
desiredType- The type to normalize the source column tosourceValue- The value to normalize- Throws:
StandardException- Thrown for null into non-nullable column, and for truncation error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The Time value to set this DataValueDescriptor tocal- The time zone from the calendar is used to construct the database time value- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The Timestamp value to set this DataValueDescriptor tocal- The time zone from the calendar is used to construct the database timestamp value- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The Date value to set this DataValueDescriptor tocal- The time zone from the calendar is used to construct the database date value- Throws:
StandardException- Thrown on error
-
setBigDecimal
Description copied from class:SQLCharOnly to be called when an application through JDBC is setting a SQLChar to a java.math.BigDecimal.- Specified by:
setBigDecimalin interfaceDataValueDescriptor- Overrides:
setBigDecimalin classSQLChar- Parameters:
bigDecimal- required to be a BigDecimal or null.- Throws:
StandardException
-
setStream
Sets a new stream for this CLOB.- Specified by:
setStreamin interfaceStreamStorable- Overrides:
setStreamin classSQLChar- Parameters:
stream- the new stream
-
restoreToNull
public final void restoreToNull()Description copied from interface:StorableRestore this object to its (SQL)null value.- Specified by:
restoreToNullin interfaceStorable- Overrides:
restoreToNullin classSQLChar- See Also:
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor to the given int value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor to the given double value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor to the given float value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor to the given short value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor to the given long value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor to the given byte value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
Description copied from class:DataTypeSet the value. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- Contains the boolean value to set this to- Throws:
StandardException
-
setValue
Description copied from class:DataTypeSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classSQLChar- Parameters:
theValue- The byte value to set this DataValueDescriptor to- Throws:
StandardException
-
setObject
Set the value from an non-null Java.sql.Clob object.- Overrides:
setObjectin classDataType- Throws:
StandardException
-
writeExternal
Writes the CLOB data value to the given destination stream using the modified UTF-8 format.- Specified by:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classSQLChar- Parameters:
out- destination stream- Throws:
IOException- if writing to the destination stream fails- See Also:
-
getStreamHeaderGenerator
Returns a stream header generator for a Clob.NOTE: To guarantee a successful generation, one of the following two conditions must be met at header or EOF generation time:
setStreamHeaderFormathas been invoked before the header generator was obtained.- There is context at generation time, such that the mode can be determined by obtaining the database context and by consulting the data dictionary.
- Specified by:
getStreamHeaderGeneratorin interfaceStringDataValue- Overrides:
getStreamHeaderGeneratorin classSQLChar- Returns:
- A stream header generator.
- See Also:
-
setStreamHeaderFormat
Tells whether the database is being accessed in soft upgrade mode or not.- Specified by:
setStreamHeaderFormatin interfaceStringDataValue- Overrides:
setStreamHeaderFormatin classSQLChar- Parameters:
inSoftUpgradeMode-TRUEif the database is accessed in soft upgrade mode,FALSEis not, ornullif unknown
-
investigateHeader
Investigates the header and returns length information.- Parameters:
hdr- the raw header bytesbytesRead- number of bytes written into the raw header bytes array- Returns:
- The information obtained from the header.
- Throws:
IOException- if the header format is invalid, or the stream seems to have been corrupted
-
readExternal
Reads and materializes the CLOB value from the stream.- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classSQLChar- Parameters:
in- source stream- Throws:
UTFDataFormatException- if an encoding error is detectedIOException- if reading from the stream fails, or the content of the stream header is invalid
-
readExternalFromArray
Reads and materializes the CLOB value from the stream.- Specified by:
readExternalFromArrayin interfaceDataValueDescriptor- Overrides:
readExternalFromArrayin classSQLChar- Parameters:
in- source stream- Throws:
UTFDataFormatException- if an encoding error is detectedIOException- if reading from the stream fails, or the content of the stream header is invalid- See Also:
-
rewindStream
Rewinds the stream to the beginning and then skips the specified number of bytes.- Parameters:
in- input stream to rewindoffset- number of bytes to skip- Throws:
IOException- if resetting or reading from the stream fails
-