Class StringPool


  • public final class StringPool
    extends java.lang.Object
    Simple map based StringPool that is considered faster than using String.intern(), but uses a bit more memory.
    Author:
    thomas.jungblut
    • Method Detail

      • pool

        public final java.lang.String pool​(java.lang.String s)
        Pools the given string and returns a reference to an existing string (if exists).
        Parameters:
        s - the string
        Returns:
        a pooled string instance.
      • getPool

        public static StringPool getPool()
        Returns:
        a not synchronized string pool based on a HashMap.
      • getSynchronizedPool

        public static StringPool getSynchronizedPool()
        Returns:
        a synchronized string pool based on a ConcurrentHashMap.