ch.panter.li.bi.asn.ber
Class AsnBerInputStream

java.lang.Object
  extended by ch.panter.li.bi.asn.ber.AsnBerInputStream

public class AsnBerInputStream
extends Object

An InputStream that provides special utility functionality to decode an ASN.1 BER-encoded message.


Constructor Summary
AsnBerInputStream(InputStream input)
          Creates a new instance which will read from the given input stream.
 
Method Summary
 void close()
          Irrevocably closes this instance.
 long getCurrentPosition()
          Gets the current position in the stream.
 int getMaximumPrimitiveValueSize()
           
 boolean hasMoreDataAvailable()
          Determines whether more data is available to be read from this instance.
 boolean isClosed()
          Determines whether this instance has been closed.
 boolean isDecodeToFloatIfPossible()
           
 void mark(int readLimit)
           
 AsnTag readNextTag()
           
 AsnBerTagLength readTagLength()
           
 void readTagValue(byte[] tagValue)
          Read the tag value data from the underlying stream.
 void readTagValue(byte[] tagValue, int offset, int length)
          Read the tag value data from the underlying stream.
 void readValue(AsnSimpleValueBase value, long valueLength)
           
 void reset()
           
 void setDecodeToFloatIfPossible(boolean decodeToFloatIfPossible)
           
 void setMaximumPrimitiveValueSize(int maximumPrimitiveValueSize)
           
 void skipData(long numberOfBytesToSkip)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsnBerInputStream

public AsnBerInputStream(InputStream input)
Creates a new instance which will read from the given input stream.

Parameters:
input - the stream to read from. may not be null.
Method Detail

getMaximumPrimitiveValueSize

public final int getMaximumPrimitiveValueSize()

setMaximumPrimitiveValueSize

public final void setMaximumPrimitiveValueSize(int maximumPrimitiveValueSize)

isDecodeToFloatIfPossible

public final boolean isDecodeToFloatIfPossible()

setDecodeToFloatIfPossible

public final void setDecodeToFloatIfPossible(boolean decodeToFloatIfPossible)

hasMoreDataAvailable

public final boolean hasMoreDataAvailable()
                                   throws IOException
Determines whether more data is available to be read from this instance.

Returns:
true if some more data can be read, false if the stream has been closed or no data is currently available.
Throws:
IOException - in case of an io error

mark

public final void mark(int readLimit)
                throws IOException
Throws:
IOException

reset

public final void reset()
                 throws IOException
Throws:
IOException

readNextTag

public final AsnTag readNextTag()
                         throws IOException,
                                AsnBerException
Throws:
IOException
AsnBerException

readTagLength

public final AsnBerTagLength readTagLength()
                                    throws IOException,
                                           AsnBerException
Throws:
IOException
AsnBerException

readValue

public final void readValue(AsnSimpleValueBase value,
                            long valueLength)
                     throws IOException,
                            AsnException
Throws:
IOException
AsnException

readTagValue

public final void readTagValue(byte[] tagValue)
                        throws IOException,
                               AsnBerException
Read the tag value data from the underlying stream. Attempts to read exactly tagValue.length
Parameters:
tagValue - the buffer into which the data is read
Throws:
AsnBerException - in case not enough data can be read
IOException - in case of an io error
NullPointerException - in case buffer is null

readTagValue

public final void readTagValue(byte[] tagValue,
                               int offset,
                               int length)
                        throws IOException,
                               AsnBerException
Read the tag value data from the underlying stream. Attempts to read exactly length
Parameters:
tagValue - the buffer into which the data is read
offset - the start offset in the array at which the data is written
length - the number of bytes to read (obtained via readTagLength)
Throws:
AsnBerException - in case not enough data can be read
IOException - in case of an io error
NullPointerException - in case buffer is null
IllegalArgumentException - in case of a negative length
ArrayIndexOutOfBoundsException - in case offset..offset+length-1 exceeds the boundaries of the array

skipData

public void skipData(long numberOfBytesToSkip)
              throws IOException,
                     AsnBerException
Throws:
IOException
AsnBerException

getCurrentPosition

public final long getCurrentPosition()
Gets the current position in the stream.

Returns:
the index of the next octet to be read since the beginning

isClosed

public final boolean isClosed()
Determines whether this instance has been closed.

Returns:
true if this instance is closed, false otherwise

close

public final void close()
                 throws IOException
Irrevocably closes this instance. Further reading is not possible afterwards. The underlying stream gets closed without any further processing.

Throws:
IOException - in case of an io error


Copyright 2007-2007 SourceForge. All Rights Reserved.