KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache;
8
9 import org.jboss.cache.optimistic.DataVersion;
10 import org.jboss.cache.optimistic.DefaultDataVersion;
11
12 import java.util.Map JavaDoc;
13
14 /**
15  * VersionedNode contains a data version.
16  *
17  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
18  */

19 public class VersionedNode extends UnversionedNode
20 {
21
22    private DataVersion version;
23
24    /**
25     * Although this object has a reference to the CacheImpl, the optimistic
26     * node is actually disconnected from the CacheImpl itself.
27     * The parent could be looked up from the TransactionWorkspace.
28     */

29    private NodeSPI parent;
30
31    public VersionedNode(Object JavaDoc childName, Fqn fqn, NodeSPI parent, Map JavaDoc data, boolean mapSafe, CacheSPI cache)
32    {
33       super(childName, fqn, data, mapSafe, cache);
34       if (parent == null && !fqn.isRoot()) throw new NullPointerException JavaDoc("parent");
35       this.parent = parent;
36       this.version = DefaultDataVersion.ZERO;
37    }
38
39    public VersionedNode(Object JavaDoc childName, Fqn fqn, NodeSPI parent, Map JavaDoc data, CacheSPI cache)
40    {
41       this(childName, fqn, parent, data, false, cache);
42    }
43
44    /**
45     * Returns the version id of this node.
46     *
47     * @return the version
48     */

49    public DataVersion getVersion()
50    {
51       return version;
52    }
53
54    /**
55     * Returns the parent.
56     */

57    public NodeSPI getParent()
58    {
59       return parent;
60    }
61
62    /**
63     * Sets the version id of this node.
64     *
65     * @param version
66     */

67    public void setVersion(DataVersion version)
68    {
69       this.version = version;
70    }
71 }
72
Popular Tags