01: package org.lateralnz.messaging.util;
02:
03: import org.lateralnz.common.model.TimestampedObject;
04:
05: public class PacketDataWrapper extends TimestampedObject {
06:
07: byte[][] data;
08: int count;
09:
10: public PacketDataWrapper(int size) {
11: data = new byte[size][];
12: }
13:
14: public void set(int idx, byte[] b) {
15: data[idx] = b;
16: count++;
17: }
18:
19: public byte[] get() {
20: int total = 0;
21: for (int i = 0; i < data.length; i++) {
22: total += data[i].length;
23: }
24: byte[] rtn = new byte[total];
25: int pos = 0;
26: for (int i = 0; i < data.length; i++) {
27: System.arraycopy(data[i], 0, rtn, pos, data[i].length);
28: pos += data[i].length;
29: }
30: return rtn;
31: }
32: }
|