org.sapia.archie.sync
Class SynchronizedNode

java.lang.Object
  extended by org.sapia.archie.sync.SynchronizedNode
All Implemented Interfaces:
Node

public class SynchronizedNode
extends java.lang.Object
implements Node

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
SynchronizedNode(Node node)
           
 
Method Summary
 Node createChild(NamePart name)
          Creates the node corresponding to the given name and returns it.
 Name getAbsolutePath()
          Returns the full path to this node, starting from the root.
 Node getChild(NamePart name)
          Returns the node with the given name.
 java.util.Iterator getChildren()
          Returns this instance's child nodes.
 int getChildrenCount()
          Returns the number of children that this instance contains.
 java.util.Iterator getChildrenNames()
          Returns the names of this instance's nodes.
 java.util.Iterator getEntries()
           
 NamePart getName()
          Return this instance's name.
 NameParser getNameParser()
          Returns this implementation's name parser.
 Node getParent()
          Returns this instance's parent.
 Synchronizer getSynchronizer()
           
 java.lang.Object getValue(NamePart name)
          Returns this node's value.
 int getValueCount()
          Returns the number of values that this instance contains.
 java.util.Iterator getValueNames()
          Returns the names of this instance's values.
 boolean putValue(NamePart name, java.lang.Object value, boolean overwrite)
          Put a value into this node; overwrites the existing value - if any.
 Node removeChild(NamePart name)
          Removes the node with the given name.
 java.lang.Object removeValue(NamePart name)
          Internally removes the value that this node holds and returns it.
 void setSynchronizer(Synchronizer sync)
           
 void setUp(Node parent, NamePart nodeName)
          Sets this node's name and parent node.
 java.lang.Object synchronizeGet(NamePart valueName)
          This method should be called when needing to synchronize a lookup that occurred at another node.
 void synchronizePut(NamePart valueName, java.lang.Object toSync, boolean overwrite)
          This method should be called when needing to synchronize the content of this node with a "putValue" that occurred at another node.
 void synchronizeRemove(NamePart valueName)
          This method should be called when needing to synchronize the content of this node with a "removeValue" that occurred at another node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedNode

public SynchronizedNode(Node node)
Parameters:
node - the Node that this instance encapsulates.
Method Detail

setSynchronizer

public void setSynchronizer(Synchronizer sync)
Parameters:
sync - a Synchronizer instance.

getSynchronizer

public Synchronizer getSynchronizer()
Returns:
the Synchronizer that this instance uses.

synchronizePut

public void synchronizePut(NamePart valueName,
                           java.lang.Object toSync,
                           boolean overwrite)
This method should be called when needing to synchronize the content of this node with a "putValue" that occurred at another node.

Parameters:
valueName - the NamePart corresponding to the name of the value to synchronize.
toSync - the value to put into this node, under the given name.

synchronizeRemove

public void synchronizeRemove(NamePart valueName)
This method should be called when needing to synchronize the content of this node with a "removeValue" that occurred at another node.

Parameters:
valueName - the NamePart corresponding to the name of the value to remove.

synchronizeGet

public java.lang.Object synchronizeGet(NamePart valueName)
This method should be called when needing to synchronize a lookup that occurred at another node.

Parameters:
valueName - the NamePart corresponding to the name of the value to look up.
Returns:
the Object corresponding to the given name, or null if no object exists for that name.

createChild

public Node createChild(NamePart name)
                 throws DuplicateException,
                        ProcessingException
Description copied from interface: Node
Creates the node corresponding to the given name and returns it.

Specified by:
createChild in interface Node
Parameters:
name - a NamePart
Returns:
a Node.
Throws:
DuplicateException - if a node exists for the given name.
ProcessingException
See Also:
Node.createChild(org.sapia.archie.NamePart)

getAbsolutePath

public Name getAbsolutePath()
Description copied from interface: Node
Returns the full path to this node, starting from the root.

Specified by:
getAbsolutePath in interface Node
Returns:
a Name.
See Also:
Node.getAbsolutePath()

getChild

public Node getChild(NamePart name)
Description copied from interface: Node
Returns the node with the given name.

