com.sun.grizzly.util.buf
Class StringCache

java.lang.Object
  extended by com.sun.grizzly.util.buf.StringCache

public class StringCache
extends Object

This class implements a String cache for ByteChunk and CharChunk.

Author:
Remy Maucherat

Nested Class Summary
protected static class StringCache.ByteEntry
           
protected static class StringCache.CharEntry
           
 
Field Summary
protected static int accessCount
          Access count.
protected static StringCache.ByteEntry[] bcCache
          Cache for byte chunk.
protected static int bcCount
          toString count for byte chunk.
protected static HashMap bcStats
          Statistics hash map for byte chunk.
protected static boolean byteEnabled
          Enabled ?
protected static int cacheSize
           
protected static StringCache.CharEntry[] ccCache
          Cache for char chunk.
protected static int ccCount
          toString count for char chunk.
protected static HashMap ccStats
          Statistics hash map for char chunk.
protected static boolean charEnabled
           
protected static int hitCount
          Hit count.
protected static int trainThreshold
           
 
Constructor Summary
StringCache()
           
 
Method Summary
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 String find(ByteChunk name)
          Find an entry given its name in the cache and return the associated String.
protected static String find(CharChunk name)
          Find an entry given its name in the cache and return the associated String.
protected static int findClosest(ByteChunk name, StringCache.ByteEntry[] array, int len)
          Find an entry given its name in a sorted array of map elements.
protected static int findClosest(CharChunk name, StringCache.CharEntry[] array, int len)
          Find an entry given its name in a sorted array of map elements.
static int getAccessCount()
           
static boolean getByteEnabled()
           
static int getCacheSize()
           
static boolean getCharEnabled()
           
static int getHitCount()
           
static int getTrainThreshold()
           
static void reset()
           
static void setByteEnabled(boolean byteEnabled)
           
static void setCacheSize(int cacheSize)
           
static void setCharEnabled(boolean charEnabled)
           
static void setTrainThreshold(int trainThreshold)
           
static String toString(ByteChunk bc)
           
static String toString(CharChunk cc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

byteEnabled

protected static boolean byteEnabled
Enabled ?


charEnabled

protected static boolean charEnabled

trainThreshold

protected static int trainThreshold

cacheSize

protected static int cacheSize

bcStats

protected static final HashMap bcStats
Statistics hash map for byte chunk.


bcCount

protected static int bcCount
toString count for byte chunk.


bcCache

protected static StringCache.ByteEntry[] bcCache
Cache for byte chunk.


ccStats

protected static final HashMap ccStats
Statistics hash map for char chunk.


ccCount

protected static int ccCount
toString count for char chunk.


ccCache

protected static StringCache.CharEntry[] ccCache
Cache for char chunk.


accessCount

protected static int accessCount
Access count.


hitCount

protected static int hitCount
Hit count.

Constructor Detail

StringCache

public StringCache()
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:
enabled - The enabled to set.

getCharEnabled

public static boolean getCharEnabled()
Returns:
Returns the enabled.

setCharEnabled

public static void setCharEnabled(boolean charEnabled)
Parameters:
enabled - 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()

toString

public static String toString(ByteChunk bc)

toString

public static String toString(CharChunk cc)

compare

protected static final 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 final String find(ByteChunk name)
Find an entry given its name in the cache and return the associated String.


findClosest

protected static final 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 final 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 final String find(CharChunk name)
Find an entry given its name in the cache and return the associated String.


findClosest

protected static final 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.



Copyright © 2011 SUN Microsystems. All Rights Reserved.