wt.wrmf.transport
Class ChunkInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bywt.wrmf.transport.ChunkInputStream
All Implemented Interfaces:
Serializable

public class ChunkInputStream
extends InputStream
implements Serializable

ChunkInputStream accepts a "large" input stream and devides it into chunks of input stream with chunk size specified in the constructor. The previous chunk will be kept in a temporary memory, it can be recovered by calling rollback() or deleted by calling commit ().

Supported API: false

Extendable: false

See Also:
Serialized Form

Field Summary
private  int chunkLength
           
private static String CLASSNAME
           
private  long committedChunkCount
           
private  byte[] data
           
private  InputStream is
           
private  int position
           
private static String RESOURCE
           
private static String versionID
           
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
ChunkInputStream(InputStream is)
          

Supported API: false
ChunkInputStream(InputStream is, int chunkSize)
          

Supported API: false
 
Method Summary
 long getCommittedChunks()
          Get the number of chunks committed by now.
 InputStream getNextChunk()
          Get the next chunk of inputstream with length equals the chunk size, unless it has no more bytes.
 int read()
          

Supported API: false
 void rollback()
          If called, the current chunk (inputstream) will be "rollback" as if it has never been read.
 long skip(long n)
          Skip exactly n bytes.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

is

private InputStream is

chunkLength

private int chunkLength

versionID

private static final String versionID
See Also:
Constant Field Values

data

private byte[] data

committedChunkCount

private long committedChunkCount

position

private int position
Constructor Detail

ChunkInputStream

public ChunkInputStream(InputStream is,
                        int chunkSize)


Supported API: false

Parameters:
is -
chunkSize -

ChunkInputStream

public ChunkInputStream(InputStream is)


Supported API: false

Parameters:
is -
Method Detail

read

public int read()
         throws IOException


Supported API: false

Returns:
int
Throws:
IOException

rollback

public void rollback()
              throws IOException
If called, the current chunk (inputstream) will be "rollback" as if it has never been read. The immediate call getNextChunk() will return this chunk of input stream.

Supported API: false

Throws:
IOException

getNextChunk

public InputStream getNextChunk()
                         throws IOException
Get the next chunk of inputstream with length equals the chunk size, unless it has no more bytes.

Supported API: false

Returns:
InputStream
Throws:
IOException

getCommittedChunks

public long getCommittedChunks()
Get the number of chunks committed by now.

Supported API: false

Returns:
long

skip

public long skip(long n)
          throws IOException
Skip exactly n bytes. This may overwrite the skip() method implemented for the input stream as in the constructor.

Supported API: false

Parameters:
n -
Returns:
long
Throws:
IOException