1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.sail.core.entity;
24
25 import java.beans.beancontext.BeanContext;
26 import java.beans.beancontext.BeanContextChildSupport;
27
28 import net.sf.sail.core.beans.Pod;
29 import net.sf.sail.core.uuid.PodUuid;
30
31
32 /***
33 * Identifies the shape and context of the data to be written by the <b>IAgent</b>
34 * into the ISock.
35 *
36 * @author turadg
37 */
38 public class Rim extends BeanContextChildSupport {
39
40 /***
41 *
42 */
43 private static final long serialVersionUID = 4637021392257551556L;
44
45 transient static int rimCount = 0;
46
47 transient int rimSerial = ++rimCount;
48
49 String name = "undefined" + rimSerial;
50
51 Class shape = Object.class;
52
53 /***
54 * Construct new Rim with a default shape and name. The default shape is
55 * Object.class. The default name is a serialial counter appended to
56 * "undefined", e.g. "undefined0".
57 */
58 public Rim() {
59
60 }
61
62 public Class getShape() {
63 return shape;
64 }
65
66 public void setShape(Class shape) {
67 if (shape == null)
68 throw new IllegalArgumentException("null shape set on rim");
69 this.shape = shape;
70 }
71
72 public String getName() {
73 return name;
74 }
75
76 public void setName(String name) {
77 if (name == null)
78 throw new IllegalArgumentException("null name set on rim");
79 this.name = name;
80 }
81
82 public PodUuid getContainingPodId() {
83 BeanContext bc = getBeanContext();
84 if (bc == null) throw new NullPointerException("Rim without a BeanContext");
85 if (!(bc instanceof Pod))
86 throw new RuntimeException("Rim's BeanContext not a Pod");
87 Pod pod = (Pod) bc;
88 PodUuid podId = pod.getPodId();
89 if (podId == null) throw new NullPointerException("pod has no id: "+pod);
90 return podId;
91 }
92
93 @Override
94 public String toString() {
95 return "Rim@" + rimSerial + "[" + name + ":" + shape + "]";
96 }
97 }