Class BasicRowProcessor.CaseInsensitiveHashMap

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.Object>
    Enclosing class:
    BasicRowProcessor

    private static final class BasicRowProcessor.CaseInsensitiveHashMap
    extends java.util.LinkedHashMap<java.lang.String,​java.lang.Object>
    A Map that converts all keys to lowercase Strings for case insensitive lookups. This is needed for the toMap() implementation because databases don't consistently handle the casing of column names.

    The keys are stored as they are given [BUG #DBUTILS-34], so we maintain an internal mapping from lowercase keys to the real keys in order to achieve the case insensitive lookup.

    Note: This implementation does not allow null for key, whereas LinkedHashMap does, because of the code:

     key.toString().toLowerCase()
     
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​java.lang.String> lowerCaseMap
      The internal mapping from lowercase keys to the real keys.
      private static long serialVersionUID
      Required for serialization support.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CaseInsensitiveHashMap​(int initialCapacity)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.Object key)
      java.lang.Object get​(java.lang.Object key)
      java.lang.Object put​(java.lang.String key, java.lang.Object value)
      void putAll​(java.util.Map<? extends java.lang.String,​?> m)
      java.lang.Object remove​(java.lang.Object key)
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, getOrDefault, keySet, removeEldestEntry, replaceAll, values
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, isEmpty, merge, putIfAbsent, remove, replace, replace, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, size
    • Field Detail

      • lowerCaseMap

        private final java.util.Map<java.lang.String,​java.lang.String> lowerCaseMap
        The internal mapping from lowercase keys to the real keys.

        Any query operation using the key (get(Object), containsKey(Object)) is done in three steps:

        • convert the parameter key to lower case
        • get the actual key that corresponds to the lower case key
        • query the map with the actual key

      • serialVersionUID

        private static final long serialVersionUID
        Required for serialization support.
        See Also:
        Serializable, Constant Field Values
    • Constructor Detail

      • CaseInsensitiveHashMap

        private CaseInsensitiveHashMap​(int initialCapacity)
    • Method Detail

      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        containsKey in class java.util.HashMap<java.lang.String,​java.lang.Object>
      • get

        public java.lang.Object get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        get in class java.util.LinkedHashMap<java.lang.String,​java.lang.Object>
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        put in class java.util.HashMap<java.lang.String,​java.lang.Object>
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.String,​?> m)
        Specified by:
        putAll in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        putAll in class java.util.HashMap<java.lang.String,​java.lang.Object>
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        remove in class java.util.HashMap<java.lang.String,​java.lang.Object>