Class InternCache


  • public final class InternCache
    extends java.lang.Object
    Singleton class that implements "fast intern" functionality, essentially adding a layer that caches Strings that have been previously intern()ed, but that probably shouldn't be added to symbol tables. This is usually used by improving intern()ing of things like namespace URIs.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int DEFAULT_SIZE
      Let's create cache big enough to usually have enough space for all entries...
      private static int MAX_SIZE
      Let's limit maximum size.
      private java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.lang.String> mCache  
      private java.util.concurrent.ConcurrentLinkedQueue<java.lang.String> mInsertionOrder
      Queue tracking insertion order for FIFO eviction when the cache exceeds MAX_SIZE.
      private static InternCache sInstance  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private InternCache()  
    • Field Detail

      • DEFAULT_SIZE

        private static final int DEFAULT_SIZE
        Let's create cache big enough to usually have enough space for all entries... (assuming NS URIs only)
        See Also:
        Constant Field Values
      • sInstance

        private static final InternCache sInstance
      • mCache

        private final java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.lang.String> mCache
      • mInsertionOrder

        private final java.util.concurrent.ConcurrentLinkedQueue<java.lang.String> mInsertionOrder
        Queue tracking insertion order for FIFO eviction when the cache exceeds MAX_SIZE.
    • Constructor Detail

      • InternCache

        private InternCache()
    • Method Detail

      • getInstance

        public static InternCache getInstance()
      • intern

        public java.lang.String intern​(java.lang.String input)