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
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionState()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 TypeMethodDescriptionbooleancontainsKey(Object key) Checks if there is a mapping for the given key.entrySet()Gets the entry set.booleanGets a value for a key, ornullif the key is not present.Object[]Gets an array value.Gets a single value.protected static intinitialCapacity(int size) booleanisEmpty()Checks if the state is empty.String[]keyArray()Gets an array of keys.keySet()Gets the key set.voidput(String key, Serializable value) Sets a key/value.protected voidputEvenIfNull(String key, Serializable value) Removes the mapping for a key.voidSets an array value.voidSets a single value.intsize()Gets the number of elements.toString()Overridden to display Calendars and arrays better, and truncate long strings and arrays.protected static voidtoString(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 aConcurrentHashMapis 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 aConcurrentHashMapis 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, ornullif 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
nullif 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:StateAccessorGets a single value.- Specified by:
getSinglein interfaceStateAccessor- Parameters:
name- the name- Returns:
- the value
-
getArray
Description copied from interface:StateAccessorGets an array value.- Specified by:
getArrayin interfaceStateAccessor- Parameters:
name- the name- Returns:
- the value
-
setSingle
Description copied from interface:StateAccessorSets a single value.- Specified by:
setSinglein interfaceStateAccessor- Parameters:
name- the namevalue- the value
-
setArray
Description copied from interface:StateAccessorSets an array value.- Specified by:
setArrayin interfaceStateAccessor- Parameters:
name- the namevalue- the value
-
equals
-