V
- the type of the valuespublic class DefaultDocumentTree<V> extends Synchronous<AsyncDocumentTree<V>> implements DocumentTree<V>
AsyncDocumentTree
. All operations are
made by making the equivalent calls to a backing AsyncDocumentTree
then blocking until the operations complete or timeout.DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS
Constructor and Description |
---|
DefaultDocumentTree(AsyncDocumentTree<V> backingTree,
long operationTimeoutMillis) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(DocumentPath path,
DocumentTreeListener<V> listener)
Registers a listener to be notified when a subtree rooted at the specified path
is modified.
|
void |
addListener(DocumentTreeListener<V> listener)
Registers a listener to be notified when the tree is modified.
|
boolean |
create(DocumentPath path,
V value)
Creates a document tree node if one does not exist already.
|
boolean |
createRecursive(DocumentPath path,
V value)
Creates a document tree node by first creating any missing intermediate nodes in the path.
|
Versioned<V> |
get(DocumentPath path)
Returns a document tree node.
|
Map<String,Versioned<V>> |
getChildren(DocumentPath path)
Returns the child values for this node.
|
void |
removeListener(DocumentTreeListener<V> listener)
Unregisters a previously added listener.
|
Versioned<V> |
removeNode(DocumentPath path)
Removes the node with the specified path.
|
boolean |
replace(DocumentPath path,
V newValue,
long version)
Conditionally updates a tree node if the current version matches a specified version.
|
boolean |
replace(DocumentPath path,
V newValue,
V currentValue)
Conditionally updates a tree node if the current value matches a specified value.
|
DocumentPath |
root()
Returns the
path to root of the tree. |
Versioned<V> |
set(DocumentPath path,
V value)
Creates or updates a document tree node.
|
destroy, name, primitiveType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
primitiveType
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
public DefaultDocumentTree(AsyncDocumentTree<V> backingTree, long operationTimeoutMillis)
public DocumentPath root()
DocumentTree
path
to root of the tree.root
in interface DocumentTree<V>
public Map<String,Versioned<V>> getChildren(DocumentPath path)
DocumentTree
getChildren
in interface DocumentTree<V>
path
- path to the nodepublic Versioned<V> get(DocumentPath path)
DocumentTree
get
in interface DocumentTree<V>
path
- path to nodenull
if path does not point to a valid nodepublic Versioned<V> set(DocumentPath path, V value)
DocumentTree
set
in interface DocumentTree<V>
path
- path for the node to create or updatevalue
- the non-null value to be associated with the keynull
if there was no previous mappingpublic boolean create(DocumentPath path, V value)
DocumentTree
create
in interface DocumentTree<V>
path
- path for the node to createvalue
- the non-null value to be associated with the keytrue
if the mapping could be added successfully, false
otherwisepublic boolean createRecursive(DocumentPath path, V value)
DocumentTree
createRecursive
in interface DocumentTree<V>
path
- path for the node to createvalue
- the non-null value to be associated with the keytrue
if the mapping could be added successfully, false
if
a node already exists at that pathpublic boolean replace(DocumentPath path, V newValue, long version)
DocumentTree
replace
in interface DocumentTree<V>
path
- path for the node to createnewValue
- the non-null value to be associated with the keyversion
- current version of the value for update to occurtrue
if the update was made and the tree was modified, false
otherwisepublic boolean replace(DocumentPath path, V newValue, V currentValue)
DocumentTree
replace
in interface DocumentTree<V>
path
- path for the node to createnewValue
- the non-null value to be associated with the keycurrentValue
- current value for update to occurtrue
if the update was made and the tree was modified, false
otherwise.
This method returns false
if the newValue and currentValue are same.public Versioned<V> removeNode(DocumentPath path)
DocumentTree
removeNode
in interface DocumentTree<V>
path
- path for the node to removenull
if it did not existpublic void addListener(DocumentPath path, DocumentTreeListener<V> listener)
DocumentTree
addListener
in interface DocumentTree<V>
path
- path to root of subtree to monitor for updateslistener
- listener to be notifiedpublic void removeListener(DocumentTreeListener<V> listener)
DocumentTree
removeListener
in interface DocumentTree<V>
listener
- listener to unregisterpublic void addListener(DocumentTreeListener<V> listener)
DocumentTree
addListener
in interface DocumentTree<V>
listener
- listener to be notified