public final class CommonUtil
extends java.lang.Object
As of EMF 2.9, the core runtime maintains a number of pools
managed by weak references
,
specifically a string pool
,
a string array pool
,
a segment sequence pool
,
and a URI pool
.
The weak referenced are optionally managed by a daemon thread.
The daemon thread is created by default only if there is no security manager
,
but that default can be overridden by specifying a true
or false
for the system property
"org.eclipse.emf.common.util.ReferenceClearingQueue"
.
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
intern(char[] characters,
int offset,
int count)
Returns an interned string value for the subsequence of characters.
|
static java.lang.String |
intern(java.lang.CharSequence value)
Returns an interned string value for the char sequence.
|
static java.lang.String |
intern(java.lang.String value)
Returns an interned value for the string.
|
static java.lang.String |
intern(java.lang.String string,
int offset,
int count)
Returns an interned string value for the subsequence of characters.
|
static java.lang.String |
internToLowerCase(java.lang.String value)
Returns the
interned version of the lower case version of this string. |
static java.lang.String |
internToUpperCase(java.lang.String value)
Returns the
interned version of the upper case version of this string. |
static java.lang.String |
javaIntern(java.lang.String value)
Returns an interned value for the string.
|
public static java.lang.String intern(java.lang.String value)
copy
will be added.
This ensures that we pool only instances with minimally-sized underlying character arrays.
Note that the {copy constructor
shares the underlying character array of the original if it's already minimally sized,
so the memory impact of interning a string already interned
by Java is minimal.
Note that you should use javaIntern(String)
for interning string literals.
This method is thread safe; the underlying representation supports shared read access and exclusive write access, holding locks for the shorted time possible to support maximal concurrency.
The interned strings are weakly referenced so are only maintained only as long as there remain strong references.public static java.lang.String internToLowerCase(java.lang.String value)
interned
version of the lower case version of this string.
It is equivalent to calling intern(value.toLowerCase(Locale.getDefaultLocale()))
,
however, it's much faster, because the pool entry for the value
itself weakly records the lower case variant.
Please note that the default locale at the time this class was initialized applies.
This method is thread safe; the underlying representation supports shared read access and exclusive write access, holding locks for the shorted time possible to support maximal concurrency.
The interned strings are weakly referenced so are only maintained only as long as there remain strong references.public static java.lang.String internToUpperCase(java.lang.String value)
interned
version of the upper case version of this string.
It is equivalent to calling intern(value.toUpperCase(Locale.getDefaultLocale()))
,
however, it's much faster, because the pool entry for the value
itself weakly records the upper case variant.
Please note that the default locale at the time this class was initialized applies.
This method is thread safe; the underlying representation supports shared read access and exclusive write access, holding locks for the shorted time possible to support maximal concurrency.
The interned strings are weakly referenced so are only maintained only as long as there remain strong references.public static java.lang.String javaIntern(java.lang.String value)
Java interned version
will be added.
It is highly recommend that you only call this with string constants, i.e., with values that are Java interned already, because you will exhaust permgen space if you do this haphazardly.
This method is thread safe; the underlying representation supports shared read access and exclusive write access, holding locks for the shorted time possible to support maximal concurrency.
The interned strings are weakly referenced but because they are Java interned, unless already in the pool, they will never be garbage collected.public static java.lang.String intern(char[] characters, int offset, int count)
public static java.lang.String intern(java.lang.String string, int offset, int count)
public static java.lang.String intern(java.lang.CharSequence value)