iaik.utils
Class TracedInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--iaik.utils.TracedInputStream

public class TracedInputStream
extends FilterInputStream

A TracedInputStream traces all the data which is read from an InputStream.

Method getTracedData() returns an array, which contains the data read from an InputStream. A TracedInputStream is useful when a decoder reads from an InputStream and the encoded data is also needed.

For example:

 // the InputStream containing a DER encoded ASN.1 object:
 InputStream is;
 TracedInputStream tis = new TracedInputStream(is);
 // read and decode the next encoded ASN.1 object from is:
 ASN1Object asn1_obj = DerCoder.decode(tis);
 // get the encoded bytes which have been read from is:
 byte[] raw = tis.getTracedData();
 ...
 

Version:
File Revision 15

Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
TracedInputStream(InputStream is)
          Constructs a TracedInputStream from the InputStream which should be traced.
TracedInputStream(InputStream is, int initialSize)
          Constructs a TracedInputStream from the InputStream which should be traced.
 
Method Summary
 byte[] getTracedData()
          Returns the data which have been read from the InputStream.
 int read()
          Reads the next byte from this stream and returns it as int value between 0 and 255.
 int read(byte[] b, int off, int len)
          Reads up to len bytes from this stream into the given byte array.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TracedInputStream

public TracedInputStream(InputStream is)
Constructs a TracedInputStream from the InputStream which should be traced.
Parameters:
is - - the input stream.

TracedInputStream

public TracedInputStream(InputStream is,
                         int initialSize)
Constructs a TracedInputStream from the InputStream which should be traced.
Parameters:
is - - the input stream.
Method Detail

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Reads up to len bytes from this stream into the given byte array.

Overrides:
read in class FilterInputStream
Parameters:
b - the byte array to which to read the data
off - the offset indicating the start position within the destination byte array, to which the data is written
len - the maximum number of bytes to be read
Returns:
the number of bytes actually read from this stream, or -1 if the end of the stream already has been reached
Throws:
IOException - if an I/O error occurs

read

public int read()
         throws IOException
Reads the next byte from this stream and returns it as int value between 0 and 255.
Overrides:
read in class FilterInputStream
Returns:
the next byte as int value between 0 and 255, or -1 if the end of the stream already has been reached
Throws:
IOException - if an I/O error occurs

getTracedData

public byte[] getTracedData()
Returns the data which have been read from the InputStream.
Returns:
the data which have been read from the InputStream.

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK