KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > loader > NodeData


1 package org.jboss.cache.loader;
2
3 import org.jboss.cache.Fqn;
4
5 import java.io.Externalizable JavaDoc;
6 import java.io.IOException JavaDoc;
7 import java.io.ObjectInput JavaDoc;
8 import java.io.ObjectOutput JavaDoc;
9 import java.util.Map JavaDoc;
10
11 /**
12  * Serializable representation of the data of a node (FQN and attributes)
13  * @author Bela Ban
14  * @version $Id: NodeData.java,v 1.4 2006/09/13 15:42:16 vblagojevic Exp $
15  */

16 public class NodeData implements Externalizable JavaDoc {
17    Fqn fqn=null;
18    Map JavaDoc attrs=null;
19
20    static final long serialVersionUID = -7571995794010294485L;
21
22    public NodeData() {
23    }
24
25    public NodeData(Fqn fqn) {
26       this.fqn=fqn;
27    }
28
29    public NodeData(Fqn fqn, Map JavaDoc attrs) {
30       this.fqn=fqn;
31       this.attrs=attrs;
32    }
33
34    public NodeData(String JavaDoc fqn, Map JavaDoc attrs) {
35          this.fqn=Fqn.fromString(fqn);
36          this.attrs=attrs;
37       }
38    
39    public Map JavaDoc getAttributes() {
40       return attrs;
41    }
42    
43    public Fqn getFqn() {
44       return fqn;
45    }
46    
47    public boolean isMarker()
48    {
49       return false;
50    }
51    
52    public boolean isExceptionMarker()
53    {
54       return false;
55    }
56
57    public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
58       out.writeObject(fqn);
59       if(attrs != null) {
60          out.writeBoolean(true);
61          out.writeObject(attrs);
62       }
63       else {
64          out.writeBoolean(false);
65       }
66    }
67
68    public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
69       fqn=(Fqn)in.readObject();
70       if(in.readBoolean())
71          attrs=(Map JavaDoc)in.readObject();
72    }
73
74    public String JavaDoc toString() {
75       return "fqn: " + fqn + ", attrs=" + attrs;
76    }
77
78 }
79
Popular Tags