01: package vicazh.hyperpool;
02:
03: import javax.xml.transform.*;
04:
05: /**
06: * The communicator
07: *
08: * @author Victor Zhigunov
09: * @version 0.4.0
10: */
11: public class Com extends Element implements ComMBean {
12:
13: private Editor editor;
14:
15: private MWriter writer;
16:
17: /**
18: * @param editor
19: * editor
20: * @param writer
21: * writer
22: */
23: public Com(Editor editor, MWriter writer) {
24: this .editor = editor;
25: this .writer = writer;
26: }
27:
28: public void setAttribute(String name, Object value)
29: throws Exception {
30: if (name.equals(ElementMBean.INIT))
31: super .setAttribute(name, writer.get());
32: else if (name.equals(ComMBean.CHANGED)) {
33: editor.changed((ComData) value);
34: super .setAttribute(name, value);
35: } else if (name.equals(ComMBean.REMOVE)) {
36: editor.remove((Integer) value);
37: super .setAttribute(name, value);
38: } else if (name.equals(ComMBean.UP)) {
39: editor.up((Integer) value);
40: super .setAttribute(name, value);
41: } else if (name.equals(ComMBean.DOWN)) {
42: editor.down((Integer) value);
43: super .setAttribute(name, value);
44: } else {
45: editor.set((ComData) value);
46: if (name.equals(ComMBean.READ))
47: ((ComData) value).b = get();
48: super .setAttribute(name, value);
49: }
50: }
51:
52: public byte[] get() throws TransformerException {
53: Object o = writer.getObject();
54: return o == null ? null : writer.get(o);
55: }
56:
57: public int getID() {
58: return 0;
59: }
60: }
|