com.sibvisions.util
Class Internalize

java.lang.Object
  extended by com.sibvisions.util.Internalize

public final class Internalize
extends java.lang.Object

Intern functionality for all immutable Objects. It's about 2 times faster than String.intern().


Method Summary
static void clearCache()
          Clears the interned objects.
static int getMaxObjectCount()
          Gets the maximum amount of internalized objects.
static long getMinimalRehashCheckInterval()
          The minimal interval, the rehashing is done in ms.
static int getObjectCount()
          Gets the amount of internalized objects.
static
<T> T
intern(T pObject)
          Internalizes any Immutable Object.
static
<T> T
internNoSync(T pObject)
          Internalizes any Immutable Object.
static boolean isDisabled()
          True, if internalize is disabled.
static void setDisabled(boolean pInternalizeDisabled)
          True, if internalize is disabled.
static void setMaxObjectCount(int pMaximumInternalizedObjectCount)
          Sets the maximum amount of internalized objects.
static void setMinimalRehashCheckInterval(long pMinimalRehashCheckInterval)
          The minimal interval, the rehashing is done in ms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clearCache

public static final void clearCache()
Clears the interned objects.


getMinimalRehashCheckInterval

public static final long getMinimalRehashCheckInterval()
The minimal interval, the rehashing is done in ms. Default is 5000ms.

Returns:
minimal interval, the rehashing is done in ms.

setMinimalRehashCheckInterval

public static final void setMinimalRehashCheckInterval(long pMinimalRehashCheckInterval)
The minimal interval, the rehashing is done in ms. Default is 5000ms.

Parameters:
pMinimalRehashCheckInterval - minimal interval, the rehashing is done in ms.

isDisabled

public static final boolean isDisabled()
True, if internalize is disabled. Default it is enabled.

Returns:
True, if internalize is disabled.

setDisabled

public static final void setDisabled(boolean pInternalizeDisabled)
True, if internalize is disabled. Default it is enabled.

Parameters:
pInternalizeDisabled - True, if internalize is disabled.

getObjectCount

public static final int getObjectCount()
Gets the amount of internalized objects.

Returns:
the amount of internalized objects.

getMaxObjectCount

public static final int getMaxObjectCount()
Gets the maximum amount of internalized objects. The maximum will never be reached exactly, as the cache size is based on primes. It is only guaranteed, that the object count will not be greater then max object count.

Returns:
the maximum amount of internalized objects.

setMaxObjectCount

public static final void setMaxObjectCount(int pMaximumInternalizedObjectCount)
Sets the maximum amount of internalized objects. The maximum will never be reached exactly, as the cache size is based on primes. It is only guaranteed, that the object count will not be greater then max object count.

Parameters:
pMaximumInternalizedObjectCount - the maximum amount of internalized objects.

intern

public static final <T> T intern(T pObject)
Internalizes any Immutable Object. The function is synchronized.

Type Parameters:
T - any immutable Object.
Parameters:
pObject - the Object to internalize.
Returns:
the internalized Object.

internNoSync

public static final <T> T internNoSync(T pObject)
Internalizes any Immutable Object. The function is not synchronized. It is provided for fast usage, in loops. The implementation has to be like:
   synchronized(Internalize.class)
   {
      ... 
        ... = Internalize.internNoSync(...);
      ...
   }
 

Type Parameters:
T - any immutable Object.
Parameters:
pObject - the Object to internalize.
Returns:
the internalized Object.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.