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 SummaryFieldsModifier and TypeFieldDescriptionprotected static intAccess count.protected static org.apache.tomcat.util.buf.StringCache.ByteEntry[]Cache for byte chunk.protected static inttoString count for byte chunk.protected static final HashMap<org.apache.tomcat.util.buf.StringCache.ByteEntry,int[]> Statistics hash map for byte chunk.protected static booleanEnabled ?protected static intprotected static org.apache.tomcat.util.buf.StringCache.CharEntry[]Cache for char chunk.protected static inttoString count for char chunk.protected static final HashMap<org.apache.tomcat.util.buf.StringCache.CharEntry,int[]> Statistics hash map for char chunk.protected static booleanprotected static intHit count.protected static final intprotected static int
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected static final intCompare given byte chunk with byte array.protected static final intCompare given char chunk with char array.protected static final StringDeprecated.Unused.protected static final Stringfind(ByteChunk name, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) Find an entry given its name in the cache and return the associated String.protected static final StringFind an entry given its name in the cache and return the associated String.protected static final intfindClosest(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 intfindClosest(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.intbooleanintbooleanintintvoidreset()voidsetByteEnabled(boolean byteEnabled) voidsetCacheSize(int cacheSize) voidsetCharEnabled(boolean charEnabled) voidsetTrainThreshold(int trainThreshold) static Stringstatic StringtoString(ByteChunk bc, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) static String
- 
Field Details- 
byteEnabledprotected static boolean byteEnabledEnabled ?
- 
charEnabledprotected static boolean charEnabled
- 
trainThresholdprotected static int trainThreshold
- 
cacheSizeprotected static int cacheSize
- 
maxStringSizeprotected static final int maxStringSize
- 
bcStatsStatistics hash map for byte chunk.
- 
bcCountprotected static int bcCounttoString count for byte chunk.
- 
bcCacheprotected static volatile org.apache.tomcat.util.buf.StringCache.ByteEntry[] bcCacheCache for byte chunk.
- 
ccStatsStatistics hash map for char chunk.
- 
ccCountprotected static int ccCounttoString count for char chunk.
- 
ccCacheprotected static volatile org.apache.tomcat.util.buf.StringCache.CharEntry[] ccCacheCache for char chunk.
- 
accessCountprotected static int accessCountAccess count.
- 
hitCountprotected static int hitCountHit count.
 
- 
- 
Constructor Details- 
StringCachepublic StringCache()
 
- 
- 
Method Details- 
getCacheSizepublic int getCacheSize()- Returns:
- Returns the cacheSize.
 
- 
setCacheSizepublic void setCacheSize(int cacheSize) - Parameters:
- cacheSize- The cacheSize to set.
 
- 
getByteEnabledpublic boolean getByteEnabled()- Returns:
- Returns the enabled.
 
- 
setByteEnabledpublic void setByteEnabled(boolean byteEnabled) - Parameters:
- byteEnabled- The enabled to set.
 
- 
getCharEnabledpublic boolean getCharEnabled()- Returns:
- Returns the enabled.
 
- 
setCharEnabledpublic void setCharEnabled(boolean charEnabled) - Parameters:
- charEnabled- The enabled to set.
 
- 
getTrainThresholdpublic int getTrainThreshold()- Returns:
- Returns the trainThreshold.
 
- 
setTrainThresholdpublic void setTrainThreshold(int trainThreshold) - Parameters:
- trainThreshold- The trainThreshold to set.
 
- 
getAccessCountpublic int getAccessCount()- Returns:
- Returns the accessCount.
 
- 
getHitCountpublic int getHitCount()- Returns:
- Returns the hitCount.
 
- 
resetpublic void reset()
- 
toString
- 
toStringpublic static String toString(ByteChunk bc, CodingErrorAction malformedInputAction, CodingErrorAction unmappableCharacterAction) throws CharacterCodingException - Throws:
- CharacterCodingException
 
- 
toString
- 
compareCompare given byte chunk with byte array.- Parameters:
- name- The name to compare
- compareTo- The compared to data
- Returns:
- -1, 0 or +1 if inferior, equal, or superior to the String.
 
- 
findDeprecated.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
 
- 
findprotected 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 find
- malformedInputAction- Action to take if an malformed input is encountered
- unmappableCharacterAction- Action to take if an unmappable character is encountered
- Returns:
- the corresponding value
 
- 
findClosestprotected 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 find
- array- The array in which to look
- len- The effective length of the array
- Returns:
- the position of the best match
 
- 
compareCompare given char chunk with char array.- Parameters:
- name- The name to compare
- compareTo- The compared to data
- Returns:
- -1, 0 or +1 if inferior, equal, or superior to the String.
 
- 
findFind an entry given its name in the cache and return the associated String.- Parameters:
- name- The name to find
- Returns:
- the corresponding value
 
- 
findClosestprotected 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 find
- array- The array in which to look
- len- The effective length of the array
- Returns:
- the position of the best match
 
 
-