XCMS Toolkit

schemajic.codec
Class ByteCountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.BufferedInputStream
              extended by schemajic.codec.ByteCountingInputStream
All Implemented Interfaces:
java.io.Closeable

public class ByteCountingInputStream
extends java.io.BufferedInputStream

Tracks the number of bytes read from an underlying input stream.

Version:
1.00 - 2006/01/22
Author:
support@phillipgriffin.com

Field Summary
 
Fields inherited from class java.io.BufferedInputStream
buf, count, marklimit, markpos, pos
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ByteCountingInputStream(java.io.InputStream in)
          Constructor for ByteCountingInputStream with an input stream initialization value parameter.
ByteCountingInputStream(java.io.InputStream in, int size)
          Constructor for ByteCountingInputStream with input stream and a stream size initialization value parameters.
 
Method Summary
 byte[] getAccumulatedBytes()
          Gets accumulated bytes read.
 int getBytesRead()
          Gets the runing total of all bytes read.
 void mark(int readLimit)
          Sets the current read mark to boolean true, updates the old bytes read counter, and sets the provided read mark limit.
 int read()
          Reads a byte, counts it as read, and returns the byte to the caller.
 int read(byte[] b)
          Reads a byte, counts it as read, conditionally writes the byte to an encoding, and returns the count of the bytes ptocessed to the caller.
 void reset()
          Resets the byte counting operation.
 void startAccumulatingBytes()
          Starts a counter to accumulate bytes read.
 void stopAccumulatingBytes()
          Stops accumulating bytes.
 
Methods inherited from class java.io.BufferedInputStream
available, close, markSupported, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteCountingInputStream

public ByteCountingInputStream(java.io.InputStream in)
Constructor for ByteCountingInputStream with an input stream initialization value parameter.

Parameters:
in - an input stream

ByteCountingInputStream

public ByteCountingInputStream(java.io.InputStream in,
                               int size)
Constructor for ByteCountingInputStream with input stream and a stream size initialization value parameters.

Parameters:
in - an input stream
size - input stream size
Method Detail

read

public int read()
         throws java.io.IOException
Reads a byte, counts it as read, and returns the byte to the caller.

Overrides:
read in class java.io.BufferedInputStream
Returns:
a byte to add to an encoding
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Reads a byte, counts it as read, conditionally writes the byte to an encoding, and returns the count of the bytes ptocessed to the caller.

Overrides:
read in class java.io.FilterInputStream
Parameters:
b - one byte
Returns:
the number of bytes read
Throws:
java.io.IOException

getBytesRead

public int getBytesRead()
Gets the runing total of all bytes read.

Returns:
the total of all bytes read

mark

public void mark(int readLimit)
Sets the current read mark to boolean true, updates the old bytes read counter, and sets the provided read mark limit.

Overrides:
mark in class java.io.BufferedInputStream

reset

public void reset()
           throws java.io.IOException
Resets the byte counting operation.

Overrides:
reset in class java.io.BufferedInputStream
Throws:
java.io.IOException

startAccumulatingBytes

public void startAccumulatingBytes()
Starts a counter to accumulate bytes read.


getAccumulatedBytes

public byte[] getAccumulatedBytes()
                           throws java.io.IOException
Gets accumulated bytes read.

Returns:
the current encoding value
Throws:
java.io.IOException

stopAccumulatingBytes

public void stopAccumulatingBytes()
                           throws java.io.IOException
Stops accumulating bytes.

Throws:
java.io.IOException

XCMS Toolkit


Copyright © 2005-2006 GRIFFIN Consulting. All Rights Reserved.