StringCache (RabbIT/4)
Date: 2009-12-20

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rabbit.util
Class StringCache

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.WeakHashMap<String,WeakReference<String>>
              rabbit.util.StringCache

All Implemented Interfaces:
  Map<String,WeakReference<String>>

    public class StringCache

extends WeakHashMap<String,WeakReference<String>>

A cache for strings. The cache is weak so GC can happen quickly. String.intern may seem similar, but String.intern is a hard cache, that is no GC will remove interned strings.

Author:
  Robert Olofsson

Nested Class Summary

Nested classes/interfaces inherited from class java.util.AbstractMap
`AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

Constructor Summary
`StringCache()`

Method Summary
`String` | `getCachedString(String s)` Get a cached string with the same contents as the given string.
`static StringCache` | `getSharedInstance()` Get the shared instance of the string caches.

Methods inherited from class java.util.WeakHashMap
`clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values`

Methods inherited from class java.util.AbstractMap
`clone, equals, hashCode, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Constructor Detail

### StringCache

    public StringCache()

Method Detail

### getSharedInstance

    public static StringCache getSharedInstance()

  Get the shared instance of the string caches.

### getCachedString

    public String getCachedString(String s)

  Get a cached string with the same contents as the given string. If the string given is not null then the cache will hold one entry with the same value as the given string after this method has completed.

  Parameters:
    `s` - the string to get a shared string for.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD