public class LazyValueMap
extends AbstractMap
implements ValueMap
This class is important to the performance of the parser. It stores Value objects in a map where they are evaluated lazily. This is great for JSONPath types of application, and Object Serialization but not for maps that are going to be stored in a cache.
This is because the Value construct is a type of index overlay that merely tracks where the token is located in the buffer, and what if any thing we noted about it (like can be converted to a decimal number, etc.). To mitigate memory leaks this class along with CharSequenceValue implement two constructs, namely, chop, and lazyChop. A chop is when we convert backing buffer of a Value object into a smaller buffer. A lazyChop is when we do a chop but only when a get operation is called. The lazyChop is performed on the tree that is touched by the JSONPath expression or its ilk. The chop operation can be done during parsing or lazily by storing the values in this construct.| Constructor and description |
|---|
LazyValueMap(boolean lazyChop)Creates a lazy map with the default item buffer size. |
LazyValueMap(boolean lazyChop, int initialSize)Creates a lazy map with a caller-supplied item buffer size. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public final void |
add(MapItemValue miv)Adds a new MapItemValue to the mapping. |
|
public final void |
chopMap()Chop this map. |
|
public Set<Entry<String, Object>> |
entrySet()Returns the hydrated entry set, building the backing map if necessary. |
|
public final Object |
get(Object key)Gets the item by key from the mapping. |
|
public boolean |
hydrated()Has the map been hydrated. |
|
public Entry<String, Value>[] |
items()Give me the items in the map without hydrating the map. Realize that the array is likely larger than the length so array items can be null. |
|
public int |
len()Return size w/o hydrating the map. |
|
public Value |
put(String key, Object value)Unsupported because parser-created entries are appended through add(MapItemValue). |
|
public int |
size()Returns the hydrated map size, building the backing map if necessary. |
|
public String |
toString()Returns the hydrated map string form, building the backing map if necessary. |
|
public Collection<Object> |
values()Returns the hydrated values collection, building the backing map if necessary. |
| Methods inherited from class | Name |
|---|---|
class AbstractMap |
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getClass, getOrDefault, hashCode, isEmpty, keySet, merge, notify, notifyAll, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, toString, values, wait, wait, wait |
Creates a lazy map with the default item buffer size.
lazyChop - whether touched branches should be chopped on accessCreates a lazy map with a caller-supplied item buffer size.
lazyChop - whether touched branches should be chopped on accessinitialSize - initial item buffer sizeAdds a new MapItemValue to the mapping.
miv - miv we are adding.Chop this map.
Returns the hydrated entry set, building the backing map if necessary.
Gets the item by key from the mapping.
key - to lookupHas the map been hydrated.
Give me the items in the map without hydrating the map. Realize that the array is likely larger than the length so array items can be null.
Return size w/o hydrating the map.
Unsupported because parser-created entries are appended through add(MapItemValue).
key - ignoredvalue - ignoredReturns the hydrated map size, building the backing map if necessary.
Returns the hydrated map string form, building the backing map if necessary.
Returns the hydrated values collection, building the backing map if necessary.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.