com.amazon.redshift.jdbc

## Class TypeInfoCache

- java.lang.Object
- - com.amazon.redshift.jdbc.TypeInfoCache

All Implemented Interfaces:
  TypeInfo

    public class TypeInfoCache
    extends Object
    implements TypeInfo

### Field Summary

Fields
`static String` `GEOMETRY_NAME`
`static int` `GEOMETRYHEXOID`
`static int` `GEOMETRYOID`
`static String` `SUPER_NAME`
`static int` `SUPEROID`
`static String` `TID_ARRAY_NAME`
`static String` `TID_NAME`
`static String` `VARBYTE_NAME`
`static int` `VARBYTEOID`
`static String` `XID_ARRAY_NAME`
`static String` `XID_NAME`

### Constructor Summary

Constructors
Constructor and Description
`TypeInfoCache(BaseConnection conn, int unknownLength)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCoreType(String rsTypeName, Integer oid, Integer sqlType, String javaClass, Integer arrayOid)`
`void` `addDataType(String type, Class<? extends RedshiftObject> klass)`
`void` `cacheSQLTypes(RedshiftLogger logger)`
`protected int` `convertArrayToBaseOid(int oid)` Return the oid of the array's base element if it's an array, if not return the provided oid.
`char` `getArrayDelimiter(int oid)` Determine the delimiter for the elements of the given array type oid.
`int` `getDisplaySize(int oid, int typmod)`
`String` `getJavaClass(int oid)`
`int` `getMaximumPrecision(int oid)`
`int` `getPrecision(int oid, int typmod)`
`int` `getRSArrayElement(int oid)` Look up the oid of an array's base type given the array's type oid.
`int` `getRSArrayType(String elementTypeName)` Determine the oid of the given base Redshift type's array type.
`Class<? extends RedshiftObject>` `getRSobject(String type)`
`String` `getRSType(int oid)` Look up the redshift type name for a given oid.
`int` `getRSType(String pgTypeName)` Look up the oid for a given redshift type name.
`Iterator<String>` `getRSTypeNamesWithSQLTypes()`
`int` `getScale(int oid, int typmod)`
`int` `getSQLType(int oid)` Look up the SQL typecode for a given type oid.
`int` `getSQLType(String pgTypeName)` Look up the SQL typecode for a given Redshift type name.
`String` `getTypeForAlias(String alias)`
`boolean` `isCaseSensitive(int oid)`
`boolean` `isSigned(int oid)`
`boolean` `requiresQuoting(int oid)`
`boolean` `requiresQuotingSqlType(int sqlType)` Returns true if particular sqlType requires quoting.

### Methods inherited from class java.lang.Object

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

### Field Detail

#### GEOMETRY_NAME

    public static final String GEOMETRY_NAME

See Also:
  Constant Field Values

#### GEOMETRYOID

    public static final int GEOMETRYOID

See Also:
  Constant Field Values

#### GEOMETRYHEXOID

    public static final int GEOMETRYHEXOID

See Also:
  Constant Field Values

#### SUPER_NAME

    public static final String SUPER_NAME

See Also:
  Constant Field Values

#### SUPEROID

    public static final int SUPEROID

See Also:
  Constant Field Values

#### VARBYTE_NAME

    public static final String VARBYTE_NAME

See Also:
  Constant Field Values

#### VARBYTEOID

    public static final int VARBYTEOID

See Also:
  Constant Field Values

#### TID_NAME

    public static final String TID_NAME

See Also:
  Constant Field Values

#### TID_ARRAY_NAME

    public static final String TID_ARRAY_NAME

See Also:
  Constant Field Values

#### XID_NAME

    public static final String XID_NAME

See Also:
  Constant Field Values

#### XID_ARRAY_NAME

    public static final String XID_ARRAY_NAME

See Also:
  Constant Field Values

### Constructor Detail

#### TypeInfoCache

    public TypeInfoCache(BaseConnection conn,
                         int unknownLength)

### Method Detail

#### addCoreType

    public void addCoreType(String rsTypeName,
                            Integer oid,
                            Integer sqlType,
                            String javaClass,
                            Integer arrayOid)

Specified by:
  `addCoreType` in interface `TypeInfo`

#### addDataType

    public void addDataType(String type,
                            Class<? extends RedshiftObject> klass)
                     throws SQLException

Specified by:
  `addDataType` in interface `TypeInfo`
Throws:
  `SQLException`

#### getRSTypeNamesWithSQLTypes

    public Iterator<String> getRSTypeNamesWithSQLTypes()

Specified by:
  `getRSTypeNamesWithSQLTypes` in interface `TypeInfo`

#### cacheSQLTypes

    public void cacheSQLTypes(RedshiftLogger logger)
                       throws SQLException

Throws:
  `SQLException`

#### getSQLType

    public int getSQLType(int oid)
                   throws SQLException

Description copied from interface: `TypeInfo`
Look up the SQL typecode for a given type oid.

Specified by:
  `getSQLType` in interface `TypeInfo`
Parameters:
  `oid` - the type's OID
Returns:
  the SQL type code (a constant from `Types`) for the type
