public class State extends Object implements StateAccessor, Serializable
Internal storage is optimized to avoid a full HashMap
when there is a small number of keys.
Modifier and Type | Class and Description |
---|---|
class |
State.ArraysEntry |
class |
State.ArraysEntryIterator |
protected class |
State.ArraysEntrySet
EntrySet optimized to just return a simple Iterator on the entries.
|
static class |
State.ListDiff
A diff for an array or
List . |
static class |
State.StateDiff
A diff for a
State . |
Modifier and Type | Field and Description |
---|---|
static int |
ARRAY_MAX |
static State |
EMPTY |
protected List<String> |
keys |
protected static org.apache.commons.logging.Log |
log |
protected Map<String,Serializable> |
map |
static org.nuxeo.ecm.core.storage.State.Nop |
NOP
Denotes no change to an element.
|
protected List<Serializable> |
values |
Constructor and Description |
---|
State()
Constructor with default capacity.
|
State(boolean threadSafe)
Constructor with default capacity, optionally thread-safe.
|
State(int size)
Constructor for a given default size.
|
State(int size,
boolean threadSafe)
Constructor for a given default size, optionally thread-safe.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(Object key)
Checks if there is a mapping for the given key.
|
Set<Map.Entry<String,Serializable>> |
entrySet()
Gets the entry set.
|
boolean |
equals(Object other) |
Serializable |
get(Object key)
Gets a value for a key, or
null if the key is not present. |
Object[] |
getArray(String name)
Gets an array value.
|
Object |
getSingle(String name)
Gets a single value.
|
protected static int |
initialCapacity(int size) |
boolean |
isEmpty()
Checks if the state is empty.
|
String[] |
keyArray()
Gets an array of keys.
|
Set<String> |
keySet()
Gets the key set.
|
void |
put(String key,
Serializable value)
Sets a key/value.
|
protected void |
putEvenIfNull(String key,
Serializable value) |
Serializable |
remove(Object key)
Removes the mapping for a key.
|
void |
setArray(String name,
Object[] value)
Sets an array value.
|
void |
setSingle(String name,
Object value)
Sets a single value.
|
int |
size()
Gets the number of elements.
|
String |
toString()
Overridden to display Calendars and arrays better, and truncate long strings and arrays.
|
protected static void |
toString(StringBuilder buf,
Object value) |
protected static final org.apache.commons.logging.Log log
public static final int ARRAY_MAX
public static final org.nuxeo.ecm.core.storage.State.Nop NOP
protected Map<String,Serializable> map
protected List<Serializable> values
public State()
public State(boolean threadSafe)
threadSafe
- if true
, then a ConcurrentHashMap
is usedpublic State(int size)
public State(int size, boolean threadSafe)
threadSafe
- if true
, then a ConcurrentHashMap
is usedprotected static int initialCapacity(int size)
public int size()
public boolean isEmpty()
public Serializable get(Object key)
null
if the key is not present.public void put(String key, Serializable value)
protected void putEvenIfNull(String key, Serializable value)
public Serializable remove(Object key)
null
if there was no mapping for the keypublic boolean containsKey(Object key)
public Set<Map.Entry<String,Serializable>> entrySet()
public String toString()
Also displays some keys first (ecm:id, ecm:name, ecm:primaryType)
protected static void toString(StringBuilder buf, Object value)
public Object getSingle(String name)
StateAccessor
getSingle
in interface StateAccessor
name
- the namepublic Object[] getArray(String name)
StateAccessor
getArray
in interface StateAccessor
name
- the namepublic void setSingle(String name, Object value)
StateAccessor
setSingle
in interface StateAccessor
name
- the namevalue
- the valuepublic void setArray(String name, Object[] value)
StateAccessor
setArray
in interface StateAccessor
name
- the namevalue
- the valueCopyright © 2017 Nuxeo. All rights reserved.