Package org.eclipse.emf.common.util
Class CommonUtil
java.lang.Object
org.eclipse.emf.common.util.CommonUtil
Static utilities for string pooling.
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".
- Since:
- 2.9
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringintern(char[] characters, int offset, int count) Returns an interned string value for the subsequence of characters.static Stringintern(CharSequence value) Returns an interned string value for the char sequence.static StringReturns an interned value for the string.static StringReturns an interned string value for the subsequence of characters.static StringinternToLowerCase(String value) Returns theinternedversion of the lower case version of this string.static StringinternToUpperCase(String value) Returns theinternedversion of the upper case version of this string.static StringjavaIntern(String value) Returns an interned value for the string.static URLCreates a URL.
-
Method Details
-
intern
Returns an interned value for the string. If the value needs to be added to the pool, acopywill be added. This ensures that we pool only instances with minimally-sized underlying character arrays. Note that the {copy constructorshares the underlying character array of the original if it's already minimally sized, so the memory impact of interning a string alreadyinternedby Java is minimal. Note that you should usejavaIntern(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. -
internToLowerCase
Returns theinternedversion of the lower case version of this string. It is equivalent to callingintern(value.toLowerCase(Locale.getDefaultLocale())), however, it's much faster, because the pool entry for thevalueitself 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. -
internToUpperCase
Returns theinternedversion of the upper case version of this string. It is equivalent to callingintern(value.toUpperCase(Locale.getDefaultLocale())), however, it's much faster, because the pool entry for thevalueitself 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. -
javaIntern
Returns an interned value for the string. If the value needs to be added to the pool, aJava interned versionwill 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. -
intern
Returns an interned string value for the subsequence of characters. 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. -
intern
Returns an interned string value for the subsequence of characters. 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. -
intern
Returns an interned string value for the char sequence. 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. -
newURL
Creates a URL.- Parameters:
literal- the url literal.- Returns:
- the corresponding new URL.
- Throws:
MalformedURLException- Since:
- 2.40
-