KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > impl > tree > NodeStateEvent


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.impl.tree;
10
11 import org.jboss.cache.Fqn;
12
13 /**
14  * The state of a node during a change made to the model. The objects are used only during a modification of the
15  * cache.
16  *
17  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
18  * @version $Revision: 1.1 $
19  */

20 public class NodeStateEvent
21 {
22
23    /** Node has been created. */
24    public static final int STATUS_CREATED = 0;
25
26    /** Node has been modified. */
27    public static final int STATUS_MODIFIED = 1;
28
29    /** Node has been removed. */
30    public static final int STATUS_REMOVED = 2;
31
32    /** Helper for toString(). */
33    private static final String JavaDoc[] toStrings = {"created","modified","removed"};
34
35    /** The fqn of the node. */
36    private final Fqn fqn;
37
38    /** The status of the node at the end of the transaction. */
39    private int status;
40
41    public NodeStateEvent(Fqn fqn, int state)
42    {
43       if (fqn == null)
44       {
45          throw new IllegalArgumentException JavaDoc("No null fqn");
46       }
47       if (state < 0 || state > 2)
48       {
49          throw new IllegalArgumentException JavaDoc("State not accepted");
50       }
51       this.fqn = fqn;
52       this.status = state;
53    }
54
55    public int getStatus()
56    {
57       return status;
58    }
59
60    public void setStatus(int status)
61    {
62       if (status < 0 || status > 2)
63       {
64          throw new IllegalArgumentException JavaDoc("State not accepted");
65       }
66       this.status = status;
67    }
68
69    public Fqn getFqn()
70    {
71       return fqn;
72    }
73
74    public String JavaDoc toString()
75    {
76       return "NodeState[" + fqn + "," + toStrings[status] + "]";
77    }
78 }
79
Popular Tags