Class Base16Codec

java.lang.Object
com.helger.base.codec.impl.Base16Codec
All Implemented Interfaces:
IByteArrayCodec, IByteArrayDecoder, IByteArrayEncoder, IByteArrayStreamDecoder, IByteArrayStreamEncoder, ICodec<byte[]>, IDecoder<byte[],byte[]>, IEncoder<byte[],byte[]>

public class Base16Codec extends Object implements IByteArrayCodec
Base16 encoder and decoder.
Author:
Philip Helger
  • Constructor Details

    • Base16Codec

      public Base16Codec()
      Creates a Base16 codec used for decoding and encoding.
  • Method Details

    • getMaximumEncodedLength

      @Nonnegative public int getMaximumEncodedLength(@Nonnegative int nDecodedLen)
      Description copied from interface: IByteArrayEncoder
      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".
      Specified by:
      getMaximumEncodedLength in interface IByteArrayEncoder
      Specified by:
      getMaximumEncodedLength in interface IByteArrayStreamEncoder
      Parameters:
      nDecodedLen - The decoded length. Always ≥ 0.
      Returns:
      The maximum encoded length. Always ≥ 0.
    • encode

      public void encode(@Nonnull @WillNotClose InputStream aDecodedIS, @Nonnull @WillNotClose OutputStream aOS)
    • encode

      public void encode(@Nullable byte[] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull @WillNotClose OutputStream aOS)
      Description copied from interface: IByteArrayStreamEncoder
      Encode (part of) a byte array to an OutputStream.
      Specified by:
      encode in interface IByteArrayStreamEncoder
      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.
      aOS - The output stream to write to. May not be null and is NOT closed afterwards!
    • getMaximumDecodedLength

      @Nonnegative public int getMaximumDecodedLength(@Nonnegative int nEncodedLen)
      Description copied from interface: IByteArrayDecoder
      Get the maximum decoded length based on the provided encoded length. This is purely for performance reasons.
      Specified by:
      getMaximumDecodedLength in interface IByteArrayDecoder
      Parameters:
      nEncodedLen - The encoded length. Always ≥ 0.
      Returns:
      The maximum decoded length. Always ≥ 0.
    • decode

      public void decode(@Nonnull @WillNotClose InputStream aEncodedIS, @Nonnull @WillNotClose OutputStream aOS)
    • decode

      public void decode(@Nullable byte[] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull @WillNotClose OutputStream aOS)
      Description copied from interface: IByteArrayStreamDecoder
      Decode (part of) a byte array.
      Specified by:
      decode in interface IByteArrayStreamDecoder
      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!