Package lazyj
Class StringFactory
java.lang.Object
lazyj.StringFactory
Keep references to common strings to avoid filling the memory with garbage. We don't use String.intern() any more because it seems to never clean up. Instead it is now relaying on a WeakHashMap.
- Since:
- Aug 10, 2007 (1.0.2)
- Author:
- costing
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Deprecated.static Stringget(byte[] vb) Get the global string pointer for this byte arraystatic Stringget(char[] vc) Get the global string pointer for this char arraystatic StringGet the global string pointer for this valuestatic longGet the total number of accesses to this cachestatic intStatistics function: the number of strings in the cache.static doubleCalculate the cache efficiency (hits / total requests)static doubleCalculate the percentage of requests that were ignored because of size limits.static voidClear the counters
-
Constructor Details
-
StringFactory
public StringFactory()
-
-
Method Details
-
get
Get the global string pointer for this byte array- Parameters:
vb-- Returns:
- the global string pointer
-
get
Get the global string pointer for this char array- Parameters:
vc-- Returns:
- the global string pointer
-
get
Get the global string pointer for this value- Parameters:
s-- Returns:
- the global string pointer for an object having the same value
-
getCacheSize
public static int getCacheSize()Statistics function: the number of strings in the cache.- Returns:
- the number of strings in the cache
-
getHitRatio
public static double getHitRatio()Calculate the cache efficiency (hits / total requests)- Returns:
- cache efficiency
-
getIgnoreRatio
public static double getIgnoreRatio()Calculate the percentage of requests that were ignored because of size limits.- Returns:
- ignore ratio
-
getAccessCount
public static long getAccessCount()Get the total number of accesses to this cache- Returns:
- the number of accesses to this cache
-
resetHitCounters
public static void resetHitCounters()Clear the counters -
clear
Deprecated.Clear this cache structure
-