# Class CharType

java.lang.Object
org.apache.cayenne.access.types.CharType

All Implemented Interfaces:
  `ExtendedType<String>`

Direct Known Subclasses:
  `H2CharType, 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 boolean`
  `trimmingChars`
  `protected boolean`
  `usingClobs`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CharType(boolean trimmingChars, boolean usingClobs)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getClassName()`
  Returns "java.lang.String".
  `boolean`
  `isTrimmingChars()`
  Returns `true` if 'materializeObject' method should trim trailing spaces from the CHAR columns.
  `boolean`
  `isUsingClobs()`
  `String`
  `materializeObject(CallableStatement cs, int index, int type)`
  Reads an object from a stored procedure OUT parameter, converting it to class returned by 'getClassName' method.
  `String`
  `materializeObject(ResultSet rs, int index, int type)`
  Return trimmed string.
  `protected String`
  `readCharStream(ResultSet rs, int index)`
  `protected String`
  `readClob(Clob clob)`
  `protected String`
  `readValueStream(Reader in, int streamSize, int bufSize)`
  `protected String`
  `rtrim(String value)`
  Trim right spaces.
  `void`
  `setJdbcObject(PreparedStatement st, String value, int pos, int type, int scale)`
  Initializes a single parameter of a PreparedStatement with object value.
  `void`
  `setTrimmingChars(boolean trimingChars)`
  `void`
  `setUsingClobs(boolean usingClobs)`
  `String`
  `toString(String value)`
  Converts value of the supported type to a human-readable String representation.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### trimmingChars

    protected boolean trimmingChars

  - ### usingClobs

    protected boolean usingClobs

- ## Constructor Details

  - ### CharType

    public CharType(boolean trimmingChars, boolean usingClobs)

- ## Method Details

  - ### getClassName

    public String getClassName()
    Returns "java.lang.String".
    Specified by:
      `getClassName` in interface `ExtendedType<String>`

  - ### materializeObject

    public String materializeObject(ResultSet rs, int index, int type) throws Exception
    Return trimmed string.
    Specified by:
      `materializeObject` in interface `ExtendedType<String>`
    Throws:
      `Exception` - if read error occurred, or an object can't be converted to a target Java class.

  - ### materializeObject

    public String materializeObject(CallableStatement cs, int index, int type) throws Exception
    Description copied from interface: `ExtendedType`
    Reads an object from a stored procedure OUT parameter, converting it to class returned by 'getClassName' method.
    Specified by:
      `materializeObject` in interface `ExtendedType<String>`
    Throws:
      `Exception` - if read error occurred, or an object can't be converted to a target Java class.

  - ### rtrim

    protected String rtrim(String value)
    Trim right spaces.

  - ### setJdbcObject

    public void setJdbcObject(PreparedStatement st, String value, int pos, int type, int scale) throws Exception
    Description copied from interface: `ExtendedType`
    Initializes a single parameter of a PreparedStatement with object value.
    Specified by:
      `setJdbcObject` in interface `ExtendedType<String>`
    Throws:
      `Exception`

  - ### toString

    public String toString(String value)
    Description copied from interface: `ExtendedType`
    Converts value of the supported type to a human-readable String representation.
    Specified by:
      `toString` in interface `ExtendedType<String>`
    Parameters:
      `value` - a value to convert to String.

  - ### readClob

    protected String readClob(Clob clob) throws IOException, SQLException
    Throws:
      `IOException`
      `SQLException`

  - ### readCharStream

    protected String readCharStream(ResultSet rs, int index) throws IOException, SQLException
    Throws:
      `IOException`
      `SQLException`

  - ### readValueStream

    protected String readValueStream(Reader in, int streamSize, int bufSize) throws IOException
    Throws:
      `IOException`

  - ### isTrimmingChars

    public boolean isTrimmingChars()
    Returns `true` if '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)