Package org.glassfish.grizzly.http.util
Class StringCache
- java.lang.Object
-
- org.glassfish.grizzly.http.util.StringCache
-
public final class StringCache extends Object
This class implements a String cache for ByteChunk and CharChunk.- Author:
- Remy Maucherat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classStringCache.ByteEntryprotected static classStringCache.CharEntry
-
Constructor Summary
Constructors Constructor Description StringCache()
-
Method Summary
All Methods Static 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 Stringfind(ByteChunk name)Find an entry given its name in the cache and return the associated String.protected static Stringfind(CharChunk name)Find an entry given its name in the cache and return the associated String.protected static intfindClosest(ByteChunk name, StringCache.ByteEntry[] array, int len)Find an entry given its name in a sorted array of map elements.protected static intfindClosest(CharChunk name, StringCache.CharEntry[] array, int len)Find an entry given its name in a sorted array of map elements.static intgetAccessCount()static booleangetByteEnabled()static intgetCacheSize()static booleangetCharEnabled()static intgetHitCount()static intgetTrainThreshold()static voidreset()static voidsetByteEnabled(boolean byteEnabled)static voidsetCacheSize(int cacheSize)static voidsetCharEnabled(boolean charEnabled)static voidsetTrainThreshold(int trainThreshold)static StringtoString(ByteChunk bc)static StringtoString(CharChunk cc)
-
-
-
Method Detail
-
getCacheSize
public static int getCacheSize()
- Returns:
- Returns the cacheSize.
-
setCacheSize
public static void setCacheSize(int cacheSize)
- Parameters:
cacheSize- The cacheSize to set.
-
getByteEnabled
public static boolean getByteEnabled()
- Returns:
- Returns the enabled.
-
setByteEnabled
public static void setByteEnabled(boolean byteEnabled)
- Parameters:
byteEnabled- The enabled to set.
-
getCharEnabled
public static boolean getCharEnabled()
- Returns:
- Returns the enabled.
-
setCharEnabled
public static void setCharEnabled(boolean charEnabled)
- Parameters:
charEnabled- The enabled to set.
-
getTrainThreshold
public static int getTrainThreshold()
- Returns:
- Returns the trainThreshold.
-
setTrainThreshold
public static void setTrainThreshold(int trainThreshold)
- Parameters:
trainThreshold- The trainThreshold to set.
-
getAccessCount
public static int getAccessCount()
- Returns:
- Returns the accessCount.
-
getHitCount
public static int getHitCount()
- Returns:
- Returns the hitCount.
-
reset
public static void reset()
-
compare
protected static int compare(ByteChunk name, byte[] compareTo)
Compare given byte chunk with byte array. Return -1, 0 or +1 if inferior, equal, or superior to the String.
-
find
protected static String find(ByteChunk name)
Find an entry given its name in the cache and return the associated String.
-
findClosest
protected static int findClosest(ByteChunk name, 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.
-
compare
protected static int compare(CharChunk name, char[] compareTo)
Compare given char chunk with char array. Return -1, 0 or +1 if inferior, equal, or superior to the String.
-
find
protected static String find(CharChunk name)
Find an entry given its name in the cache and return the associated String.
-
findClosest
protected static int findClosest(CharChunk name, 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.
-
-