public final class StringPool extends Object
A string pool instance is initialized with
a "limit" parameter at construction.
For a string pool strPool with a limit of N,
and two strings S1 and S2;
strPool.get(S1) and
strPool.get(S2) are guaranteed to return a reference to the same string instance
iff S1.equals(S2) && S1.length() <= N.
Using StringPool is preferrable to using String.intern(), which stores strings in
its internal cache permanently. StringPool implements a mechanism to "age-out"
entries over time.
(NOTE: the age-out mechanism hasn't been implemented yet, but it will be soon!)
| Constructor and Description |
|---|
StringPool()
Constructs a string pool with the default string length limit of 64.
|
StringPool(int limit)
Constructs a string pool with the specified string length limit.
|
public StringPool()
public StringPool(int limit)
limit or less will be canonicalized.limit - the string length limitpublic String get(String s)
s - the stringCopyright © 2014. All Rights Reserved.