public class DocumentNodeState extends AbstractDocumentNodeState implements CacheValue
NodeState
implementation for the DocumentNodeStore
.Modifier and Type | Class and Description |
---|---|
protected static class |
DocumentNodeState.BundlingContext |
static class |
DocumentNodeState.Children
A list of children for a node.
|
Modifier and Type | Field and Description |
---|---|
static DocumentNodeState.Children |
NO_CHILDREN |
Modifier | Constructor and Description |
---|---|
|
DocumentNodeState(@NotNull DocumentNodeStore store,
@NotNull Path path,
@NotNull RevisionVector rootRevision,
@NotNull java.util.Map<java.lang.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) |
Modifier and Type | Method and 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() |
java.lang.Iterable<DocumentNodeState> |
getAllBundledNodesStates() |
java.util.Map<java.lang.String,java.lang.String> |
getAllBundledProperties()
Returns all properties, including bundled, as Json serialized value.
|
java.util.Set<java.lang.String> |
getBundledChildNodeNames() |
@NotNull NodeState |
getChildNode(@NotNull java.lang.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 java.lang.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 java.lang.Iterable<? extends PropertyState> |
getProperties()
Returns an iterable of the properties of this node.
|
PropertyState |
getProperty(@NotNull java.lang.String name)
Returns the named property, or
null 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 java.lang.String name)
Checks whether the named child node exists.
|
boolean |
hasNoChildren() |
boolean |
hasOnlyBundledChildren() |
boolean |
hasProperty(@NotNull java.lang.String name)
Checks whether the named property exists.
|
boolean |
isFromExternalChange() |
java.lang.String |
toString()
Returns a string representation of this node state.
|
DocumentNodeState |
withRootRevision(@NotNull RevisionVector root,
boolean externalChange)
|
compareAgainstBaseState, equals
checkValidName, compareAgainstBaseState, comparePropertiesAgainstBaseState, count, equals, getBoolean, getBoolean, getChildNodeNames, getLong, getLong, getName, getName, getNames, getNames, getString, getString, getStrings, getStrings, hashCode, isValidName, toString
public static final DocumentNodeState.Children NO_CHILDREN
public DocumentNodeState(@NotNull @NotNull DocumentNodeStore store, @NotNull @NotNull Path path, @NotNull @NotNull RevisionVector rootRevision, @NotNull @NotNull java.util.Map<java.lang.String,PropertyState> properties, boolean hasChildren, int memory, @Nullable @Nullable RevisionVector lastRevision, boolean fromExternalChange)
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)
public DocumentNodeState withRootRevision(@NotNull @NotNull RevisionVector root, boolean externalChange)
DocumentNodeState
with the
rootRevision
set to the given root
revision. This method
returns this
instance if the given root
revision is
the same as the one in this instance and the fromExternalChange
flags are equal.withRootRevision
in class AbstractDocumentNodeState
root
- the root revision for the copy of this node state.externalChange
- if the fromExternalChange
flag must be
set on the returned node state.@NotNull public @NotNull DocumentNodeState fromExternalChange()
DocumentNodeState
with the
fromExternalChange
flag set to true
.public boolean isFromExternalChange()
isFromExternalChange
in class AbstractDocumentNodeState
true
if this node state was created as a result of an
external change; false
otherwise.@NotNull public @NotNull RevisionVector getRootRevision()
getRootRevision
in class AbstractDocumentNodeState
public Path getPath()
getPath
in class AbstractDocumentNodeState
public RevisionVector getLastRevision()
getLastRevision
in class AbstractDocumentNodeState
public boolean exists()
NodeState
public PropertyState getProperty(@NotNull @NotNull java.lang.String name)
NodeState
null
if no such property exists.getProperty
in interface NodeState
getProperty
in class AbstractNodeState
name
- name of the property to returnnull
if not foundpublic boolean hasProperty(@NotNull @NotNull java.lang.String name)
NodeState
getProperty(name) != null
, but may be optimized
to avoid having to load the property value.hasProperty
in interface NodeState
hasProperty
in class AbstractNodeState
name
- property nametrue
if the named property exists,
false
otherwise@NotNull public @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
NodeState
getProperties
in interface NodeState
public boolean hasChildNode(@NotNull @NotNull java.lang.String name)
NodeState
getChildNode(name).exists()
, except that
passing an invalid name as argument will result in a false
return value instead of an IllegalArgumentException
.hasChildNode
in interface NodeState
name
- name of the child nodetrue
if the named child node exists,
false
otherwise@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull java.lang.String name)
NodeState
NodeState.exists()
method on the returned child node to determine
whether the node exists or not.getChildNode
in interface NodeState
name
- name of the child node to returnpublic long getChildNodeCount(long max)
NodeState
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).
getChildNodeCount
in interface NodeState
getChildNodeCount
in class AbstractNodeState
max
- the maximum number of entries to traversepublic long getPropertyCount()
NodeState
getPropertyCount
in interface NodeState
getPropertyCount
in class AbstractNodeState
@NotNull public @NotNull java.lang.Iterable<? extends ChildNodeEntry> getChildNodeEntries()
NodeState
Note on cost and performance: while it is possible to iterate over
all child NodeState
s with the two methods NodeState.getChildNodeNames()
and NodeState.getChildNode(String)
, this method is
considered more efficient because an implementation can potentially
perform the retrieval of the name and NodeState
in one call.
This results in O(n) vs. O(n log n) when iterating over the child node
names and then look up the NodeState
by name.
getChildNodeEntries
in interface NodeState
@NotNull public @NotNull NodeBuilder builder()
NodeState
public java.util.Set<java.lang.String> getBundledChildNodeNames()
public boolean hasOnlyBundledChildren()
public boolean hasNoChildren()
hasNoChildren
in class AbstractDocumentNodeState
protected NodeStateDiffer getNodeStateDiffer()
getNodeStateDiffer
in class AbstractDocumentNodeState
public java.lang.String toString()
AbstractNodeState
toString
in class AbstractNodeState
public int getMemory()
CacheValue
getMemory
in interface CacheValue
public java.lang.Iterable<DocumentNodeState> getAllBundledNodesStates()
public java.util.Map<java.lang.String,java.lang.String> getAllBundledProperties()
Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.