Package org.apache.tomcat.util.buf
Class StringCache
java.lang.Object
org.apache.tomcat.util.buf.StringCache
This class implements a String cache for ByteChunk and CharChunk.
- Author:
- Remy Maucherat
-
Field Summary
Modifier and TypeFieldDescriptionprotected static int
Access count.protected static org.apache.tomcat.util.buf.StringCache.ByteEntry[]
Cache for byte chunk.protected static int
toString count for byte chunk.protected static final HashMap<org.apache.tomcat.util.buf.StringCache.ByteEntry,
int[]> Statistics hash map for byte chunk.protected static boolean
Enabled ?protected static int
protected static org.apache.tomcat.util.buf.StringCache.CharEntry[]
Cache for char chunk.protected static int
toString count for char chunk.protected static final HashMap<org.apache.tomcat.util.buf.StringCache.CharEntry,
int[]> Statistics hash map for char chunk.protected static boolean
protected static int
Hit count.protected static final int
protected static int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static final int
Compare given byte chunk with byte array.protected static final int
Compare given char chunk with char array.protected static final String
Deprecated.Unused.protected static final String
find
(ByteChunk name, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) Find an entry given its name in the cache and return the associated String.protected static final String
Find an entry given its name in the cache and return the associated String.protected static final int
findClosest
(ByteChunk name, org.apache.tomcat.util.buf.StringCache.ByteEntry[] array, int len) Find an entry given its name in a sorted array of map elements.protected static final int
findClosest
(CharChunk name, org.apache.tomcat.util.buf.StringCache.CharEntry[] array, int len) Find an entry given its name in a sorted array of map elements.int
boolean
int
boolean
int
int
void
reset()
void
setByteEnabled
(boolean byteEnabled) void
setCacheSize
(int cacheSize) void
setCharEnabled
(boolean charEnabled) void
setTrainThreshold
(int trainThreshold) static String
static String
toString
(ByteChunk bc, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) static String
-
Field Details
-
byteEnabled
protected static boolean byteEnabledEnabled ? -
charEnabled
protected static boolean charEnabled -
trainThreshold
protected static int trainThreshold -
cacheSize
protected static int cacheSize -
maxStringSize
protected static final int maxStringSize -
bcStats
Statistics hash map for byte chunk. -
bcCount
protected static int bcCounttoString count for byte chunk. -
bcCache
protected static volatile org.apache.tomcat.util.buf.StringCache.ByteEntry[] bcCacheCache for byte chunk. -
ccStats
Statistics hash map for char chunk. -
ccCount
protected static int ccCounttoString count for char chunk. -
ccCache
protected static volatile org.apache.tomcat.util.buf.StringCache.CharEntry[] ccCacheCache for char chunk. -
accessCount
protected static int accessCountAccess count. -
hitCount
protected static int hitCountHit count.
-
-
Constructor Details
-
StringCache
public StringCache()
-
-
Method Details
-
getCacheSize
public int getCacheSize()- Returns:
- Returns the cacheSize.
-
setCacheSize
public void setCacheSize(int cacheSize) - Parameters:
cacheSize
- The cacheSize to set.
-
getByteEnabled
public boolean getByteEnabled()- Returns:
- Returns the enabled.
-
setByteEnabled
public void setByteEnabled(boolean byteEnabled) - Parameters:
byteEnabled
- The enabled to set.
-
getCharEnabled
public boolean getCharEnabled()- Returns:
- Returns the enabled.
-
setCharEnabled
public void setCharEnabled(boolean charEnabled) - Parameters:
charEnabled
- The enabled to set.
-
getTrainThreshold
public int getTrainThreshold()- Returns:
- Returns the trainThreshold.
-
setTrainThreshold
public void setTrainThreshold(int trainThreshold) - Parameters:
trainThreshold
- The trainThreshold to set.
-
getAccessCount
public int getAccessCount()- Returns:
- Returns the accessCount.
-
getHitCount
public int getHitCount()- Returns:
- Returns the hitCount.
-
reset
public void reset() -
toString
-
toString
public static String toString(ByteChunk bc, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) throws CharacterCodingException - Throws:
CharacterCodingException
-
toString
-
compare
Compare given byte chunk with byte array.- Parameters:
name
- The name to comparecompareTo
- The compared to data- Returns:
- -1, 0 or +1 if inferior, equal, or superior to the String.
-
find
Deprecated.Unused. Will be removed in Tomcat 11. Usefind(ByteChunk, CodingErrorAction, CodingErrorAction)
Find an entry given its name in the cache and return the associated String.- Parameters:
name
- The name to find- Returns:
- the corresponding value
-
find
protected static final String find(ByteChunk name, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) Find an entry given its name in the cache and return the associated String.- Parameters:
name
- The name to findmalformedInputAction
- Action to take if an malformed input is encounteredunmappableCharacterAction
- Action to take if an unmappable character is encountered- Returns:
- the corresponding value
-
findClosest
protected static final int findClosest(ByteChunk name, org.apache.tomcat.util.buf.StringCache.ByteEntry[] array, int len) Find an entry given its name in a sorted array of map elements. This will return the index for the closest inferior or equal item in the given array.- Parameters:
name
- The name to findarray
- The array in which to looklen
- The effective length of the array- Returns:
- the position of the best match
-
compare
Compare given char chunk with char array.- Parameters:
name
- The name to comparecompareTo
- The compared to data- Returns:
- -1, 0 or +1 if inferior, equal, or superior to the String.
-
find
Find an entry given its name in the cache and return the associated String.- Parameters:
name
- The name to find- Returns:
- the corresponding value
-
findClosest
protected static final int findClosest(CharChunk name, org.apache.tomcat.util.buf.StringCache.CharEntry[] array, int len) Find an entry given its name in a sorted array of map elements. This will return the index for the closest inferior or equal item in the given array.- Parameters:
name
- The name to findarray
- The array in which to looklen
- The effective length of the array- Returns:
- the position of the best match
-