Class StringCache
java.lang.Object
org.apache.jackrabbit.spi.commons.util.StringCache
A few String utility functions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final int -
Method Summary
-
Field Details
-
OBJECT_CACHE
public static final boolean OBJECT_CACHE -
OBJECT_CACHE_SIZE
public static final int OBJECT_CACHE_SIZE
-
-
Method Details
-
cache
Get the string from the cache if possible. If the string has not been found, it is added to the cache. If there is such a string in the cache, that one is returned.- Parameters:
s- the original string- Returns:
- a string with the same content, if possible from the cache
-
fromCacheOrNew
Get a string from the cache, and if no such string has been found, create a new one with only this content. This solves out of memory problems if the string is a substring of another, large string. In Java, strings are shared, which could lead to memory problems. This avoid such problems.- Parameters:
s- the string- Returns:
- a string that is guaranteed not be a substring of a large string
-
clearCache
public static void clearCache()Clear the cache. This method is used for testing.
-