Class ModifiedNodeState
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.state.AbstractNodeState
-
- org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState
-
- All Implemented Interfaces:
NodeState
public class ModifiedNodeState extends AbstractNodeState
Immutable snapshot of a mutable node state.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull NodeBuilderbuilder()Returns a builder for constructing a new node state based on this state, i.e.booleancompareAgainstBaseState(NodeState base, NodeStateDiff diff)Since we keep track of an explicit base node state for aModifiedNodeStateinstance, we can do this in two steps: first compare all the modified properties and child nodes to those of the given base state, and then compare the base states to each other, ignoring all changed properties and child nodes that were already covered earlier.booleanexists()Checks whether this node exists.@NotNull NodeStategetBaseState()@NotNull NodeStategetChildNode(@NotNull java.lang.String name)Returns the named, possibly non-existent, child node.longgetChildNodeCount(long max)Returns the number of iterable child nodes of this node.@NotNull java.lang.Iterable<? extends ChildNodeEntry>getChildNodeEntries()Returns the iterable child node entries of this instance.java.lang.Iterable<java.lang.String>getChildNodeNames()Returns the names of all iterable child nodes.@NotNull java.lang.Iterable<? extends PropertyState>getProperties()Returns an iterable of the properties of this node.PropertyStategetProperty(@NotNull java.lang.String name)Returns the named property, ornullif no such property exists.longgetPropertyCount()Returns the number of properties of this node.booleanhasChildNode(@NotNull java.lang.String name)Checks whether the named child node exists.booleanhasProperty(@NotNull java.lang.String name)Checks whether the named property exists.static NodeStatesqueeze(NodeState state)"Squeezes"ModifiedNodeStateinstances into equivalentMemoryNodeStates.-
Methods inherited from class org.apache.jackrabbit.oak.spi.state.AbstractNodeState
checkValidName, compareAgainstBaseState, comparePropertiesAgainstBaseState, equals, equals, getBoolean, getBoolean, getLong, getLong, getName, getName, getNames, getNames, getString, getString, getStrings, getStrings, hashCode, isValidName, toString, toString
-
-
-
-
Method Detail
-
squeeze
public static NodeState squeeze(NodeState state)
"Squeezes"ModifiedNodeStateinstances into equivalentMemoryNodeStates. Other kinds of states are returned as-is.
-
getBaseState
@NotNull public @NotNull NodeState getBaseState()
-
builder
@NotNull public @NotNull NodeBuilder builder()
Description copied from interface:NodeStateReturns a builder for constructing a new node state based on this state, i.e. starting with all the properties and child nodes of this state.- Returns:
- node builder based on this state
-
exists
public boolean exists()
Description copied from interface:NodeStateChecks whether this node exists. See the above discussion about the existence of node states.- Returns:
trueif this node exists,falseif not
-
getPropertyCount
public long getPropertyCount()
Description copied from interface:NodeStateReturns the number of properties of this node.- Specified by:
getPropertyCountin interfaceNodeState- Overrides:
getPropertyCountin classAbstractNodeState- Returns:
- number of properties
-
hasProperty
public boolean hasProperty(@NotNull @NotNull java.lang.String name)Description copied from interface:NodeStateChecks whether the named property exists. The implementation is equivalent togetProperty(name) != null, but may be optimized to avoid having to load the property value.- Specified by:
hasPropertyin interfaceNodeState- Overrides:
hasPropertyin classAbstractNodeState- Parameters:
name- property name- Returns:
trueif the named property exists,falseotherwise
-
getProperty
public PropertyState getProperty(@NotNull @NotNull java.lang.String name)
Description copied from interface:NodeStateReturns the named property, ornullif no such property exists.- Specified by:
getPropertyin interfaceNodeState- Overrides:
getPropertyin classAbstractNodeState- Parameters:
name- name of the property to return- Returns:
- named property, or
nullif not found
-
getProperties
@NotNull public @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
Description copied from interface:NodeStateReturns an iterable of the properties of this node. Multiple iterations are guaranteed to return the properties in the same order, but the specific order used is implementation-dependent and may change across different states of the same node.- Returns:
- properties in some stable order
-
getChildNodeCount
public long getChildNodeCount(long max)
Description copied from interface:NodeStateReturns the number of iterable child nodes of this node.If an implementation knows the exact value, it returns it (even if the value is higher than max). If the implementation does not know the exact value, and the child node count is higher than max, it may return Long.MAX_VALUE. The cost of the operation is at most O(max).
- Specified by:
getChildNodeCountin interfaceNodeState- Overrides:
getChildNodeCountin classAbstractNodeState- Parameters:
max- the maximum number of entries to traverse- Returns:
- number of iterable child nodes
-
hasChildNode
public boolean hasChildNode(@NotNull @NotNull java.lang.String name)Description copied from interface:NodeStateChecks whether the named child node exists. The implementation is equivalent togetChildNode(name).exists(), except that passing an invalid name as argument will result in afalsereturn value instead of anIllegalArgumentException.- Parameters:
name- name of the child node- Returns:
trueif the named child node exists,falseotherwise
-
getChildNode
@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull java.lang.String name)
Description copied from interface:NodeStateReturns the named, possibly non-existent, child node. Use theNodeState.exists()method on the returned child node to determine whether the node exists or not.- Parameters:
name- name of the child node to return- Returns:
- named child node
-
getChildNodeNames
public java.lang.Iterable<java.lang.String> getChildNodeNames()
Description copied from interface:NodeStateReturns the names of all iterable child nodes.- Specified by:
getChildNodeNamesin interfaceNodeState- Overrides:
getChildNodeNamesin classAbstractNodeState- Returns:
- child node names in some stable order
-
getChildNodeEntries
@NotNull public @NotNull java.lang.Iterable<? extends ChildNodeEntry> getChildNodeEntries()
Description copied from interface:NodeStateReturns the iterable child node entries of this instance. Multiple iterations are guaranteed to return the child nodes in the same order, but the specific order used is implementation dependent and may change across different states of the same node.Note on cost and performance: while it is possible to iterate over all child
NodeStates with the two methodsNodeState.getChildNodeNames()andNodeState.getChildNode(String), this method is considered more efficient because an implementation can potentially perform the retrieval of the name andNodeStatein one call. This results in O(n) vs. O(n log n) when iterating over the child node names and then look up theNodeStateby name.- Returns:
- child node entries in some stable order
-
compareAgainstBaseState
public boolean compareAgainstBaseState(NodeState base, NodeStateDiff diff)
Since we keep track of an explicit base node state for aModifiedNodeStateinstance, we can do this in two steps: first compare all the modified properties and child nodes to those of the given base state, and then compare the base states to each other, ignoring all changed properties and child nodes that were already covered earlier.- Specified by:
compareAgainstBaseStatein interfaceNodeState- Overrides:
compareAgainstBaseStatein classAbstractNodeState- Parameters:
base- base statediff- handler of node state differences- Returns:
trueif the full diff was performed, orfalseif it was aborted as requested by the handler (see theNodeStateDiffcontract for more details)
-
-