Interface TypeInfo

  • All Known Implementing Classes:
    TypeInfoCache

    public interface TypeInfo
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method 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)  
      char getArrayDelimiter​(int oid)
      Determine the delimiter for the elements of the given array type oid.
      int getDisplaySize​(int oid, int typmod)  
      int getJavaArrayType​(java.lang.String className)  
      java.lang.String getJavaClass​(int oid)  
      int getMaximumPrecision​(int oid)  
      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 oid)
      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.
      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.
      boolean requiresQuoting​(int oid)  
      boolean requiresQuotingSqlType​(int sqlType)
      Returns true if particular sqlType requires quoting.
    • Method Detail

      • addCoreType

        void addCoreType​(java.lang.String pgTypeName,
                         java.lang.Integer oid,
                         java.lang.Integer sqlType,
                         java.lang.String javaClass,
                         java.lang.Integer arrayOid)
      • addDataType

        void addDataType​(java.lang.String type,
                         java.lang.Class<? extends PGobject> klass)
                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getSQLType

        int getSQLType​(int oid)
                throws java.sql.SQLException
        Look up the SQL typecode for a given type oid.
        Parameters:
        oid - the type's OID
        Returns:
        the SQL type code (a constant from Types) for the type
        Throws:
        java.sql.SQLException - if an error occurs when retrieving sql type
      • getSQLType

        int getSQLType​(java.lang.String pgTypeName)
                throws java.sql.SQLException
        Look up the SQL typecode for a given postgresql type name.
        Parameters:
        pgTypeName - the server type name to look up
        Returns:
        the SQL type code (a constant from Types) for the type
        Throws:
        java.sql.SQLException - if an error occurs when retrieving sql type
      • getJavaArrayType

        int getJavaArrayType​(java.lang.String className)
                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getPGType

        int getPGType​(java.lang.String pgTypeName)
               throws java.sql.SQLException
        Look up the oid for a given postgresql type name. This is the inverse of getPGType(int).
        Parameters:
        pgTypeName - the server type name to look up
        Returns:
        the type's OID, or 0 if unknown
        Throws:
        java.sql.SQLException - if an error occurs when retrieving PG type
      • getPGType

        java.lang.String getPGType​(int oid)
                            throws java.sql.SQLException
        Look up the postgresql type name for a given oid. This is the inverse of getPGType(String).
        Parameters:
        oid - the type's OID
        Returns:
        the server type name for that OID or null if unknown
        Throws:
        java.sql.SQLException - if an error occurs when retrieving PG type
      • getPGArrayElement

        int getPGArrayElement​(int oid)
                       throws java.sql.SQLException
        Look up the oid of an array's base type given the array's type oid.
        Parameters:
        oid - the array type's OID
        Returns:
        the base type's OID, or 0 if unknown
        Throws:
        java.sql.SQLException - if an error occurs when retrieving array element
      • getPGArrayType

        int getPGArrayType​(java.lang.String elementTypeName)
                    throws java.sql.SQLException
        Determine the oid of the given base postgresql type's array type.
        Parameters:
        elementTypeName - the base type's
        Returns:
        the array type's OID, or 0 if unknown
        Throws:
        java.sql.SQLException - if an error occurs when retrieving array type
      • getArrayDelimiter

        char getArrayDelimiter​(int oid)
                        throws java.sql.SQLException
        Determine the delimiter for the elements of the given array type oid.
        Parameters:
        oid - the array type's OID
        Returns:
        the base type's array type delimiter
        Throws:
        java.sql.SQLException - if an error occurs when retrieving array delimiter
      • getPGTypeNamesWithSQLTypes

        java.util.Iterator<java.lang.String> getPGTypeNamesWithSQLTypes()
      • getPGTypeOidsWithSQLTypes

        java.util.Iterator<java.lang.Integer> getPGTypeOidsWithSQLTypes()
      • getPGobject

        java.lang.Class<? extends PGobject> getPGobject​(java.lang.String type)
      • getJavaClass

        java.lang.String getJavaClass​(int oid)
                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getTypeForAlias

        java.lang.String getTypeForAlias​(java.lang.String alias)
      • getPrecision

        int getPrecision​(int oid,
                         int typmod)
      • getScale

        int getScale​(int oid,
                     int typmod)
      • isCaseSensitive

        boolean isCaseSensitive​(int oid)
      • isSigned

        boolean isSigned​(int oid)
      • getDisplaySize

        int getDisplaySize​(int oid,
                           int typmod)
      • getMaximumPrecision

        int getMaximumPrecision​(int oid)
      • requiresQuoting

        boolean requiresQuoting​(int oid)
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • requiresQuotingSqlType

        boolean requiresQuotingSqlType​(int sqlType)
                                throws java.sql.SQLException
        Returns true if particular sqlType requires quoting. This method is used internally by the driver, so it might disappear without notice.
        Parameters:
        sqlType - sql type as in java.sql.Types
        Returns:
        true if the type requires quoting
        Throws:
        java.sql.SQLException - if something goes wrong
      • longOidToInt

        int longOidToInt​(long oid)
                  throws java.sql.SQLException

        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.

        Parameters:
        oid - the oid as a long.
        Returns:
        the (internal) signed integer representation of the (unsigned) oid.
        Throws:
        java.sql.SQLException - if the long has a value outside of the range representable by uint32
      • intOidToLong

        long intOidToLong​(int oid)
        Java Integers are signed 32-bit integers, but oids are unsigned 32-bit integers. We must therefore first map the (internal) integer representation to a positive long value before sending it to postgresql, or we would be unable to correctly handle the upper half of the oid space because these negative values are disallowed as OID values.
        Parameters:
        oid - the (signed) integer oid to convert into a long.
        Returns:
        the non-negative value of this oid, stored as a java long.