1
2
3
4
5
6 package net.kwfgrid.gwes.uiproxy;
7
8 import java.util.*;
9
10
11
12
13
14
15
16
17 public abstract class AbstractBuffer implements Buffer {
18 public static final int DEFAULT_SIZE = 100;
19 public static final String SIZE_PROPERTY_KEY = "Buffer.size";
20
21 protected int _size;
22 protected String _id;
23
24 public AbstractBuffer() {
25 _id = null;
26 _size = DEFAULT_SIZE;
27 }
28
29 protected void setID(String id) {
30 _id = id;
31 }
32
33 public String getID() {
34 return _id;
35 }
36
37
38
39
40 protected void setSize(int size) throws BufferException {
41 _size = size;
42 }
43
44 public int getSize() {
45 return _size;
46 }
47
48
49
50
51
52 public void setProperties(Properties props) throws BufferException {
53 Iterator keys = props.keySet().iterator(); while (keys.hasNext()) {
54 String key = keys.next().toString();
55 setProperty(key, props.getProperty(key));
56 }
57 }
58
59
60
61
62 public void setProperty(String key, String value) throws BufferException {
63 if (SIZE_PROPERTY_KEY.equals(key)) {
64 try {
65 int size = Integer.parseInt(value);
66 setSize(size);
67 } catch (NumberFormatException x) {
68
69
70 }
71 }
72 }
73
74 public abstract void handle(Object message);
75
76 public abstract Object[] read() throws BufferException;
77 }