KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.IOException JavaDoc;
12 import java.io.ObjectInputStream JavaDoc;
13 import java.io.ObjectOutputStream JavaDoc;
14 import java.io.Serializable JavaDoc;
15
16 import org.jboss.portal.common.util.UUIDGenerator;
17
18 /**
19  * Hold a property within the cache.
20  *
21  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
22  * @version $Revision: 1.1 $
23  */

24 public class Property implements Serializable JavaDoc
25 {
26
27    /** UUID for property changes detection. */
28    private static final UUIDGenerator generator = new UUIDGenerator();
29
30    /** The property name. */
31    private String JavaDoc name;
32
33    /** The current value. */
34    private Object JavaDoc value;
35
36    /** The synthetic id. */
37    private String JavaDoc id;
38
39    public Property(String JavaDoc name, Object JavaDoc value)
40    {
41       if (name == null)
42       {
43          throw new IllegalArgumentException JavaDoc("name cannot be null");
44       }
45       this.name = name;
46       this.value = value;
47       this.id = generator.generateKey();
48    }
49
50    public String JavaDoc getID()
51    {
52       return id;
53    }
54
55    public String JavaDoc getName()
56    {
57       return name;
58    }
59
60    public void setName(String JavaDoc name)
61    {
62       this.name = name;
63    }
64
65    public Object JavaDoc getValue()
66    {
67       return value;
68    }
69
70    private void writeObject(ObjectOutputStream JavaDoc out) throws IOException JavaDoc
71    {
72       out.writeObject(name);
73       out.writeObject(value);
74    }
75
76    private void readObject(ObjectInputStream JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc
77    {
78       name = (String JavaDoc)in.readObject();
79       value = in.readObject();
80    }
81
82    public String JavaDoc toString()
83    {
84       return "Property[" + name + "," + value + "," + id + "]";
85    }
86 }
87
Popular Tags