public class Immutables
extends java.lang.Object
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 and Description |
---|
Immutables() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String[] |
allIDs()
Returns an array with the IDs of all the objects in the pool.
|
static long |
freeMemory()
Returns the amount of free immutable memory still available.
|
static java.lang.Object |
get(java.lang.String ID)
Retrieves the object that match the the given ID in the immutable objects
pool.
|
static boolean |
isImmutable(java.lang.Object object)
Gets whether or not the given object is in the immutable objects pool or not.
|
static void |
put(java.lang.String ID,
java.lang.Object object)
Deprecated.
|
static void |
putAll(java.util.Hashtable table)
Deprecated.
|
static long |
totalMemory()
Returns the total amount of immutable memory.
|
public static java.lang.Object get(java.lang.String ID)
If no object can be found with such ID, a NoSuchElementException
is
thrown.
ID
- the ID of the immutable object to getjava.util.NoSuchElementException
- if the ID is not foundImmutablesError
- if an internal error occurred during immutable access@Deprecated public static void put(java.lang.String ID, java.lang.Object object)
The object can be retrieved by calling the get method with an ID that is equal to the original ID.
ID
- the ID of the immutable object to setobject
- the object to set immutablejava.lang.NullPointerException
- if given object is null
java.lang.OutOfMemoryError
- if the immutable memory is fullfreeMemory()
@Deprecated public static void putAll(java.util.Hashtable table)
table
- the table that contains the objects to set immutablejava.lang.NullPointerException
- if given table is null
java.lang.ClassCastException
- if an ID is not a String
java.lang.OutOfMemoryError
- if the immutable memory is fullfreeMemory()
,
put(String, Object)
public static boolean isImmutable(java.lang.Object object)
object
- the object to checktrue
if the given object is immutable,
false
otherwisejava.lang.NullPointerException
- if given object is null
public static java.lang.String[] allIDs()
get(String)
public static long freeMemory()
public static long totalMemory()
Note that the amount of memory required to hold an object of any given type may be implementation-dependent.