Class SignatureStream

All Implemented Interfaces:
Closeable, AutoCloseable

public final class SignatureStream extends ByteArrayInputStream
An input stream over the first signaturePrefixLength bytes of another input stream, used to allow multiple codecs to probe those bytes for a file format/version signature.
  • Constructor Details

    • SignatureStream

      public SignatureStream(int signaturePrefixLength, byte[] signaturePrefix)
      Create a signature probe stream containing the first signaturePrefixLength bytes of an input stream that can be probed for a signature.
      Parameters:
      signaturePrefixLength - signaturePrefixLength should be expressed in "compressed(/encrypted)" space rather than "plaintext" space. For example, a raw signature may be n bytes of decompressed ASCII, but the codec may need to consume an entire encrypted GZIP block in order to inspect those n bytes. signaturePrefixLength should be specified based on the block size, in order to ensure that the signature probe stream contains a semantically meaningful fragment of the underlying input.
      signaturePrefix - the bytes containing the signature, over which the probe stream will be created
  • Method Details

    • getSignaturePrefixLength

      public final int getSignaturePrefixLength()
      Get the maximum number of bytes that can be consumed from this stream.
      Returns:
      the maximum number of bytes that can be consumed from this stream.