1 |
| package org.jboss.cache.marshall; |
2 |
| |
3 |
| import org.jboss.cache.Fqn; |
4 |
| |
5 |
| import java.io.Externalizable; |
6 |
| import java.io.IOException; |
7 |
| import java.io.ObjectInput; |
8 |
| import java.io.ObjectOutput; |
9 |
| import java.util.Map; |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| public class NodeData implements Externalizable |
18 |
| { |
19 |
| private Fqn fqn = null; |
20 |
| private Map<Object, Object> attrs = null; |
21 |
| |
22 |
| static final long serialVersionUID = -7571995794010294485L; |
23 |
| |
24 |
13044
| public NodeData()
|
25 |
| { |
26 |
| } |
27 |
| |
28 |
946
| public NodeData(Fqn fqn)
|
29 |
| { |
30 |
946
| this.fqn = fqn;
|
31 |
| } |
32 |
| |
33 |
10526
| public NodeData(Fqn fqn, Map attrs)
|
34 |
| { |
35 |
10526
| this.fqn = fqn;
|
36 |
10526
| this.attrs = attrs;
|
37 |
| } |
38 |
| |
39 |
0
| public NodeData(String fqn, Map attrs)
|
40 |
| { |
41 |
0
| this.fqn = Fqn.fromString(fqn);
|
42 |
0
| this.attrs = attrs;
|
43 |
| } |
44 |
| |
45 |
11555
| public Map getAttributes()
|
46 |
| { |
47 |
11555
| return attrs;
|
48 |
| } |
49 |
| |
50 |
21631
| public Fqn getFqn()
|
51 |
| { |
52 |
21631
| return fqn;
|
53 |
| } |
54 |
| |
55 |
21592
| public boolean isMarker()
|
56 |
| { |
57 |
21592
| return false;
|
58 |
| } |
59 |
| |
60 |
240
| public boolean isExceptionMarker()
|
61 |
| { |
62 |
240
| return false;
|
63 |
| } |
64 |
| |
65 |
13641
| public void writeExternal(ObjectOutput out) throws IOException
|
66 |
| { |
67 |
13641
| out.writeObject(fqn);
|
68 |
13641
| if (attrs != null)
|
69 |
| { |
70 |
10498
| out.writeBoolean(true);
|
71 |
10498
| out.writeObject(attrs);
|
72 |
| } |
73 |
| else |
74 |
| { |
75 |
3143
| out.writeBoolean(false);
|
76 |
| } |
77 |
| } |
78 |
| |
79 |
12919
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
|
80 |
| { |
81 |
12919
| fqn = (Fqn) in.readObject();
|
82 |
12919
| if (in.readBoolean())
|
83 |
| { |
84 |
10498
| attrs = (Map) in.readObject();
|
85 |
| } |
86 |
| } |
87 |
| |
88 |
0
| public String toString()
|
89 |
| { |
90 |
0
| return "NodeData {fqn: " + fqn + ", attrs=" + attrs + "}";
|
91 |
| } |
92 |
| |
93 |
| |
94 |
8
| public boolean equals(Object o)
|
95 |
| { |
96 |
0
| if (this == o) return true;
|
97 |
0
| if (o == null || getClass() != o.getClass()) return false;
|
98 |
| |
99 |
8
| NodeData nodeData = (NodeData) o;
|
100 |
| |
101 |
0
| if (attrs != null ? !attrs.equals(nodeData.attrs) : nodeData.attrs != null) return false;
|
102 |
0
| if (fqn != null ? !fqn.equals(nodeData.fqn) : nodeData.fqn != null) return false;
|
103 |
| |
104 |
8
| return true;
|
105 |
| } |
106 |
| |
107 |
25103
| public int hashCode()
|
108 |
| { |
109 |
25103
| int result;
|
110 |
25103
| result = (fqn != null ? fqn.hashCode() : 0);
|
111 |
25103
| result = 31 * result + (attrs != null ? attrs.hashCode() : 0);
|
112 |
25103
| return result;
|
113 |
| } |
114 |
| } |