Package org.nuxeo.ecm.core.storage
Class State
java.lang.Object
org.nuxeo.ecm.core.storage.State
- All Implemented Interfaces:
Serializable
,StateAccessor
- Direct Known Subclasses:
State.StateDiff
Abstraction for a Map<String, Serializable> that is Serializable.
Internal storage is optimized to avoid a full HashMap
when there is a small number of keys.
- Since:
- 5.9.5
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionState()
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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) Checks if there is a mapping for the given key.entrySet()
Gets the entry set.boolean
Gets a value for a key, ornull
if the key is not present.Object[]
Gets an array value.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.keySet()
Gets the key set.void
put
(String key, Serializable value) Sets a key/value.protected void
putEvenIfNull
(String key, Serializable value) Removes the mapping for a key.void
Sets an array value.void
Sets a single value.int
size()
Gets the number of elements.toString()
Overridden to display Calendars and arrays better, and truncate long strings and arrays.protected static void
toString
(StringBuilder sb, Object value)
-
Field Details
-
ARRAY_MAX
public static final int ARRAY_MAX- See Also:
-
EMPTY
-
NOP
public static final org.nuxeo.ecm.core.storage.State.Nop NOPDenotes no change to an element. -
map
-
keys
-
values
-
-
Constructor Details
-
State
public State()Constructor with default capacity. -
State
public State(boolean threadSafe) Constructor with default capacity, optionally thread-safe.- Parameters:
threadSafe
- iftrue
, then aConcurrentHashMap
is used
-
State
public State(int size) Constructor for a given default size. -
State
public State(int size, boolean threadSafe) Constructor for a given default size, optionally thread-safe.- Parameters:
threadSafe
- iftrue
, then aConcurrentHashMap
is used
-
-
Method Details
-
initialCapacity
protected static int initialCapacity(int size) -
size
public int size()Gets the number of elements. -
isEmpty
public boolean isEmpty()Checks if the state is empty. -
get
Gets a value for a key, ornull
if the key is not present. -
put
Sets a key/value. -
putEvenIfNull
-
remove
Removes the mapping for a key.- Returns:
- the previous value associated with the key, or
null
if there was no mapping for the key
-
keySet
Gets the key set. IT MUST NOT BE MODIFIED. -
keyArray
Gets an array of keys. -
containsKey
Checks if there is a mapping for the given key. -
entrySet
Gets the entry set. IT MUST NOT BE MODIFIED. -
toString
Overridden to display Calendars and arrays better, and truncate long strings and arrays.Also displays some keys first (ecm:id, ecm:name, ecm:primaryType)
-
toString
-
getSingle
Description copied from interface:StateAccessor
Gets a single value.- Specified by:
getSingle
in interfaceStateAccessor
- Parameters:
name
- the name- Returns:
- the value
-
getArray
Description copied from interface:StateAccessor
Gets an array value.- Specified by:
getArray
in interfaceStateAccessor
- Parameters:
name
- the name- Returns:
- the value
-
setSingle
Description copied from interface:StateAccessor
Sets a single value.- Specified by:
setSingle
in interfaceStateAccessor
- Parameters:
name
- the namevalue
- the value
-
setArray
Description copied from interface:StateAccessor
Sets an array value.- Specified by:
setArray
in interfaceStateAccessor
- Parameters:
name
- the namevalue
- the value
-
equals
-