Interface IByteArrayStreamDecoder

All Superinterfaces:
IByteArrayDecoder, IDecoder<byte[],byte[]>
All Known Subinterfaces:
IByteArrayCodec
All Known Implementing Classes:
ASCII85Codec, ASCIIHexCodec, Base16Codec, Base32Codec, Base64Codec, FlateCodec, GZIPCodec, IdentityByteArrayCodec, LZWCodec, QuotedPrintableCodec, RFC3986Codec, RunLengthCodec
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IByteArrayStreamDecoder extends IByteArrayDecoder
Interface for a single decoder of bytes, based on streams.
Author:
Philip Helger
  • Method Details

    • decode

      default void decode(byte @Nullable [] aEncodedBuffer, @WillNotClose @NonNull OutputStream aOS)
      Decode a byte array.
      Parameters:
      aEncodedBuffer - The byte array to be decoded. May be null.
      aOS - The output stream to write to. May not be null and is NOT closed afterwards!
      Throws:
      DecodeException - in case something goes wrong
      Since:
      9.0.0
    • decode

      void decode(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS)
      Decode (part of) a byte array.
      Parameters:
      aEncodedBuffer - The byte array to be decoded. May be null.
      nOfs - Offset into the byte array to start from.
      nLen - Number of bytes starting from offset to consider.
      aOS - The output stream to write to. May not be null and is NOT closed afterwards!
      Throws:
      DecodeException - in case something goes wrong
    • getDecoded

      @ReturnsMutableCopy default byte @Nullable [] getDecoded(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
      Decode a byte array.
      Specified by:
      getDecoded in interface IByteArrayDecoder
      Parameters:
      aEncodedBuffer - The byte array to be decoded. May be null.
      nOfs - Offset into the byte array to start from.
      nLen - Number of bytes starting from offset to consider.
      Returns:
      The decoded byte array or null if the parameter was null.
      Throws:
      DecodeException - in case something goes wrong
    • getDecodedAsString

      default @Nullable String getDecodedAsString(byte @Nullable [] aEncodedBuffer, @NonNull Charset aCharset)
      Decode a byte array and return the result as a string.
      Parameters:
      aEncodedBuffer - The byte array to be decoded. May be null.
      aCharset - The charset to be used for the result string. May not be null.
      Returns:
      null if the input buffer is null.
      Throws:
      DecodeException - in case something goes wrong
    • getDecodedAsString

      default @Nullable String getDecodedAsString(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @NonNull Charset aCharset)
      Decode a portion of a byte array and return the result as a string.
      Parameters:
      aEncodedBuffer - The byte array to be decoded. May be null.
      nOfs - Offset into the byte array to start from.
      nLen - Number of bytes starting from offset to consider.
      aCharset - The charset to be used for the result string. May not be null.
      Returns:
      null if the input buffer is null.
      Throws:
      DecodeException - in case something goes wrong
    • getDecodedAsString

      default @Nullable String getDecodedAsString(@Nullable String sEncoded, @NonNull Charset aCharset)
      Decode the passed string.
      Parameters:
      sEncoded - The string to be decoded. May be null.
      aCharset - The charset to be used for encoding AND decoding. May not be null.
      Returns:
      null if the input string is null.
      Throws:
      DecodeException - in case something goes wrong
    • getDecodedAsString

      default @Nullable String getDecodedAsString(@Nullable String sEncoded, @NonNull Charset aEncodedCharset, @NonNull Charset aDecodedCharset)
      Decode the passed string.
      Parameters:
      sEncoded - The string to be decoded. May be null.
      aEncodedCharset - The charset to be used for the encoded string. May not be null.
      aDecodedCharset - The charset to be used for the decoded result string. May not be null.
      Returns:
      null if the input string is null.
      Throws:
      DecodeException - in case something goes wrong
      Since:
      9.3.6