KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > AbstractNode


1 /**
2  *
3  */

4 package org.jboss.cache;
5
6 import java.util.Map JavaDoc;
7
8 /**
9  * Base class for {@link UnversionedNode}.
10  *
11  * @author manik
12  */

13 public abstract class AbstractNode implements Node
14 {
15    protected boolean deleted;
16    protected Map JavaDoc<Object JavaDoc, Node> children;
17    protected Fqn fqn;
18
19    public boolean isDeleted()
20    {
21       return deleted;
22    }
23
24    public void markAsDeleted(boolean marker)
25    {
26       markAsDeleted(marker, false);
27    }
28
29    public void markAsDeleted(boolean marker, boolean recursive)
30    {
31       deleted = marker;
32       if (recursive && children != null)
33       {
34          synchronized (this)
35          {
36             for (Node child : children.values())
37             {
38                ((AbstractNode) child).markAsDeleted(marker, true);
39             }
40          }
41       }
42    }
43
44    public boolean equals(Object JavaDoc another)
45    {
46       if (another instanceof AbstractNode)
47       {
48          AbstractNode anotherNode = (AbstractNode) another;
49          return fqn == null && anotherNode.fqn == null || !(fqn == null || anotherNode.fqn == null) && fqn.equals(anotherNode.fqn);
50       }
51       return false;
52    }
53
54    public int hashCode()
55    {
56       return fqn.hashCode();
57    }
58 }
59
Popular Tags