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.TypeDEFAULT_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, primitiveTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprimitiveTypeaddStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListenerspublic DefaultDocumentTree(AsyncDocumentTree<V> backingTree, long operationTimeoutMillis)
public DocumentPath root()
DocumentTreepath to root of the tree.root in interface DocumentTree<V>public Map<String,Versioned<V>> getChildren(DocumentPath path)
DocumentTreegetChildren in interface DocumentTree<V>path - path to the nodepublic Versioned<V> get(DocumentPath path)
DocumentTreeget in interface DocumentTree<V>path - path to nodenull if path does not point to a valid nodepublic Versioned<V> set(DocumentPath path, V value)
DocumentTreeset 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)
DocumentTreecreate 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)
DocumentTreecreateRecursive 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)
DocumentTreereplace 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)
DocumentTreereplace 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)
DocumentTreeremoveNode in interface DocumentTree<V>path - path for the node to removenull if it did not existpublic void addListener(DocumentPath path, DocumentTreeListener<V> listener)
DocumentTreeaddListener in interface DocumentTree<V>path - path to root of subtree to monitor for updateslistener - listener to be notifiedpublic void removeListener(DocumentTreeListener<V> listener)
DocumentTreeremoveListener in interface DocumentTree<V>listener - listener to unregisterpublic void addListener(DocumentTreeListener<V> listener)
DocumentTreeaddListener in interface DocumentTree<V>listener - listener to be notified