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 SummaryConstructors
- 
Method SummaryModifier 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- 
StringFactorypublic StringFactory()
 
- 
- 
Method Details- 
getGet the global string pointer for this byte array- Parameters:
- vb-
- Returns:
- the global string pointer
 
- 
getGet the global string pointer for this char array- Parameters:
- vc-
- Returns:
- the global string pointer
 
- 
getGet the global string pointer for this value- Parameters:
- s-
- Returns:
- the global string pointer for an object having the same value
 
- 
getCacheSizepublic static int getCacheSize()Statistics function: the number of strings in the cache.- Returns:
- the number of strings in the cache
 
- 
getHitRatiopublic static double getHitRatio()Calculate the cache efficiency (hits / total requests)- Returns:
- cache efficiency
 
- 
getIgnoreRatiopublic static double getIgnoreRatio()Calculate the percentage of requests that were ignored because of size limits.- Returns:
- ignore ratio
 
- 
getAccessCountpublic static long getAccessCount()Get the total number of accesses to this cache- Returns:
- the number of accesses to this cache
 
- 
resetHitCounterspublic static void resetHitCounters()Clear the counters
- 
clearDeprecated.Clear this cache structure
 
-