Class TypeMapper

java.lang.Object
org.apache.sis.internal.metadata.sql.TypeMapper

public final class TypeMapper extends Object
Maps a few basic Java types to JDBC types.
Since:
0.8
Version:
0.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Class<?>
    The Java class.
    private final String
    The SQL keyword for that type.
    private final int
    A constant from the SQL Types enumeration.
    private static final TypeMapper[]
    A list of Java classes to be mapped to SQL types.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    TypeMapper(Class<?> classe, int type, String keyword)
    For internal use only.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    keywordFor(Class<?> classe)
    Returns the SQL keyword for storing an element of the given type, or null if unknown.
    static Class<?>
    toJavaType(int type)
    Return the Java class for the given SQL type, or null if none.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TYPES

      private static final TypeMapper[] TYPES
      A list of Java classes to be mapped to SQL types. We do not want to map every SQL types, but only the ones which are of interest for the Apache SIS metadata implementation. The types will be tested in the order they are declared, so the last declarations are fallbacks.

      The types declared here matches both the Derby and PostgreSQL mapping.

    • classe

      private final Class<?> classe
      The Java class.
    • type

      private final int type
      A constant from the SQL Types enumeration.
    • keyword

      private final String keyword
      The SQL keyword for that type.
  • Constructor Details

    • TypeMapper

      private TypeMapper(Class<?> classe, int type, String keyword)
      For internal use only.
  • Method Details

    • keywordFor

      public static String keywordFor(Class<?> classe)
      Returns the SQL keyword for storing an element of the given type, or null if unknown. This method does not handle the text type, so String are treated as "unknown" as well. We do that way because the caller will need to specify a value in VARCHAR(n) statement.
      Parameters:
      classe - the class for which to get the SQL keyword in a CREATE TABLE statement.
      Returns:
      the SQL keyword, or null if unknown.
    • toJavaType

      public static Class<?> toJavaType(int type)
      Return the Java class for the given SQL type, or null if none.
      Parameters:
      type - one of the Types constants.
      Returns:
      the Java class, or null if none.