01: package org.jgroups.util;
02:
03: import java.io.ByteArrayInputStream;
04:
05: /**
06: * @author Bela Ban
07: * @version $Id: ExposedByteArrayInputStream.java,v 1.1 2005/07/25 15:53:36 belaban Exp $
08: */
09: public class ExposedByteArrayInputStream extends ByteArrayInputStream {
10:
11: /**
12: * Creates a <code>ByteArrayInputStream</code>
13: * so that it uses <code>buf</code> as its
14: * buffer array.
15: * The buffer array is not copied.
16: * The initial value of <code>pos</code>
17: * is <code>0</code> and the initial value
18: * of <code>count</code> is the length of
19: * <code>buf</code>.
20: *
21: * @param buf the input buffer.
22: */
23: public ExposedByteArrayInputStream(byte[] buf) {
24: super (buf);
25: }
26:
27: /**
28: * Creates <code>ByteArrayInputStream</code>
29: * that uses <code>buf</code> as its
30: * buffer array. The initial value of <code>pos</code>
31: * is <code>offset</code> and the initial value
32: * of <code>count</code> is the minimum of <code>offset+length</code>
33: * and <code>buf.length</code>.
34: * The buffer array is not copied. The buffer's mark is
35: * set to the specified offset.
36: *
37: * @param buf the input buffer.
38: * @param offset the offset in the buffer of the first byte to read.
39: * @param length the maximum number of bytes to read from the buffer.
40: */
41: public ExposedByteArrayInputStream(byte[] buf, int offset,
42: int length) {
43: super (buf, offset, length);
44: }
45:
46: public void setData(byte[] buf, int offset, int length) {
47: this.buf = buf;
48: this.pos = offset;
49: this.count = Math.min(offset + length, buf.length);
50: this.mark = offset;
51: }
52:
53: }
|