Package org.apache.tomcat.util.buf
Class StringCache
- java.lang.Object
-
- org.apache.tomcat.util.buf.StringCache
-
public class StringCache extends java.lang.Object
This class implements a String cache for ByteChunk and CharChunk.- Author:
- Remy Maucherat
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
accessCount
Access count.protected static org.apache.tomcat.util.buf.StringCache.ByteEntry[]
bcCache
Cache for byte chunk.protected static int
bcCount
toString count for byte chunk.protected static java.util.HashMap<org.apache.tomcat.util.buf.StringCache.ByteEntry,int[]>
bcStats
Statistics hash map for byte chunk.protected static boolean
byteEnabled
Enabled ?protected static int
cacheSize
protected static org.apache.tomcat.util.buf.StringCache.CharEntry[]
ccCache
Cache for char chunk.protected static int
ccCount
toString count for char chunk.protected static java.util.HashMap<org.apache.tomcat.util.buf.StringCache.CharEntry,int[]>
ccStats
Statistics hash map for char chunk.protected static boolean
charEnabled
protected static int
hitCount
Hit count.protected static int
maxStringSize
protected static int
trainThreshold
-
Constructor Summary
Constructors Constructor Description StringCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static int
compare(ByteChunk name, byte[] compareTo)
Compare given byte chunk with byte array.protected static int
compare(CharChunk name, char[] compareTo)
Compare given char chunk with char array.protected static java.lang.String
find(ByteChunk name)
Find an entry given its name in the cache and return the associated String.protected static java.lang.String
find(CharChunk name)
Find an entry given its name in the cache and return the associated String.protected static 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 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
getAccessCount()
boolean
getByteEnabled()
int
getCacheSize()
boolean
getCharEnabled()
int
getHitCount()
int
getTrainThreshold()
void
reset()
void
setByteEnabled(boolean byteEnabled)
void
setCacheSize(int cacheSize)
void
setCharEnabled(boolean charEnabled)
void
setTrainThreshold(int trainThreshold)
static java.lang.String
toString(ByteChunk bc)
static java.lang.String
toString(CharChunk cc)
-
-
-
Field Detail
-
byteEnabled
protected static boolean byteEnabled
Enabled ?
-
charEnabled
protected static boolean charEnabled
-
trainThreshold
protected static int trainThreshold
-
cacheSize
protected static int cacheSize
-
maxStringSize
protected static final int maxStringSize
-
bcStats
protected static final java.util.HashMap<org.apache.tomcat.util.buf.StringCache.ByteEntry,int[]> bcStats
Statistics hash map for byte chunk.
-
bcCount
protected static int bcCount
toString count for byte chunk.
-
bcCache
protected static volatile org.apache.tomcat.util.buf.StringCache.ByteEntry[] bcCache
Cache for byte chunk.
-
ccStats
protected static final java.util.HashMap<org.apache.tomcat.util.buf.StringCache.CharEntry,int[]> ccStats
Statistics hash map for char chunk.
-
ccCount
protected static int ccCount
toString count for char chunk.
-
ccCache
protected static volatile org.apache.tomcat.util.buf.StringCache.CharEntry[] ccCache
Cache for char chunk.
-
accessCount
protected static int accessCount
Access count.
-
hitCount
protected static int hitCount
Hit count.
-
-
Method Detail
-
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
public static java.lang.String toString(ByteChunk bc)
-
toString
public static java.lang.String toString(CharChunk cc)
-
compare
protected static final int compare(ByteChunk name, byte[] compareTo)
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
protected 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
-
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
protected static final int compare(CharChunk name, char[] compareTo)
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
protected 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
-
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
-
-