Class DocumentNodeState
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.state.AbstractNodeState
-
- org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState
-
- org.apache.jackrabbit.oak.plugins.document.DocumentNodeState
-
- All Implemented Interfaces:
CacheValue
,NodeState
public class DocumentNodeState extends AbstractDocumentNodeState implements CacheValue
ANodeState
implementation for theDocumentNodeStore
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DocumentNodeState.BundlingContext
static class
DocumentNodeState.Children
A list of children for a node.
-
Field Summary
Fields Modifier and Type Field Description static DocumentNodeState.Children
NO_CHILDREN
-
Constructor Summary
Constructors Modifier Constructor Description DocumentNodeState(@NotNull DocumentNodeStore store, @NotNull Path path, @NotNull RevisionVector rootRevision, @NotNull Map<String,PropertyState> properties, boolean hasChildren, int memory, @Nullable RevisionVector lastRevision, boolean fromExternalChange)
protected
DocumentNodeState(@NotNull DocumentNodeStore store, @NotNull Path path, @Nullable RevisionVector lastRevision, @NotNull RevisionVector rootRevision, boolean fromExternalChange, DocumentNodeState.BundlingContext bundlingContext, int memory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull NodeBuilder
builder()
Returns a builder for constructing a new node state based on this state, i.e.boolean
exists()
Checks whether this node exists.@NotNull DocumentNodeState
fromExternalChange()
Iterable<DocumentNodeState>
getAllBundledNodesStates()
Map<String,String>
getAllBundledProperties()
Returns all properties, including bundled, as Json serialized value.Set<String>
getBundledChildNodeNames()
@Nullable DocumentNodeState
getChildIfCached(String name)
/** Returns the child node for the given name from the cache.@NotNull NodeState
getChildNode(@NotNull String name)
Returns the named, possibly non-existent, child node.long
getChildNodeCount(long max)
Returns the number of iterable child nodes of this node.@NotNull Iterable<? extends ChildNodeEntry>
getChildNodeEntries()
Returns the iterable child node entries of this instance.RevisionVector
getLastRevision()
int
getMemory()
The estimated amount of memory used by this object, in bytes.protected NodeStateDiffer
getNodeStateDiffer()
Path
getPath()
@NotNull Iterable<? extends PropertyState>
getProperties()
Returns an iterable of the properties of this node.PropertyState
getProperty(@NotNull String name)
Returns the named property, ornull
if no such property exists.long
getPropertyCount()
Returns the number of properties of this node.@NotNull RevisionVector
getRootRevision()
Returns the root revision for this node state.boolean
hasChildNode(@NotNull String name)
Checks whether the named child node exists.boolean
hasNoChildren()
boolean
hasOnlyBundledChildren()
boolean
hasProperty(@NotNull String name)
Checks whether the named property exists.boolean
isFromExternalChange()
String
toString()
Returns a string representation of this node state.DocumentNodeState
withRootRevision(@NotNull RevisionVector root, boolean externalChange)
Creates a copy of thisDocumentNodeState
with therootRevision
set to the givenroot
revision.-
Methods inherited from class org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState
compareAgainstBaseState, equals
-
Methods inherited from class org.apache.jackrabbit.oak.spi.state.AbstractNodeState
checkValidName, compareAgainstBaseState, comparePropertiesAgainstBaseState, count, equals, getBoolean, getBoolean, getChildNodeNames, getLong, getLong, getName, getName, getNames, getNames, getString, getString, getStrings, getStrings, hashCode, isValidName, toString
-
-
-
-
Field Detail
-
NO_CHILDREN
public static final DocumentNodeState.Children NO_CHILDREN
-
-
Constructor Detail
-
DocumentNodeState
public DocumentNodeState(@NotNull @NotNull DocumentNodeStore store, @NotNull @NotNull Path path, @NotNull @NotNull RevisionVector rootRevision, @NotNull @NotNull Map<String,PropertyState> properties, boolean hasChildren, int memory, @Nullable @Nullable RevisionVector lastRevision, boolean fromExternalChange)
-
DocumentNodeState
protected DocumentNodeState(@NotNull @NotNull DocumentNodeStore store, @NotNull @NotNull Path path, @Nullable @Nullable RevisionVector lastRevision, @NotNull @NotNull RevisionVector rootRevision, boolean fromExternalChange, DocumentNodeState.BundlingContext bundlingContext, int memory)
-
-
Method Detail
-
withRootRevision
public DocumentNodeState withRootRevision(@NotNull @NotNull RevisionVector root, boolean externalChange)
Creates a copy of thisDocumentNodeState
with therootRevision
set to the givenroot
revision. This method returnsthis
instance if the givenroot
revision is the same as the one in this instance and thefromExternalChange
flags are equal.- Specified by:
withRootRevision
in classAbstractDocumentNodeState
- Parameters:
root
- the root revision for the copy of this node state.externalChange
- if thefromExternalChange
flag must be set on the returned node state.- Returns:
- a copy of this node state with the given root revision and external change flag.
-
fromExternalChange
@NotNull public @NotNull DocumentNodeState fromExternalChange()
- Returns:
- a copy of this
DocumentNodeState
with thefromExternalChange
flag set totrue
.
-
isFromExternalChange
public boolean isFromExternalChange()
- Specified by:
isFromExternalChange
in classAbstractDocumentNodeState
- Returns:
true
if this node state was created as a result of an external change;false
otherwise.
-
getRootRevision
@NotNull public @NotNull RevisionVector getRootRevision()
Returns the root revision for this node state. This is the root revision passed from the parent node state. This revision therefore reflects the revision of the root node state where the traversal down the tree started.- Specified by:
getRootRevision
in classAbstractDocumentNodeState
- Returns:
- the revision of the root node state.
-
getPath
public Path getPath()
- Specified by:
getPath
in classAbstractDocumentNodeState
-
getLastRevision
public RevisionVector getLastRevision()
- Specified by:
getLastRevision
in classAbstractDocumentNodeState
-
exists
public boolean exists()
Description copied from interface:NodeState
Checks whether this node exists. See the above discussion about the existence of node states.
-
getProperty
public PropertyState getProperty(@NotNull @NotNull String name)
Description copied from interface:NodeState
Returns the named property, ornull
if no such property exists.- Specified by:
getProperty
in interfaceNodeState
- Overrides:
getProperty
in classAbstractNodeState
- Parameters:
name
- name of the property to return- Returns:
- named property, or
null
if not found
-
hasProperty
public boolean hasProperty(@NotNull @NotNull String name)
Description copied from interface:NodeState
Checks 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:
hasProperty
in interfaceNodeState
- Overrides:
hasProperty
in classAbstractNodeState
- Parameters:
name
- property name- Returns:
true
if the named property exists,false
otherwise
-
getProperties
@NotNull public @NotNull Iterable<? extends PropertyState> getProperties()
Description copied from interface:NodeState
Returns 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.- Specified by:
getProperties
in interfaceNodeState
- Returns:
- properties in some stable order
-
hasChildNode
public boolean hasChildNode(@NotNull @NotNull String name)
Description copied from interface:NodeState
Checks whether the named child node exists. The implementation is equivalent togetChildNode(name).exists()
, except that passing an invalid name as argument will result in afalse
return value instead of anIllegalArgumentException
.- Specified by:
hasChildNode
in interfaceNodeState
- Parameters:
name
- name of the child node- Returns:
true
if the named child node exists,false
otherwise
-
getChildNode
@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull String name)
Description copied from interface:NodeState
Returns the named, possibly non-existent, child node. Use theNodeState.exists()
method on the returned child node to determine whether the node exists or not.- Specified by:
getChildNode
in interfaceNodeState
- Parameters:
name
- name of the child node to return- Returns:
- named child node
-
getChildIfCached
@Nullable public @Nullable DocumentNodeState getChildIfCached(String name)
/** Returns the child node for the given name from the cache. This method returnsnull
if the cache does not have an entry for the child node.Please note, the returned node state may also represent a node that does not exist. In which case
exists()
of the returned node state will returnfalse
.- Parameters:
name
- the name of the child node.- Returns:
- the node state or
null
if the cache does not have an entry for the child node.
-
getChildNodeCount
public long getChildNodeCount(long max)
Description copied from interface:NodeState
Returns 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:
getChildNodeCount
in interfaceNodeState
- Overrides:
getChildNodeCount
in classAbstractNodeState
- Parameters:
max
- the maximum number of entries to traverse- Returns:
- number of iterable child nodes
-
getPropertyCount
public long getPropertyCount()
Description copied from interface:NodeState
Returns the number of properties of this node.- Specified by:
getPropertyCount
in interfaceNodeState
- Overrides:
getPropertyCount
in classAbstractNodeState
- Returns:
- number of properties
-
getChildNodeEntries
@NotNull public @NotNull Iterable<? extends ChildNodeEntry> getChildNodeEntries()
Description copied from interface:NodeState
Returns 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
NodeState
s 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 andNodeState
in one call. This results in O(n) vs. O(n log n) when iterating over the child node names and then look up theNodeState
by name.- Specified by:
getChildNodeEntries
in interfaceNodeState
- Returns:
- child node entries in some stable order
-
builder
@NotNull public @NotNull NodeBuilder builder()
Description copied from interface:NodeState
Returns 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.
-
hasOnlyBundledChildren
public boolean hasOnlyBundledChildren()
-
hasNoChildren
public boolean hasNoChildren()
- Specified by:
hasNoChildren
in classAbstractDocumentNodeState
-
getNodeStateDiffer
protected NodeStateDiffer getNodeStateDiffer()
- Specified by:
getNodeStateDiffer
in classAbstractDocumentNodeState
-
toString
public String toString()
Description copied from class:AbstractNodeState
Returns a string representation of this node state.- Overrides:
toString
in classAbstractNodeState
- Returns:
- string representation
-
getMemory
public int getMemory()
Description copied from interface:CacheValue
The estimated amount of memory used by this object, in bytes.- Specified by:
getMemory
in interfaceCacheValue
- Returns:
- the estimated number of bytes
-
getAllBundledNodesStates
public Iterable<DocumentNodeState> getAllBundledNodesStates()
-
-