Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Integer,java.lang.Character> |
arrayOidToDelimiter |
private BaseConnection |
conn |
private java.sql.PreparedStatement |
getAllTypeInfoStatement |
private java.sql.PreparedStatement |
getArrayDelimiterStatement |
private java.sql.PreparedStatement |
getArrayElementOidStatement |
private java.sql.PreparedStatement |
getNameStatement |
private java.sql.PreparedStatement |
getOidStatementComplexArray |
private java.sql.PreparedStatement |
getOidStatementComplexNonArray |
private java.sql.PreparedStatement |
getOidStatementSimple |
private java.sql.PreparedStatement |
getTypeInfoStatement |
private static java.util.logging.Logger |
LOGGER |
private java.util.Map<java.lang.Integer,java.lang.String> |
oidToPgName |
private java.util.Map<java.lang.Integer,java.lang.Integer> |
oidToSQLType |
private java.util.Map<java.lang.Integer,java.lang.Integer> |
pgArrayToPgType |
private java.util.Map<java.lang.String,java.lang.String> |
pgNameToJavaClass |
private java.util.Map<java.lang.String,java.lang.Integer> |
pgNameToOid |
private java.util.Map<java.lang.String,java.lang.Class<? extends PGobject>> |
pgNameToPgObject |
private java.util.Map<java.lang.String,java.lang.Integer> |
pgNameToSQLType |
private static java.util.HashMap<java.lang.String,java.lang.String> |
typeAliases
PG maps several alias to real type names.
|
private static java.lang.Object[][] |
types |
private int |
unknownLength |
Constructor and Description |
---|
TypeInfoCache(BaseConnection conn,
int unknownLength) |
Modifier and Type | Method and Description |
---|---|
void |
addCoreType(java.lang.String pgTypeName,
java.lang.Integer oid,
java.lang.Integer sqlType,
java.lang.String javaClass,
java.lang.Integer arrayOid) |
void |
addDataType(java.lang.String type,
java.lang.Class<? extends PGobject> klass) |
void |
cacheSQLTypes() |
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) |
java.lang.String |
getJavaClass(int oid) |
int |
getMaximumPrecision(int oid) |
private java.sql.PreparedStatement |
getOidStatement(java.lang.String pgTypeName) |
int |
getPGArrayElement(int oid)
Look up the oid of an array's base type given the array's type oid.
|
int |
getPGArrayType(java.lang.String elementTypeName)
Determine the oid of the given base postgresql type's array type.
|
java.lang.Class<? extends PGobject> |
getPGobject(java.lang.String type) |
java.lang.String |
getPGType(int oid)
Look up the postgresql type name for a given oid.
|
int |
getPGType(java.lang.String pgTypeName)
Look up the oid for a given postgresql type name.
|
java.util.Iterator<java.lang.String> |
getPGTypeNamesWithSQLTypes() |
java.util.Iterator<java.lang.Integer> |
getPGTypeOidsWithSQLTypes() |
int |
getPrecision(int oid,
int typmod) |
int |
getScale(int oid,
int typmod) |
int |
getSQLType(int typeOid)
Look up the SQL typecode for a given type oid.
|
int |
getSQLType(java.lang.String pgTypeName)
Look up the SQL typecode for a given postgresql type name.
|
private int |
getSQLTypeFromQueryResult(java.sql.ResultSet rs) |
private java.lang.String |
getSQLTypeQuery(boolean typoidParam) |
java.lang.String |
getTypeForAlias(java.lang.String alias) |
long |
intOidToLong(int oid)
Java Integers are signed 32-bit integers, but oids are unsigned 32-bit integers.
|
boolean |
isCaseSensitive(int oid) |
boolean |
isSigned(int oid) |
int |
longOidToInt(long oid)
Java Integers are signed 32-bit integers, but oids are unsigned 32-bit integers.
|
private java.sql.PreparedStatement |
prepareGetAllTypeInfoStatement() |
private java.sql.PreparedStatement |
prepareGetArrayDelimiterStatement() |
private java.sql.PreparedStatement |
prepareGetArrayElementOidStatement() |
private java.sql.PreparedStatement |
prepareGetNameStatement() |
private java.sql.PreparedStatement |
prepareGetTypeInfoStatement() |
boolean |
requiresQuoting(int oid) |
boolean |
requiresQuotingSqlType(int sqlType)
Returns true if particular sqlType requires quoting.
|
private static final java.util.logging.Logger LOGGER
private java.util.Map<java.lang.String,java.lang.Integer> pgNameToSQLType
private java.util.Map<java.lang.Integer,java.lang.Integer> oidToSQLType
private java.util.Map<java.lang.String,java.lang.String> pgNameToJavaClass
private java.util.Map<java.lang.Integer,java.lang.String> oidToPgName
private java.util.Map<java.lang.String,java.lang.Integer> pgNameToOid
private java.util.Map<java.lang.String,java.lang.Class<? extends PGobject>> pgNameToPgObject
private java.util.Map<java.lang.Integer,java.lang.Integer> pgArrayToPgType
private java.util.Map<java.lang.Integer,java.lang.Character> arrayOidToDelimiter
private final BaseConnection conn
private final int unknownLength
private java.sql.PreparedStatement getOidStatementSimple
private java.sql.PreparedStatement getOidStatementComplexNonArray
private java.sql.PreparedStatement getOidStatementComplexArray
private java.sql.PreparedStatement getNameStatement
private java.sql.PreparedStatement getArrayElementOidStatement
private java.sql.PreparedStatement getArrayDelimiterStatement
private java.sql.PreparedStatement getTypeInfoStatement
private java.sql.PreparedStatement getAllTypeInfoStatement
private static final java.lang.Object[][] types
private static final java.util.HashMap<java.lang.String,java.lang.String> typeAliases
public TypeInfoCache(BaseConnection conn, int unknownLength)
public void addCoreType(java.lang.String pgTypeName, java.lang.Integer oid, java.lang.Integer sqlType, java.lang.String javaClass, java.lang.Integer arrayOid)
addCoreType
in interface TypeInfo
public void addDataType(java.lang.String type, java.lang.Class<? extends PGobject> klass) throws java.sql.SQLException
addDataType
in interface TypeInfo
java.sql.SQLException
public java.util.Iterator<java.lang.String> getPGTypeNamesWithSQLTypes()
getPGTypeNamesWithSQLTypes
in interface TypeInfo
public java.util.Iterator<java.lang.Integer> getPGTypeOidsWithSQLTypes()
getPGTypeOidsWithSQLTypes
in interface TypeInfo
private java.lang.String getSQLTypeQuery(boolean typoidParam)
private int getSQLTypeFromQueryResult(java.sql.ResultSet rs) throws java.sql.SQLException
java.sql.SQLException
private java.sql.PreparedStatement prepareGetAllTypeInfoStatement() throws java.sql.SQLException
java.sql.SQLException
public void cacheSQLTypes() throws java.sql.SQLException
java.sql.SQLException
private java.sql.PreparedStatement prepareGetTypeInfoStatement() throws java.sql.SQLException
java.sql.SQLException
public int getSQLType(java.lang.String pgTypeName) throws java.sql.SQLException
TypeInfo
getSQLType
in interface TypeInfo
pgTypeName
- the server type name to look upTypes
) for the typejava.sql.SQLException
- if an error occurs when retrieving sql typepublic int getSQLType(int typeOid) throws java.sql.SQLException
TypeInfo
getSQLType
in interface TypeInfo
typeOid
- the type's OIDTypes
) for the typejava.sql.SQLException
- if an error occurs when retrieving sql typeprivate java.sql.PreparedStatement getOidStatement(java.lang.String pgTypeName) throws java.sql.SQLException
java.sql.SQLException
public int getPGType(java.lang.String pgTypeName) throws java.sql.SQLException
TypeInfo
TypeInfo.getPGType(int)
.public java.lang.String getPGType(int oid) throws java.sql.SQLException
TypeInfo
TypeInfo.getPGType(String)
.private java.sql.PreparedStatement prepareGetNameStatement() throws java.sql.SQLException
java.sql.SQLException
public int getPGArrayType(java.lang.String elementTypeName) throws java.sql.SQLException
TypeInfo
getPGArrayType
in interface TypeInfo
elementTypeName
- the base type'sjava.sql.SQLException
- if an error occurs when retrieving array typeprotected int convertArrayToBaseOid(int oid)
oid
- input oidpublic char getArrayDelimiter(int oid) throws java.sql.SQLException
TypeInfo
getArrayDelimiter
in interface TypeInfo
oid
- the array type's OIDjava.sql.SQLException
- if an error occurs when retrieving array delimiterprivate java.sql.PreparedStatement prepareGetArrayDelimiterStatement() throws java.sql.SQLException
java.sql.SQLException
public int getPGArrayElement(int oid) throws java.sql.SQLException
TypeInfo
getPGArrayElement
in interface TypeInfo
oid
- the array type's OIDjava.sql.SQLException
- if an error occurs when retrieving array elementprivate java.sql.PreparedStatement prepareGetArrayElementOidStatement() throws java.sql.SQLException
java.sql.SQLException
public java.lang.Class<? extends PGobject> getPGobject(java.lang.String type)
getPGobject
in interface TypeInfo
public java.lang.String getJavaClass(int oid) throws java.sql.SQLException
getJavaClass
in interface TypeInfo
java.sql.SQLException
public java.lang.String getTypeForAlias(java.lang.String alias)
getTypeForAlias
in interface TypeInfo
public int getPrecision(int oid, int typmod)
getPrecision
in interface TypeInfo
public boolean isCaseSensitive(int oid)
isCaseSensitive
in interface TypeInfo
public int getDisplaySize(int oid, int typmod)
getDisplaySize
in interface TypeInfo
public int getMaximumPrecision(int oid)
getMaximumPrecision
in interface TypeInfo
public boolean requiresQuoting(int oid) throws java.sql.SQLException
requiresQuoting
in interface TypeInfo
java.sql.SQLException
public boolean requiresQuotingSqlType(int sqlType) throws java.sql.SQLException
requiresQuotingSqlType
in interface TypeInfo
sqlType
- sql type as in java.sql.Typesjava.sql.SQLException
- if something goes wrongpublic int longOidToInt(long oid) throws java.sql.SQLException
TypeInfo
Java Integers are signed 32-bit integers, but oids are unsigned 32-bit integers. We therefore read them as positive long values and then force them into signed integers (wrapping around into negative values when required) or we'd be unable to correctly handle the upper half of the oid space.
This function handles the mapping of uint32-values in the long to java integers, and throws for values that are out of range.
longOidToInt
in interface TypeInfo
oid
- the oid as a long.java.sql.SQLException
- if the long has a value outside of the range representable by uint32public long intOidToLong(int oid)
TypeInfo
intOidToLong
in interface TypeInfo
oid
- the (signed) integer oid to convert into a long.