Class TypeNames


  • public final class TypeNames
    extends java.lang.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
            names.put( type,        "TEXT" );
            names.put( type,   255, "VARCHAR($l)" );
            names.put( type, 65534, "LONGVARCHAR($l)" );
     
    will give you back the following:
      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)
     
    On the other hand, simply putting
            names.put( type, "VARCHAR($l)" );
     
    would result in
      names.get( type )        // --> "VARCHAR($l)" (will cause trouble)
      names.get( type, 100 )   // --> "VARCHAR(100)"
      names.get( type, 10000 ) // --> "VARCHAR(10000)"
     
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeNames()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsTypeName​(java.lang.String typeName)
      Check whether or not the provided typeName exists.
      java.lang.String get​(int typeCode)
      get default type name for specified type
      java.lang.String get​(int typeCode, long size, int precision, int scale)
      get type name for specified type and size
      void put​(int typeCode, long capacity, java.lang.String value)
      Register a weighted typeCode mapping
      void put​(int typeCode, java.lang.String value)
      Register a default (non-weighted) typeCode mapping
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TypeNames

        public TypeNames()
    • Method Detail

      • get

        public java.lang.String get​(int typeCode)
                             throws MappingException
        get default type name for specified type
        Parameters:
        typeCode - the type key
        Returns:
        the default type name associated with specified key
        Throws:
        MappingException - Indicates that no registrations were made for that typeCode
      • get

        public java.lang.String get​(int typeCode,
                                    long size,
                                    int precision,
                                    int scale)
                             throws MappingException
        get type name for specified type and size
        Parameters:
        typeCode - the type key
        size - the SQL length
        scale - the SQL scale
        precision - the SQL precision
        Returns:
        the associated name with smallest capacity >= size, if available and the default type name otherwise
        Throws:
        MappingException - Indicates that no registrations were made for that typeCode
      • put

        public void put​(int typeCode,
                        long capacity,
                        java.lang.String value)
        Register a weighted typeCode mapping
        Parameters:
        typeCode - the JDBC type code
        capacity - The capacity for this weighting
        value - The mapping (type name)
      • put

        public void put​(int typeCode,
                        java.lang.String value)
        Register a default (non-weighted) typeCode mapping
        Parameters:
        typeCode - the type key
        value - The mapping (type name)
      • containsTypeName

        public boolean containsTypeName​(java.lang.String typeName)
        Check whether or not the provided typeName exists.
        Parameters:
        typeName - the type name.
        Returns:
        true if the given string has been registered as a type.