1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.marshalling;
17
18 import java.io.IOException;
19
20 import org.jboss.marshalling.ByteOutput;
21 import org.jboss.netty.buffer.ChannelBuffer;
22 import org.jboss.netty.buffer.ChannelBufferFactory;
23 import org.jboss.netty.buffer.ChannelBuffers;
24
25
26
27
28
29
30 class ChannelBufferByteOutput implements ByteOutput {
31
32 private final ChannelBuffer buffer;
33
34
35
36
37 public ChannelBufferByteOutput(ChannelBuffer buffer) {
38 this.buffer = buffer;
39 }
40
41
42
43
44 public ChannelBufferByteOutput(ChannelBufferFactory factory, int estimatedLength) {
45 this(ChannelBuffers.dynamicBuffer(estimatedLength, factory));
46 }
47
48 public void close() throws IOException {
49
50 }
51
52 public void flush() throws IOException {
53
54 }
55
56 public void write(int b) throws IOException {
57 buffer.writeByte(b);
58 }
59
60 public void write(byte[] bytes) throws IOException {
61 buffer.writeBytes(bytes);
62 }
63
64 public void write(byte[] bytes, int srcIndex, int length) throws IOException {
65 buffer.writeBytes(bytes, srcIndex, length);
66 }
67
68
69
70
71
72 public ChannelBuffer getBuffer() {
73 return buffer;
74 }
75
76 }