org.apache.tomcat.util.buf

Class StringCache

public class StringCache extends Object

This class implements a String cache for ByteChunk and CharChunk.

Author: Remy Maucherat

Nested Class Summary
static classStringCache.ByteEntry
static classStringCache.CharEntry
Field Summary
protected static intaccessCount
Access count.
protected static StringCache.ByteEntry[]bcCache
Cache for byte chunk.
protected static intbcCount
toString count for byte chunk.
protected static HashMapbcStats
Statistics hash map for byte chunk.
protected static booleanbyteEnabled
Enabled ?
protected static intcacheSize
protected static StringCache.CharEntry[]ccCache
Cache for char chunk.
protected static intccCount
toString count for char chunk.
protected static HashMapccStats
Statistics hash map for char chunk.
protected static booleancharEnabled
protected static inthitCount
Hit count.
protected static intmaxStringSize
protected static inttrainThreshold
Method Summary
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.
intgetAccessCount()
booleangetByteEnabled()
intgetCacheSize()
booleangetCharEnabled()
intgetHitCount()
intgetTrainThreshold()
voidreset()
voidsetByteEnabled(boolean byteEnabled)
voidsetCacheSize(int cacheSize)
voidsetCharEnabled(boolean charEnabled)
voidsetTrainThreshold(int trainThreshold)
static StringtoString(ByteChunk bc)
static StringtoString(CharChunk cc)

Field Detail

accessCount

protected static int accessCount
Access count.

bcCache

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

bcCount

protected static int bcCount
toString count for byte chunk.

bcStats

protected static HashMap bcStats
Statistics hash map for byte chunk.

byteEnabled

protected static boolean byteEnabled
Enabled ?

cacheSize

protected static int cacheSize

ccCache

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

ccCount

protected static int ccCount
toString count for char chunk.

ccStats

protected static HashMap ccStats
Statistics hash map for char chunk.

charEnabled

protected static boolean charEnabled

hitCount

protected static int hitCount
Hit count.

maxStringSize

protected static int maxStringSize

trainThreshold

protected static int trainThreshold

Method Detail

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.

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

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.

getAccessCount

public int getAccessCount()

Returns: Returns the accessCount.

getByteEnabled

public boolean getByteEnabled()

Returns: Returns the enabled.

getCacheSize

public int getCacheSize()

Returns: Returns the cacheSize.

getCharEnabled

public boolean getCharEnabled()

Returns: Returns the enabled.

getHitCount

public int getHitCount()

Returns: Returns the hitCount.

getTrainThreshold

public int getTrainThreshold()

Returns: Returns the trainThreshold.

reset

public void reset()

setByteEnabled

public void setByteEnabled(boolean byteEnabled)

Parameters: byteEnabled The enabled to set.

setCacheSize

public void setCacheSize(int cacheSize)

Parameters: cacheSize The cacheSize to set.

setCharEnabled

public void setCharEnabled(boolean charEnabled)

Parameters: charEnabled The enabled to set.

setTrainThreshold

public void setTrainThreshold(int trainThreshold)

Parameters: trainThreshold The trainThreshold to set.

toString

public static String toString(ByteChunk bc)

toString

public static String toString(CharChunk cc)
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.