Package ej.bon
Class Immutables
- java.lang.Object
-
- ej.bon.Immutables
-
public class Immutables extends Object
This class gives access to the global immutable objects pool.Immutable objects are persistent and normally reside in read-only-memory, such as flash memory.
The method
get(String)allows to retrieve an object from the pool using its ID.
-
-
Constructor Summary
Constructors Constructor Description Immutables()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String[]allIDs()Returns an array with the IDs of all the objects in the pool.static longfreeMemory()Returns the amount of free immutable memory still available.static Objectget(String ID)Retrieves the object that match the the given ID in the immutable objects pool.static booleanisImmutable(Object object)Gets whether or not the given object is in the immutable objects pool or not.static voidput(String ID, Object object)Deprecated.static voidputAll(Hashtable table)Deprecated.static longtotalMemory()Returns the total amount of immutable memory.
-
-
-
Method Detail
-
get
public static Object get(String ID)
Retrieves the object that match the the given ID in the immutable objects pool.If no object can be found with such ID, a
NoSuchElementExceptionis thrown.- Parameters:
ID- the ID of the immutable object to get- Returns:
- the immutable object matching the ID
- Throws:
NoSuchElementException- if the ID is not foundImmutablesError- if an internal error occurred during immutable access
-
put
@Deprecated public static void put(String ID, Object object)
Deprecated.Maps the given ID to the given object in the immutable objects pool.The object can be retrieved by calling the get method with an ID that is equal to the original ID.
- Parameters:
ID- the ID of the immutable object to setobject- the object to set immutable- Throws:
NullPointerException- if given object isnullOutOfMemoryError- if the immutable memory is full- See Also:
freeMemory()
-
putAll
@Deprecated public static void putAll(Hashtable table)
Deprecated.Maps all the mappings in the given table in the immutable objects pool.- Parameters:
table- the table that contains the objects to set immutable- Throws:
NullPointerException- if given table isnullClassCastException- if an ID is not aStringOutOfMemoryError- if the immutable memory is full- See Also:
freeMemory(),put(String, Object)
-
isImmutable
public static boolean isImmutable(Object object)
Gets whether or not the given object is in the immutable objects pool or not.- Parameters:
object- the object to check- Returns:
trueif the given object is immutable,falseotherwise- Throws:
NullPointerException- if given object isnull
-
allIDs
public static String[] allIDs()
Returns an array with the IDs of all the objects in the pool.- Returns:
- all the immutable objects ID.
- See Also:
get(String)
-
freeMemory
public static long freeMemory()
Returns the amount of free immutable memory still available.- Returns:
- the amount of free immutable memory
-
totalMemory
public static long totalMemory()
Returns the total amount of immutable memory.Note that the amount of memory required to hold an object of any given type may be implementation-dependent.
- Returns:
- the total amount of immutable memory
-
-