01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.io;
05:
06: import com.tc.bytes.TCByteBuffer;
07:
08: import java.io.IOException;
09:
10: public interface TCByteBufferInput extends TCDataInput {
11:
12: /**
13: * Duplicate this stream. The resulting stream will share data with the source stream (ie. no copying), but the two
14: * streams will have independent read positions. The read position of the result stream will initially be the same as
15: * the source stream
16: */
17: public TCByteBufferInput duplicate();
18:
19: /**
20: * Effectively the same thing as calling duplicate().limit(int), but potentially creating far less garbage (depending
21: * on the size difference between the original stream and the slice you want)
22: */
23: public TCByteBufferInput duplicateAndLimit(final int limit);
24:
25: public TCByteBuffer[] toArray();
26:
27: /**
28: * Artificially limit the length of this input stream starting at the current read position. This operation is
29: * destructive to the stream contents (ie. data trimmed off by setting limit can never be read with this stream).
30: */
31: public TCDataInput limit(int limit);
32:
33: public int getTotalLength();
34:
35: public int available();
36:
37: public void close();
38:
39: public void mark(int readlimit);
40:
41: // XXX: This is a TC special version of mark() to be used in conjunction with tcReset()...We should eventually
42: // implement the general purpose mark(int) method as specified by InputStream. NOTE: It has some unusual semantics
43: // that make it a little trickier to implement (in our case) than you might think (specifially the readLimit field)
44: public void mark();
45:
46: public boolean markSupported();
47:
48: public int read(byte[] b);
49:
50: public int read();
51:
52: public void reset();
53:
54: /**
55: * Reset this input stream to the position recorded by the last call to mark(). This method discards the previous
56: * value of the mark
57: *
58: * @throws IOException if mark() has never been called on this stream
59: */
60: public void tcReset();
61:
62: public long skip(long skip);
63:
64: }
|