Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.access.types
Class CharType

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

All Implemented Interfaces:
  ExtendedType

    public class CharType

extends Object
implements ExtendedType

Handles `java.lang.String`, mapping it as either of JDBC types - CLOB or (VAR)CHAR. Can be configured to trim trailing spaces.

Field Summary
`protected boolean` | `trimmingChars`
`protected boolean` | `usingClobs`

Constructor Summary
`CharType(boolean trimingChars, boolean usingClobs)`

Method Summary
`String` | `getClassName()` Returns "java.lang.String".
`boolean` | `isTrimmingChars()` Returns `true` if 'materializeObject' method should trim trailing spaces from the CHAR columns.
`boolean` | `isUsingClobs()`
`Object` | `materializeObject(CallableStatement cs, int index, int type)` Return trimmed string.
`Object` | `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)`
`void` | `setJdbcObject(PreparedStatement st, Object val, int pos, int type, int precision)` Initializes a single parameter of a PreparedStatement with object value.
`void` | `setTrimmingChars(boolean trimingChars)`
`void` | `setUsingClobs(boolean usingClobs)`
`boolean` | `validateProperty(Object source, String property, Object value, DbAttribute dbAttribute, ValidationResult validationResult)` Deprecated. since 3.0 as validation should not be done at the DataNode level.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### trimmingChars

    protected boolean trimmingChars

### usingClobs

    protected boolean usingClobs

Constructor Detail

### CharType

    public CharType(boolean trimingChars,
                    boolean usingClobs)

Method Detail

### getClassName

    public String getClassName()

  Returns "java.lang.String".

  Specified by:
    `getClassName` in interface `ExtendedType`

### validateProperty

    public boolean validateProperty(Object source,
                                    String property,
                                    Object value,
                                    DbAttribute dbAttribute,
                                    ValidationResult validationResult)

  Deprecated. since 3.0 as validation should not be done at the DataNode level.

  Validates string property.

  Specified by:
    `validateProperty` in interface `ExtendedType`
  Since:
    1.1

### materializeObject

    public Object materializeObject(ResultSet rs,
                                    int index,
                                    int type)
                             throws Exception

  Return trimmed string.

  Specified by:
    `materializeObject` in interface `ExtendedType`
  Throws:
    `Exception` - if read error ocurred, or an object can't be converted to a target Java class.

### materializeObject

    public Object materializeObject(CallableStatement cs,
                                    int index,
                                    int type)
                             throws Exception

  Return trimmed string.

  Specified by:
    `materializeObject` in interface `ExtendedType`
  Throws:
    `Exception` - if read error ocurred, or an object can't be converted to a target Java class.

### setJdbcObject

    public void setJdbcObject(PreparedStatement st,
                              Object val,
                              int pos,
                              int type,
                              int precision)
                       throws Exception

  Description copied from interface: `ExtendedType`
  Initializes a single parameter of a PreparedStatement with object value.

  Specified by:
    `setJdbcObject` in interface `ExtendedType`
  Throws:
    `Exception`

### 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 columsn padded with spaces.

### setTrimmingChars

    public void setTrimmingChars(boolean trimingChars)

### isUsingClobs

    public boolean isUsingClobs()

### setUsingClobs

    public void setUsingClobs(boolean usingClobs)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2009 Apache Cayenne. All Rights Reserved.