Interface IByteArrayEncoder

All Superinterfaces:
IEncoder<byte[],byte[]>
All Known Subinterfaces:
IByteArrayCodec, IByteArrayStreamEncoder
All Known Implementing Classes:
Base16Codec, Base32Codec, Base64Codec, FlateCodec, GZIPCodec, IdentityByteArrayCodec, LZWCodec, QuotedPrintableCodec, URLCodec
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 IByteArrayEncoder extends IEncoder<byte[],byte[]>
Interface for a single encoder of bytes.
Author:
Philip Helger
  • Method Summary

    Modifier and Type
    Method
    Description
    default byte[]
    getEncoded(byte[] aDecodedBuffer)
    Encode a byte array.
    byte[]
    getEncoded(byte[] aDecodedBuffer, int nOfs, int nLen)
    Encode a byte array.
    default byte[]
    getEncoded(String sDecoded, Charset aCharset)
    Encode the passed string.
    default int
    getMaximumEncodedLength(int nDecodedLen)
    Get the maximum encoded length based on the provided decoded length.
  • Method Details

    • getMaximumEncodedLength

      @Nonnegative default int getMaximumEncodedLength(@Nonnegative int nDecodedLen)
      Get the maximum encoded length based on the provided decoded length. This is purely for performance reasons. The name of the method would be better called "getMaximumEncodedLength".
      Parameters:
      nDecodedLen - The decoded length. Always ≥ 0.
      Returns:
      The maximum encoded length. Always ≥ 0.
      Since:
      9.3.6
    • getEncoded

      @Nullable @ReturnsMutableCopy default byte[] getEncoded(@Nullable byte[] aDecodedBuffer)
      Encode a byte array.
      Specified by:
      getEncoded in interface IEncoder<byte[],byte[]>
      Parameters:
      aDecodedBuffer - The byte array to be encoded. May be null.
      Returns:
      The encoded byte array or null if the parameter was null.
      Throws:
      EncodeException - In case something goes wrong
    • getEncoded

      @Nullable @ReturnsMutableCopy byte[] getEncoded(@Nullable byte[] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
      Encode a byte array.
      Parameters:
      aDecodedBuffer - The byte array to be encoded. May be null.
      nOfs - Offset into the byte array to start from.
      nLen - Number of bytes starting from offset to consider.
      Returns:
      The encoded byte array or null if the parameter was null.
      Throws:
      EncodeException - In case something goes wrong
    • getEncoded

      @Nullable @ReturnsMutableCopy default byte[] getEncoded(@Nullable String sDecoded, @Nonnull Charset aCharset)
      Encode the passed string.
      Parameters:
      sDecoded - The string to be encoded. May be null.
      aCharset - The charset to be used. May not be null.
      Returns:
      null if the input string is null.
      Throws:
      EncodeException - In case something goes wrong