Specified by:
getChild in interface Node
Parameters:
name - a NamePart corresponding to the name of an existing child node.
Returns:
a Node or null if not child exists for the given name.
See Also:
Node.getChild(org.sapia.archie.NamePart)

getChildren

public java.util.Iterator getChildren()
Description copied from interface: Node
Returns this instance's child nodes.

Specified by:
getChildren in interface Node
Returns:
a Iterator of Nodes.
See Also:
Node.getChildren()

getChildrenCount

public int getChildrenCount()
Description copied from interface: Node
Returns the number of children that this instance contains.

Specified by:
getChildrenCount in interface Node
Returns:
the number of children that this instance contains.
See Also:
Node.getChildrenCount()

getChildrenNames

public java.util.Iterator getChildrenNames()
Description copied from interface: Node
Returns the names of this instance's nodes.

Specified by:
getChildrenNames in interface Node
Returns:
an Iterator of NameParts.
See Also:
Node.getChildrenNames()

getEntries

public java.util.Iterator getEntries()
Specified by:
getEntries in interface Node
Returns:
an Iterator of Entry instances, corresponding to the bindings that this instance holds.
See Also:
Node.getEntries()

getName

public NamePart getName()
Description copied from interface: Node
Return this instance's name.

Specified by:
getName in interface Node
Returns:
a NamePart.
See Also:
Node.getName()

getNameParser

public NameParser getNameParser()
Description copied from interface: Node
Returns this implementation's name parser.

Specified by:
getNameParser in interface Node
Returns:
a NameParser.
See Also:
Node.getNameParser()

getParent

public Node getParent()
Description copied from interface: Node
Returns this instance's parent.

Specified by:
getParent in interface Node
Returns:
a Node.
See Also:
Node.getParent()

getValue

public java.lang.Object getValue(NamePart name)
Description copied from interface: Node
Returns this node's value.

Specified by:
getValue in interface Node
Returns:
an Object, or null if this node has no value.
See Also:
Node.getValue(org.sapia.archie.NamePart)

getValueCount

public int getValueCount()
Description copied from interface: Node
Returns the number of values that this instance contains.

Specified by:
getValueCount in interface Node
Returns:
the number of values that this instance contains.
See Also:
Node.getValueCount()

getValueNames

public java.util.Iterator getValueNames()
Description copied from interface: Node
Returns the names of this instance's values.

Specified by:
getValueNames in interface Node
Returns:
an Iterator of NameParts.
See Also:
Node.getValueNames()

putValue

public boolean putValue(NamePart name,
                        java.lang.Object value,
                        boolean overwrite)
Description copied from interface: Node
Put a value into this node; overwrites the existing value - if any.

Specified by:
putValue in interface Node
Parameters:
name - the name under which to bind the given value.
value - an Object.
overwrite - if true, overwrites the already existing value for the given name - it such is the case.
Returns:
true if the given value was added. Returns false if overwrite is false and a value already exists for the given name.
See Also:
Node.putValue(org.sapia.archie.NamePart, java.lang.Object, boolean)

removeChild

public Node removeChild(NamePart name)
Description copied from interface: Node
Removes the node with the given name.

Specified by:
removeChild in interface Node
Parameters:
name - a NamePart corresponding to the name of an existing child node.
Returns:
a Node or null if not child exists for the given name.
See Also:
Node.removeChild(org.sapia.archie.NamePart)

removeValue

public java.lang.Object removeValue(NamePart name)
Description copied from interface: Node
Internally removes the value that this node holds and returns it.

Specified by:
removeValue in interface Node
Returns:
an Object, or null if this node has no value.
See Also:
Node.removeValue(org.sapia.archie.NamePart)

setUp

public void setUp(Node parent,
                  NamePart nodeName)
Description copied from interface: Node
Sets this node's name and parent node. Client applications must not use this method - unless they know what they are doing.

Specified by:
setUp in interface Node
Parameters:
parent - this instance's parent Node
nodeName - a NamePart.
See Also:
Node.setUp(org.sapia.archie.Node, org.sapia.archie.NamePart)


Copyright © 2010 Sapia OSS. All Rights Reserved.