public final class TypeNames extends Object
This class maps a type to names. Associations may be marked with a capacity. Calling the get() method with a type and actual size n will return the associated name with smallest capacity >= n, if available and an unmarked default type otherwise. Eg, setting <pre> names.put( type, "TEXT" ); names.put( type, 255, "VARCHAR($l)" ); names.put( type, 65534, "LONGVARCHAR($l)" ); </pre> will give you back the following: <pre> names.get( type ) // -→ "TEXT" (default) names.get( type, 100 ) // -→ "VARCHAR(100)" (100 is in [0:255]) names.get( type, 1000 ) // -→ "LONGVARCHAR(1000)" (1000 is in [256:65534]) names.get( type, 100000 ) // -→ "TEXT" (default) </pre> On the other hand, simply putting <pre> names.put( type, "VARCHAR($l)" ); </pre> would result in <pre> names.get( type ) // -→ "VARCHAR($l)" (will cause trouble) names.get( type, 100 ) // -→ "VARCHAR(100)" names.get( type, 10000 ) // -→ "VARCHAR(10000)" </pre>
Constructor and Description |
---|
TypeNames() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsTypeName(String typeName)
Check whether or not the provided typeName exists.
|
String |
get(int typeCode)
get default type name for specified type
|
String |
get(int typeCode,
long size,
int precision,
int scale)
get type name for specified type and size
|
void |
put(int typeCode,
long capacity,
String value)
Register a weighted typeCode mapping
|
void |
put(int typeCode,
String value)
Register a default (non-weighted) typeCode mapping
|
public String get(int typeCode) throws MappingException
get default type name for specified type
typeCode
- the type keyMappingException
- Indicates that no registrations were made for that typeCodepublic String get(int typeCode, long size, int precision, int scale) throws MappingException
get type name for specified type and size
typeCode
- the type keysize
- the SQL lengthscale
- the SQL scaleprecision
- the SQL precisionMappingException
- Indicates that no registrations were made for that typeCodepublic void put(int typeCode, long capacity, String value)
Register a weighted typeCode mapping
typeCode
- the JDBC type codecapacity
- The capacity for this weightingvalue
- The mapping (type name)public void put(int typeCode, String value)
Register a default (non-weighted) typeCode mapping
typeCode
- the type keyvalue
- The mapping (type name)public boolean containsTypeName(String typeName)
Check whether or not the provided typeName exists.
typeName
- the type name.Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.