Package com.ctc.wstx.util
Class InternCache
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<java.lang.String,java.lang.String>
-
- com.ctc.wstx.util.InternCache
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.String,java.lang.String>
public final class InternCache extends java.util.LinkedHashMap<java.lang.String,java.lang.String>
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.Note: that this class extends
LinkedHashMap
is an implementation detail -- no code should ever directly call Map methods.- See Also:
- Serialized Form
-
-
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 to hash area size of 1024.private static InternCache
sInstance
-
Constructor Summary
Constructors Modifier Constructor Description private
InternCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InternCache
getInstance()
java.lang.String
intern(java.lang.String input)
protected boolean
removeEldestEntry(java.util.Map.Entry<java.lang.String,java.lang.String> eldest)
-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
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 to hash area size of 1024.- See Also:
- Constant Field Values
-
sInstance
private static final InternCache sInstance
-
-
Method Detail
-
getInstance
public static InternCache getInstance()
-
intern
public java.lang.String intern(java.lang.String input)
-
removeEldestEntry
protected boolean removeEldestEntry(java.util.Map.Entry<java.lang.String,java.lang.String> eldest)
- Overrides:
removeEldestEntry
in classjava.util.LinkedHashMap<java.lang.String,java.lang.String>
-
-