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 class DefaultBuffer extends AbstractBuffer {
18 protected List _content;
19 protected boolean _overflow;
20
21 public DefaultBuffer() {
22 super();
23 _content = new ArrayList(getSize());
24 _overflow = false;
25 }
26
27 public synchronized void handle(Object message) {
28 if (shouldHandle(message)) {
29 if (_content.size()>=getSize()) _overflow = true;
30 else _content.add(message);
31 }
32 }
33
34 public synchronized Object[] read() throws BufferException {
35 if (_overflow) throw new BufferOverflowException(this);
36 Object[] messages = _content.toArray();
37 _content.clear();
38 return messages;
39 }
40
41
42
43
44
45
46 protected boolean shouldHandle(Object message) {
47 return true;
48 }
49 }