Package org.apache.cayenne.access.types
Class CharType
java.lang.Object
org.apache.cayenne.access.types.CharType
- All Implemented Interfaces:
ExtendedType<String>
- Direct Known Subclasses:
OracleCharType
public class CharType extends Object implements ExtendedType<String>
Handles
java.lang.String, mapping it as either of JDBC types -
CLOB or (VAR)CHAR. Can be configured to trim trailing spaces.-
Field Summary
Fields Modifier and Type Field Description protected booleantrimmingCharsprotected booleanusingClobs -
Constructor Summary
Constructors Constructor Description CharType(boolean trimmingChars, boolean usingClobs) -
Method Summary
Modifier and Type Method Description StringgetClassName()Returns "java.lang.String".booleanisTrimmingChars()Returnstrueif 'materializeObject' method should trim trailing spaces from the CHAR columns.booleanisUsingClobs()StringmaterializeObject(CallableStatement cs, int index, int type)Reads an object from a stored procedure OUT parameter, converting it to class returned by 'getClassName' method.StringmaterializeObject(ResultSet rs, int index, int type)Return trimmed string.protected StringreadCharStream(ResultSet rs, int index)protected StringreadClob(Clob clob)protected StringreadValueStream(Reader in, int streamSize, int bufSize)protected Stringrtrim(String value)Trim right spaces.voidsetJdbcObject(PreparedStatement st, String value, int pos, int type, int scale)Initializes a single parameter of a PreparedStatement with object value.voidsetTrimmingChars(boolean trimingChars)voidsetUsingClobs(boolean usingClobs)StringtoString(String value)Converts value of the supported type to a human-readable String representation.
-
Field Details
-
trimmingChars
protected boolean trimmingChars -
usingClobs
protected boolean usingClobs
-
-
Constructor Details
-
CharType
public CharType(boolean trimmingChars, boolean usingClobs)
-
-
Method Details
-
getClassName
Returns "java.lang.String".- Specified by:
getClassNamein interfaceExtendedType<String>
-
materializeObject
Return trimmed string.- Specified by:
materializeObjectin interfaceExtendedType<String>- Throws:
Exception- if read error occurred, or an object can't be converted to a target Java class.
-
materializeObject
Description copied from interface:ExtendedTypeReads an object from a stored procedure OUT parameter, converting it to class returned by 'getClassName' method.- Specified by:
materializeObjectin interfaceExtendedType<String>- Throws:
Exception- if read error occurred, or an object can't be converted to a target Java class.
-
rtrim
Trim right spaces. -
setJdbcObject
public void setJdbcObject(PreparedStatement st, String value, int pos, int type, int scale) throws ExceptionDescription copied from interface:ExtendedTypeInitializes a single parameter of a PreparedStatement with object value.- Specified by:
setJdbcObjectin interfaceExtendedType<String>- Throws:
Exception
-
toString
Description copied from interface:ExtendedTypeConverts value of the supported type to a human-readable String representation.- Specified by:
toStringin interfaceExtendedType<String>- Parameters:
value- a value to convert to String.
-
readClob
- Throws:
IOExceptionSQLException
-
readCharStream
- Throws:
IOExceptionSQLException
-
readValueStream
- Throws:
IOException
-
isTrimmingChars
public boolean isTrimmingChars()Returnstrueif 'materializeObject' method should trim trailing spaces from the CHAR columns. This addresses an issue with some JDBC drivers (e.g. Oracle), that return Strings for CHAR columns padded with spaces. -
setTrimmingChars
public void setTrimmingChars(boolean trimingChars) -
isUsingClobs
public boolean isUsingClobs() -
setUsingClobs
public void setUsingClobs(boolean usingClobs)
-