Package org.apache.tomcat.util.buf
Class StringCache
- java.lang.Object
- 
- org.apache.tomcat.util.buf.StringCache
 
- 
 public class StringCache extends java.lang.ObjectThis class implements a String cache for ByteChunk and CharChunk.- Author:
- Remy Maucherat
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected static intaccessCountAccess count.protected static org.apache.tomcat.util.buf.StringCache.ByteEntry[]bcCacheCache for byte chunk.protected static intbcCounttoString count for byte chunk.protected static java.util.HashMap<org.apache.tomcat.util.buf.StringCache.ByteEntry,int[]>bcStatsStatistics hash map for byte chunk.protected static booleanbyteEnabledEnabled ?protected static intcacheSizeprotected static org.apache.tomcat.util.buf.StringCache.CharEntry[]ccCacheCache for char chunk.protected static intccCounttoString count for char chunk.protected static java.util.HashMap<org.apache.tomcat.util.buf.StringCache.CharEntry,int[]>ccStatsStatistics hash map for char chunk.protected static booleancharEnabledprotected static inthitCountHit count.protected static intmaxStringSizeprotected static inttrainThreshold
 - 
Constructor SummaryConstructors Constructor Description StringCache()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static intcompare(ByteChunk name, byte[] compareTo)Compare given byte chunk with byte array.protected static intcompare(CharChunk name, char[] compareTo)Compare given char chunk with char array.protected static java.lang.Stringfind(ByteChunk name)Find an entry given its name in the cache and return the associated String.protected static java.lang.Stringfind(CharChunk name)Find an entry given its name in the cache and return the associated String.protected static 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 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.intgetAccessCount()booleangetByteEnabled()intgetCacheSize()booleangetCharEnabled()intgetHitCount()intgetTrainThreshold()voidreset()voidsetByteEnabled(boolean byteEnabled)voidsetCacheSize(int cacheSize)voidsetCharEnabled(boolean charEnabled)voidsetTrainThreshold(int trainThreshold)static java.lang.StringtoString(ByteChunk bc)static java.lang.StringtoString(CharChunk cc)
 
- 
- 
- 
Field Detail- 
byteEnabledprotected static boolean byteEnabled Enabled ?
 - 
charEnabledprotected static boolean charEnabled 
 - 
trainThresholdprotected static int trainThreshold 
 - 
cacheSizeprotected static int cacheSize 
 - 
maxStringSizeprotected static final int maxStringSize 
 - 
bcStatsprotected static final java.util.HashMap<org.apache.tomcat.util.buf.StringCache.ByteEntry,int[]> bcStats Statistics hash map for byte chunk.
 - 
bcCountprotected static int bcCount toString count for byte chunk.
 - 
bcCacheprotected static volatile org.apache.tomcat.util.buf.StringCache.ByteEntry[] bcCache Cache for byte chunk.
 - 
ccStatsprotected static final java.util.HashMap<org.apache.tomcat.util.buf.StringCache.CharEntry,int[]> ccStats Statistics hash map for char chunk.
 - 
ccCountprotected static int ccCount toString count for char chunk.
 - 
ccCacheprotected static volatile org.apache.tomcat.util.buf.StringCache.CharEntry[] ccCache Cache for char chunk.
 - 
accessCountprotected static int accessCount Access count.
 - 
hitCountprotected static int hitCount Hit count.
 
- 
 - 
Method Detail- 
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() 
 - 
toStringpublic static java.lang.String toString(ByteChunk bc) 
 - 
toStringpublic static java.lang.String toString(CharChunk cc) 
 - 
compareprotected static final int compare(ByteChunk name, byte[] compareTo) Compare 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.
 
 - 
findprotected static final java.lang.String find(ByteChunk name) Find 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(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
 
 - 
compareprotected static final int compare(CharChunk name, char[] compareTo) Compare 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.
 
 - 
findprotected static final java.lang.String find(CharChunk name) Find 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
 
 
- 
 
-