Package com.ctc.wstx.util
Class InternCache
- java.lang.Object
-
- com.ctc.wstx.util.InternCache
-
public final class InternCache extends java.lang.ObjectSingleton 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 intDEFAULT_SIZELet's create cache big enough to usually have enough space for all entries...private static intMAX_SIZELet's limit maximum size.private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String>mCacheprivate java.util.concurrent.ConcurrentLinkedQueue<java.lang.String>mInsertionOrderQueue tracking insertion order for FIFO eviction when the cache exceedsMAX_SIZE.private static InternCachesInstance
-
Constructor Summary
Constructors Modifier Constructor Description privateInternCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InternCachegetInstance()java.lang.Stringintern(java.lang.String input)
-
-
-
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
-
MAX_SIZE
private static final int MAX_SIZE
Let's limit maximum size.- 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 exceedsMAX_SIZE.
-
-
Method Detail
-
getInstance
public static InternCache getInstance()
-
intern
public java.lang.String intern(java.lang.String input)
-
-