Throws:
  `SQLException` - if an error occurs when retrieving sql type

#### getSQLType

    public int getSQLType(String pgTypeName)
                   throws SQLException

Description copied from interface: `TypeInfo`
Look up the SQL typecode for a given Redshift type name.

Specified by:
  `getSQLType` in interface `TypeInfo`
Parameters:
  `pgTypeName` - the server type name to look up
Returns:
  the SQL type code (a constant from `Types`) for the type
Throws:
  `SQLException` - if an error occurs when retrieving sql type

#### getRSType

    public int getRSType(String pgTypeName)
                  throws SQLException

Description copied from interface: `TypeInfo`
Look up the oid for a given redshift type name. This is the inverse of `TypeInfo.getRSType(int)`.

Specified by:
  `getRSType` in interface `TypeInfo`
Parameters:
  `pgTypeName` - the server type name to look up
Returns:
  the type's OID, or 0 if unknown
Throws:
  `SQLException` - if an error occurs when retrieving RS type

#### getRSType

    public String getRSType(int oid)
                     throws SQLException

Description copied from interface: `TypeInfo`
Look up the redshift type name for a given oid. This is the inverse of `TypeInfo.getRSType(String)`.

Specified by:
  `getRSType` in interface `TypeInfo`
Parameters:
  `oid` - the type's OID
Returns:
  the server type name for that OID or null if unknown
Throws:
  `SQLException` - if an error occurs when retrieving RS type

#### getRSArrayType

    public int getRSArrayType(String elementTypeName)
                       throws SQLException

Description copied from interface: `TypeInfo`
Determine the oid of the given base Redshift type's array type.

Specified by:
  `getRSArrayType` in interface `TypeInfo`
Parameters:
  `elementTypeName` - the base type's
Returns:
  the array type's OID, or 0 if unknown
Throws:
  `SQLException` - if an error occurs when retrieving array type

#### convertArrayToBaseOid

    protected int convertArrayToBaseOid(int oid)

Return the oid of the array's base element if it's an array, if not return the provided oid. This doesn't do any database lookups, so it's only useful for the originally provided type mappings. This is fine for it's intended uses where we only have intimate knowledge of types that are already known to the driver.

Parameters:
  `oid` - input oid
Returns:
  oid of the array's base element or the provided oid (if not array)

#### getArrayDelimiter

    public char getArrayDelimiter(int oid)
                           throws SQLException

Description copied from interface: `TypeInfo`
Determine the delimiter for the elements of the given array type oid.

Specified by:
  `getArrayDelimiter` in interface `TypeInfo`
Parameters:
  `oid` - the array type's OID
Returns:
  the base type's array type delimiter
Throws:
  `SQLException` - if an error occurs when retrieving array delimiter

#### getRSArrayElement

    public int getRSArrayElement(int oid)
                          throws SQLException

Description copied from interface: `TypeInfo`
Look up the oid of an array's base type given the array's type oid.

Specified by:
  `getRSArrayElement` in interface `TypeInfo`
Parameters:
  `oid` - the array type's OID
Returns:
  the base type's OID, or 0 if unknown
Throws:
  `SQLException` - if an error occurs when retrieving array element

#### getRSobject

    public Class<? extends RedshiftObject> getRSobject(String type)

Specified by:
  `getRSobject` in interface `TypeInfo`

#### getJavaClass

    public String getJavaClass(int oid)
                        throws SQLException

Specified by:
  `getJavaClass` in interface `TypeInfo`
Throws:
  `SQLException`

#### getTypeForAlias

    public String getTypeForAlias(String alias)

Specified by:
  `getTypeForAlias` in interface `TypeInfo`

#### getPrecision

    public int getPrecision(int oid,
                            int typmod)

Specified by:
  `getPrecision` in interface `TypeInfo`

#### getScale

    public int getScale(int oid,
                        int typmod)

Specified by:
  `getScale` in interface `TypeInfo`

#### isCaseSensitive

    public boolean isCaseSensitive(int oid)

Specified by:
  `isCaseSensitive` in interface `TypeInfo`

#### isSigned

    public boolean isSigned(int oid)

Specified by:
  `isSigned` in interface `TypeInfo`

#### getDisplaySize

    public int getDisplaySize(int oid,
                              int typmod)

Specified by:
  `getDisplaySize` in interface `TypeInfo`

#### getMaximumPrecision

    public int getMaximumPrecision(int oid)

Specified by:
  `getMaximumPrecision` in interface `TypeInfo`

#### requiresQuoting

    public boolean requiresQuoting(int oid)
                            throws SQLException

Specified by:
  `requiresQuoting` in interface `TypeInfo`
Throws:
  `SQLException`

#### requiresQuotingSqlType

    public boolean requiresQuotingSqlType(int sqlType)
                                   throws SQLException

Returns true if particular sqlType requires quoting. This method is used internally by the driver, so it might disappear without notice.

Specified by:
  `requiresQuotingSqlType` in interface `TypeInfo`
Parameters:
  `sqlType` - sql type as in java.sql.Types
Returns:
  true if the type requires quoting
Throws:
  `SQLException` - if something goes wrong