| java.lang.Object org.apache.derby.iapi.types.DataType org.apache.derby.iapi.types.SQLChar
All known Subclasses: org.apache.derby.iapi.types.SQLNationalChar, org.apache.derby.iapi.types.SQLVarchar,
SQLChar | public class SQLChar extends DataType implements StringDataValue,StreamStorable(Code) | | SQLChar satisfies the DataValueDescriptor
interfaces (i.e., OrderableDataType). It implements an String holder,
e.g. for storing a column value; it can be specified
when constructed to not allow nulls. Nullability cannot be changed
after construction.
Because OrderableDataType is a subclass of DataType,
SQLChar can play a role in either a DataType/ValueRow
or a OrderableDataType/KeyRow, interchangeably.
|
Constructor Summary | |
public | SQLChar() no-arg constructor, required by Formattable. | public | SQLChar(String val) |
Method Summary | |
public NumberDataValue | charLength(NumberDataValue result) This method implements the char_length function for char. | public Object | cloneObject() From CloneableObject
Shallow clone a StreamStorable without objectifying. | public boolean | compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) | public int | compare(DataValueDescriptor other) | public StringDataValue | concatenate(StringDataValue leftOperand, StringDataValue rightOperand, StringDataValue result) | protected void | copyState(SQLChar other) | public BooleanDataValue | equals(DataValueDescriptor left, DataValueDescriptor right) The = operator as called from the language module, as opposed to
the storage module. | public int | estimateMemoryUsage() | public boolean | getBoolean() | public byte | getByte() | public char[] | getCharArray() Get a char array. | public DataValueDescriptor | getClone() | protected CollationKey | getCollationKey() | public Date | getDate(Calendar cal) | public static Date | getDate(java.util.Calendar cal, String str, LocaleFinder localeFinder) | protected DateFormat | getDateFormat() | protected DateFormat | getDateFormat(Calendar cal) | public double | getDouble() | public float | getFloat() | public int | getInt() | public int | getLength() | protected LocaleFinder | getLocaleFinder() | public long | getLong() | public DataValueDescriptor | getNewNull() | protected StringDataValue | getNewVarchar() Get a SQLVarchar for a built-in string function. | public Object | getObject() | public short | getShort() | public InputStream | getStream() | public String | getString() If possible, use getCharArray() if you don't really
need a string. | public Time | getTime(Calendar cal) | public static Time | getTime(Calendar cal, String str, LocaleFinder localeFinder) | protected DateFormat | getTimeFormat() | protected DateFormat | getTimeFormat(Calendar cal) | public Timestamp | getTimestamp(Calendar cal) | public static Timestamp | getTimestamp(java.util.Calendar cal, String str, LocaleFinder localeFinder) | protected DateFormat | getTimestampFormat() | protected DateFormat | getTimestampFormat(Calendar cal) | public int | getTypeFormatId() Return my format identifier. | public String | getTypeName() | public BooleanDataValue | greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) The >= operator as called from the language module, as opposed to
the storage module. | public 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 . | final protected void | hasNonBlankChars(String source, int start, int end) | public int | hashCode() | protected boolean | isNationalString() Return whether or not this is a national character datatype. | public boolean | isNull() see if the String value is null. | public BooleanDataValue | lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) The <= operator as called from the language module, as opposed to
the storage module. | public BooleanDataValue | lessThan(DataValueDescriptor left, DataValueDescriptor right) The < operator as called from the language module, as opposed to
the storage module. | public BooleanDataValue | like(DataValueDescriptor pattern) This method implements the like function for char (with no escape value). | public BooleanDataValue | like(DataValueDescriptor pattern, DataValueDescriptor escape) This method implements the like function for char with an escape value. | public void | loadStream() | public NumberDataValue | locate(StringDataValue searchFrom, NumberDataValue start, NumberDataValue result) This method implements the locate function for char.
Parameters: searchFrom - - The string to search from Parameters: start - - The position to search from in string searchFrom Parameters: result - - The object to returnNote: use getString() to get the string to search for. | public StringDataValue | lower(StringDataValue result) | protected Date | nationalGetDate(Calendar cal) This implements getDate() for the national types. | protected Time | nationalGetTime(Calendar cal) This implements getTime() for the national types. | protected Timestamp | nationalGetTimestamp(Calendar cal) This implements getTimestamp() for the national types. | protected int | nationalHashCode() Implementation of hashCode() for the national character types,
put here to make it accessible to all the national types. | public 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, String sourceValue) | public BooleanDataValue | notEquals(DataValueDescriptor left, DataValueDescriptor right) The <> operator as called from the language module, as opposed to
the storage module. | public void | readExternal(ObjectInput in) | public void | readExternalFromArray(ArrayInputStream in) Reads in a string from the specified data input stream. | public void | restoreToNull() | public InputStream | returnStream() | public void | setBigDecimal(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) | final public void | setInto(PreparedStatement ps, int position) Set the value into a PreparedStatement. | protected void | setLocaleFinder(LocaleFinder localeFinder) | public void | setObjectForCast(Object theValue, boolean instanceOfResultType, String resultTypeClassName) Allow any Java type to be cast to a character type using
Object.toString. | final public void | setStream(InputStream newStream) Set this value to the on-disk format stream. | public void | setValue(String theValue) | public void | setValue(boolean theValue) | public void | setValue(int theValue) | public void | setValue(double theValue) | public void | setValue(float theValue) | public void | setValue(short theValue) | public void | setValue(long theValue) | public void | setValue(byte theValue) | public void | setValue(byte[] theValue) | public void | setValue(Date theValue, Calendar cal) | public void | setValue(Time theValue, Calendar cal) | public void | setValue(Timestamp theValue, Calendar cal) | final public void | setValue(InputStream theStream, int valueLength) Set the value from the stream which is in the on-disk format. | final public void | setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) | public void | setWidth(int desiredWidth, int desiredScale, boolean errorOnTrunc) Set the width of the to the desired value. | protected int | stringCollatorCompare(SQLChar str2) Compare a localized string with this one. | protected static int | stringCompare(String op1, String op2) Compare two Strings using standard SQL semantics. | protected int | stringCompare(SQLChar char1, SQLChar char2) Compare two SQLChars. | protected static int | stringCompare(char[] op1, int leftlen, char[] op2, int rightlen) Compare two Strings using standard SQL semantics. | public ConcatableDataValue | substring(NumberDataValue start, NumberDataValue length, ConcatableDataValue result, int maxLen) The SQL substr() function. | public String | toString() | public StringDataValue | trim(int trimType, StringDataValue result) The SQL trim(), ltrim() and rtrim() functions. | public int | typePrecedence() | public int | typeToBigDecimal() CHAR/VARCHAR/LONG VARCHAR implementation. | public StringDataValue | upper(StringDataValue result) | public void | writeExternal(ObjectOutput out) The maximum stored size is based upon the UTF format
used to stored the String. |
RETURN_SPACE_THRESHOLD | final protected static int RETURN_SPACE_THRESHOLD(Code) | | threshold, that decides when we return space back to the VM
see getString() where it is used
|
arg_passer | char[][] arg_passer(Code) | | |
SQLChar | public SQLChar()(Code) | | no-arg constructor, required by Formattable.
|
cloneObject | public Object cloneObject()(Code) | | From CloneableObject
Shallow clone a StreamStorable without objectifying. This is used to avoid
unnecessary objectifying of a stream object. The only difference of this method
from getClone is this method does not objectify a stream. beetle 4896
|
estimateMemoryUsage | public int estimateMemoryUsage()(Code) | | |
getCharArray | public char[] getCharArray() throws StandardException(Code) | | Get a char array. Typically, this is a simple
getter that is cheaper than getString() because
we always need to create a char array when
doing I/O. Use this instead of getString() where
reasonable.
WARNING: may return a character array that has spare
characters at the end. MUST be used in conjunction
with getLength() to be safe.
exception: StandardException - Thrown on error |
getString | public String getString() throws StandardException(Code) | | If possible, use getCharArray() if you don't really
need a string. getString() will cause an extra
char array to be allocated when it calls the the String()
constructor (the first time through), so may be
cheaper to use getCharArray().
exception: StandardException - Thrown on error |
greaterOrEquals | public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | The >= operator as called from the language module, as opposed to
the storage module.
Parameters: left - The value on the left side of the >= Parameters: right - The value on the right side of the >= A SQL boolean value telling whether the first operand isgreater than or equal to the second operand exception: StandardException - Thrown on error |
growBy | protected int growBy()(Code) | | returns the reasonable minimum amount by
which the array can grow . See readExternal.
when we know that the array needs to grow by at least
one byte, it is not performant to grow by just one byte
instead this amount is used to provide a resonable growby size.
minimum reasonable growby size |
hashCode | public int hashCode()(Code) | | |
isNationalString | protected boolean isNationalString()(Code) | | Return whether or not this is a national character datatype.
|
lessOrEquals | public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | The <= operator as called from the language module, as opposed to
the storage module.
Parameters: left - The value on the left side of the <= Parameters: right - The value on the right side of the <= A SQL boolean value telling whether the first operand isless than or equal to the second operand exception: StandardException - Thrown on error |
locate | public NumberDataValue locate(StringDataValue searchFrom, NumberDataValue start, NumberDataValue result) throws StandardException(Code) | | This method implements the locate function for char.
Parameters: searchFrom - - The string to search from Parameters: start - - The position to search from in string searchFrom Parameters: result - - The object to returnNote: use getString() to get the string to search for. The position in searchFrom the fist occurrence of this.value.0 is returned if searchFrom does not contain this.value. exception: StandardException - Thrown on error |
nationalGetDate | protected Date nationalGetDate(Calendar cal) throws StandardException(Code) | | This implements getDate() for the national types. It lives
here so it can be shared between all the national types.
exception: StandardException - thrown on failure to convert |
nationalGetTime | protected Time nationalGetTime(Calendar cal) throws StandardException(Code) | | This implements getTime() for the national types. It lives
here so it can be shared between all the national types.
exception: StandardException - thrown on failure to convert |
nationalGetTimestamp | protected Timestamp nationalGetTimestamp(Calendar cal) throws StandardException(Code) | | This implements getTimestamp() for the national types. It lives
here so it can be shared between all the national types.
exception: StandardException - thrown on failure to convert |
nationalHashCode | protected int nationalHashCode()(Code) | | Implementation of hashCode() for the national character types,
put here to make it accessible to all the national types.
|
normalize | public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException(Code) | | Normalization method - this method may be called when putting
a value into a SQLChar, for example, when inserting into a SQLChar
column. See NormalizeResultSet in execution.
Parameters: desiredType - The type to normalize the source column to Parameters: source - The value to normalize exception: StandardException - Thrown for null intonon-nullable column, and fortruncation error |
readExternalFromArray | public void readExternalFromArray(ArrayInputStream in) throws IOException(Code) | | Reads in a string from the specified data input stream. The
string has been encoded using a modified UTF-8 format.
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.
Parameters: in - a data input stream. exception: EOFException - if the input stream reaches the endbefore all the bytes. exception: IOException - if an I/O error occurs. exception: UTFDataFormatException - if the bytes do not represent avalid UTF-8 encoding of a Unicode string. See Also: java.io.DataInputStream.readUnsignedShort See Also: java.io.Externalizable.readExternal |
setBigDecimal | public void setBigDecimal(Number bigDecimal) throws StandardException(Code) | | Only to be called when an application through JDBC is setting a
SQLChar to a java.math.BigDecimal.
|
setStream | final public void setStream(InputStream newStream)(Code) | | Set this value to the on-disk format stream.
|
setValue | final public void setValue(InputStream theStream, int valueLength)(Code) | | Set the value from the stream which is in the on-disk format.
Parameters: theStream - On disk format of the stream Parameters: valueLength - length of the logical value in characters. |
setWidth | public void setWidth(int desiredWidth, int desiredScale, boolean errorOnTrunc) throws StandardException(Code) | | Set the width of the to the desired value. Used
when CASTing. Ideally we'd recycle normalize(), but
the behavior is different (we issue a warning instead
of an error, and we aren't interested in nullability).
Parameters: desiredWidth - the desired length Parameters: desiredScale - the desired scale (ignored) Parameters: errorOnTrunc - throw an error on truncation exception: StandardException - Thrown when errorOnTruncis true and when a shrink will truncate non-whitespaces. |
stringCollatorCompare | protected int stringCollatorCompare(SQLChar str2) throws StandardException(Code) | | Compare a localized string with this one.
Parameters: str2 - The other string -1 - this < str20 - this == str21 - this > str2 |
stringCompare | protected static int stringCompare(String op1, String op2)(Code) | | Compare two Strings using standard SQL semantics.
Parameters: op1 - The first String Parameters: op2 - The second String -1 - op1 < op20 - op1 == op21 - op1 > op2 |
stringCompare | protected int stringCompare(SQLChar char1, SQLChar char2) throws StandardException(Code) | | Compare two SQLChars. This method will be overriden in the
National char wrappers so that the appropriate comparison
is done.
exception: StandardException - Thrown on error |
stringCompare | protected static int stringCompare(char[] op1, int leftlen, char[] op2, int rightlen)(Code) | | Compare two Strings using standard SQL semantics.
Parameters: op1 - The first String Parameters: op2 - The second String -1 - op1 < op20 - op1 == op21 - op1 > op2 |
trim | public StringDataValue trim(int trimType, StringDataValue result) throws StandardException(Code) | | The SQL trim(), ltrim() and rtrim() functions.
Parameters: trimType - Type of trim Parameters: result - The result of a previous call to this method,null if not called yet. A StringDataValue containing the result of the trim() exception: StandardException - Thrown on error |
typeToBigDecimal | public int typeToBigDecimal() throws StandardException(Code) | | CHAR/VARCHAR/LONG VARCHAR implementation. Convert to a BigDecimal using getString.
|
writeExternal | public void writeExternal(ObjectOutput out) throws IOException(Code) | | The maximum stored size is based upon the UTF format
used to stored the String. The format consists of
a two byte length field and a maximum number of three
bytes for each character.
This puts an upper limit on the length of a stored
String. The maximum stored length is 65535, these leads to
the worse case of a maximum string length of 21844 ((65535 - 2) / 3).
Strings with stored length longer than 64K is handled with
the following format:
(1) 2 byte length: will be assigned 0.
(2) UTF formated string data.
(3) terminate the string with the following 3 bytes:
first byte is:
+---+---+---+---+---+---+---+---+
| 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+
second byte is:
+---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+
third byte is:
+---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+
The UTF format:
Writes a string to the underlying output stream using UTF-8
encoding in a machine-independent manner.
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.
exception: IOException - if an I/O error occurs. since: JDK1.0 exception: IOException - thrown by writeUTF See Also: java.io.DataInputStream |
Methods inherited from org.apache.derby.iapi.types.DataType | public void checkHostVariable(int declaredLength) throws StandardException(Code)(Java Doc) public Object cloneObject()(Code)(Java Doc) public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException(Code)(Java Doc) public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException(Code)(Java Doc) final protected StandardException dataTypeConversion(String targetType)(Code)(Java Doc) public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public boolean equals(Object other)(Code)(Java Doc) protected static int flip(int operator)(Code)(Java Doc) void genericSetObject(Object theValue) throws StandardException(Code)(Java Doc) public boolean getBoolean() throws StandardException(Code)(Java Doc) public byte getByte() throws StandardException(Code)(Java Doc) public byte[] getBytes() throws StandardException(Code)(Java Doc) public Date getDate(Calendar cal) throws StandardException(Code)(Java Doc) public double getDouble() throws StandardException(Code)(Java Doc) public float getFloat() throws StandardException(Code)(Java Doc) public int getInt() throws StandardException(Code)(Java Doc) public long getLong() throws StandardException(Code)(Java Doc) protected String getNationalString(LocaleFinder localeFinder) throws StandardException(Code)(Java Doc) public Object getObject() throws StandardException(Code)(Java Doc) public short getShort() throws StandardException(Code)(Java Doc) public InputStream getStream() throws StandardException(Code)(Java Doc) public Time getTime(Calendar cal) throws StandardException(Code)(Java Doc) public Timestamp getTimestamp(Calendar cal) throws StandardException(Code)(Java Doc) public String getTraceString() throws StandardException(Code)(Java Doc) String getTypeName(String className)(Code)(Java Doc) public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException(Code)(Java Doc) final protected StandardException invalidFormat()(Code)(Java Doc) final public BooleanDataValue isNotNull()(Code)(Java Doc) final public BooleanDataValue isNullOp()(Code)(Java Doc) public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException(Code)(Java Doc) public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) final protected StandardException outOfRange()(Code)(Java Doc) public void setBigDecimal(Number bigDecimal) throws StandardException(Code)(Java Doc) protected void setFrom(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException(Code)(Java Doc) public void setInto(ResultSet rs, int position) throws SQLException, StandardException(Code)(Java Doc) void setObject(Object theValue) throws StandardException(Code)(Java Doc) public void setObjectForCast(Object theValue, boolean instanceOfResultType, String resultTypeClassName) throws StandardException(Code)(Java Doc) public void setToNull()(Code)(Java Doc) public void setValue(Time theValue) throws StandardException(Code)(Java Doc) public void setValue(Time theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Date theValue) throws StandardException(Code)(Java Doc) public void setValue(Date theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(String theValue) throws StandardException(Code)(Java Doc) public void setValue(int theValue) throws StandardException(Code)(Java Doc) public void setValue(double theValue) throws StandardException(Code)(Java Doc) public void setValue(float theValue) throws StandardException(Code)(Java Doc) public void setValue(short theValue) throws StandardException(Code)(Java Doc) public void setValue(long theValue) throws StandardException(Code)(Java Doc) public void setValue(byte theValue) throws StandardException(Code)(Java Doc) public void setValue(boolean theValue) throws StandardException(Code)(Java Doc) public void setValue(byte[] theValue) throws StandardException(Code)(Java Doc) final public void setValue(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setValue(InputStream theStream, int valueLength) throws StandardException(Code)(Java Doc) public void throwLangSetMismatch(Object value) throws StandardException(Code)(Java Doc) void throwLangSetMismatch(String argTypeName) throws StandardException(Code)(Java Doc) public int typePrecedence()(Code)(Java Doc) public int typeToBigDecimal() throws StandardException(Code)(Java Doc)
|
|
|