JMRTD 0.4.5

net.sourceforge.scuba.tlv
Class BERTLVInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by net.sourceforge.scuba.tlv.BERTLVInputStream
All Implemented Interfaces:
Closeable

public class BERTLVInputStream
extends InputStream

TLV input stream.

Author:
Martijn Oostdijk (martijn.oostdijk@gmail.com)

Constructor Summary
BERTLVInputStream(InputStream in)
          Constructs a new TLV stream based on another stream.
 
Method Summary
 int available()
          Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
 void close()
          Closes this input stream.
 void mark(int readLimit)
          Marks the underlying input stream if supported.
 boolean markSupported()
          Whether marking and resetting are supported.
 int read()
          Reads the next byte of data from the input stream.
 int readLength()
          Reads a length.
 int readTag()
          Reads a tag.
 byte[] readValue()
          Reads a value.
 void reset()
          Resets the underlying input stream if supported.
 long skip(long n)
          Attempts to skip over n bytes.
 void skipToTag(int searchTag)
          Skips in this stream until a given tag is found (depth first).
 String toString()
           
 
Methods inherited from class java.io.InputStream
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BERTLVInputStream

public BERTLVInputStream(InputStream in)
Constructs a new TLV stream based on another stream.

Parameters:
in - a TLV object
Method Detail

readTag

public int readTag()
            throws IOException
Reads a tag.

Returns:
the tag just read
Throws:
IOException - if reading goes wrong

readLength

public int readLength()
               throws IOException
Reads a length.

Returns:
the length just read
Throws:
IOException - if reading goes wrong

readValue

public byte[] readValue()
                 throws IOException
Reads a value.

Returns:
the value just read
Throws:
IOException - if reading goes wrong

skipToTag

public void skipToTag(int searchTag)
               throws IOException
Skips in this stream until a given tag is found (depth first). The stream is positioned right after the first occurrence of the tag.

Parameters:
searchTag - the tag to search for
Throws:
IOException

available

public int available()
              throws IOException
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.

Overrides:
available in class InputStream
Returns:
a number of bytes
Throws:
IOException - if something goes wrong

read

public int read()
         throws IOException
Reads the next byte of data from the input stream.

Specified by:
read in class InputStream
Returns:
a byte
Throws:
IOException - if reading goes wrong

skip

public long skip(long n)
          throws IOException
Attempts to skip over n bytes.

Overrides:
skip in class InputStream
Returns:
the actual number of bytes skipped
Throws:
IOException - if something goes wrong

mark

public void mark(int readLimit)
Marks the underlying input stream if supported.

Overrides:
mark in class InputStream
Parameters:
readLimit - limit for marking

markSupported

public boolean markSupported()
Whether marking and resetting are supported. We support this whenever the underlying input stream supports it.

Overrides:
markSupported in class InputStream
Returns:
whether mark and reset are supported

reset

public void reset()
           throws IOException
Resets the underlying input stream if supported.

Overrides:
reset in class InputStream
Throws:
IOException - if something goes wrong

close

public void close()
           throws IOException
Closes this input stream.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException - if something goes wrong

toString

public String toString()
Overrides:
toString in class Object

JMRTD 0.4.5