Interface ICharArrayStreamEncoder

All Superinterfaces:
ICharArrayEncoder, IEncoder<char[],char[]>
All Known Subinterfaces:
ICharArrayCodec
All Known Implementing Classes:
RFC2616Codec
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 ICharArrayStreamEncoder extends ICharArrayEncoder
Interface for a single encoder of chars, based on reader/writer.
Author:
Philip Helger
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    encode(char @Nullable [] aDecodedBuffer, int nOfs, int nLen, @NonNull Writer aWriter)
    Encode (part of) a char array to an Writer.
    default void
    encode(char @Nullable [] aDecodedBuffer, @NonNull Writer aWriter)
    Encode a char array to a Writer.
    default char @Nullable []
    getEncoded(char @Nullable [] aDecodedBuffer)
    Encode a char array.
    default char @Nullable []
    getEncoded(char @Nullable [] aDecodedBuffer, int nOfs, int nLen)
    Encode a char array.
    default char @Nullable []
    getEncoded(@Nullable String sDecoded)
    Encode the passed string.
    default @Nullable String
    getEncodedAsString(char @Nullable [] aDecodedBuf)
    Encode a char array and return the result as a String.
    default @Nullable String
    getEncodedAsString(char @Nullable [] aDecodedBuf, int nOfs, int nLen)
    Encode (part of) a char array and return the result as a String.
    default @Nullable String
    getEncodedAsString(@Nullable String sDecoded)
    Encode the passed string and return the result as a 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".
      Specified by:
      getMaximumEncodedLength in interface ICharArrayEncoder
      Parameters:
      nDecodedLen - The decoded length. Always ≥ 0.
      Returns:
      The maximum encoded length. Always ≥ 0.
    • encode

      default void encode(char @Nullable [] aDecodedBuffer, @WillNotClose @NonNull Writer aWriter)
      Encode a char array to a Writer.
      Parameters:
      aDecodedBuffer - The char array to be encoded. May be null.
      aWriter - The writer to write to. May not be null and is NOT closed afterwards!
      Throws:
      EncodeException - In case something goes wrong
      Since:
      9.0.0
    • encode

      void encode(char @Nullable [] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull Writer aWriter)
      Encode (part of) a char array to an Writer.
      Parameters:
      aDecodedBuffer - The char array to be encoded. May be null.
      nOfs - Offset into the char array to start from.
      nLen - Number of chars starting from offset to consider.
      aWriter - The writer to write to. May not be null and is NOT closed afterwards!
      Throws:
      EncodeException - In case something goes wrong
    • getEncoded

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

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

      @ReturnsMutableCopy default char @Nullable [] getEncoded(@Nullable String sDecoded)
      Encode the passed string.
      Specified by:
      getEncoded in interface ICharArrayEncoder
      Parameters:
      sDecoded - The string to be encoded. May be null.
      Returns:
      null if the input string is null.
      Throws:
      EncodeException - In case something goes wrong
    • getEncodedAsString

      default @Nullable String getEncodedAsString(char @Nullable [] aDecodedBuf)
      Encode a char array and return the result as a String.
      Parameters:
      aDecodedBuf - The char array to be encoded. May be null.
      Returns:
      The encoded string or null if the parameter was null.
      Throws:
      EncodeException - In case something goes wrong
    • getEncodedAsString

      default @Nullable String getEncodedAsString(char @Nullable [] aDecodedBuf, @Nonnegative int nOfs, @Nonnegative int nLen)
      Encode (part of) a char array and return the result as a String.
      Parameters:
      aDecodedBuf - The char array to be encoded. May be null.
      nOfs - Offset into the char array to start from.
      nLen - Number of chars starting from offset to consider.
      Returns:
      The encoded string or null if the parameter was null.
      Throws:
      EncodeException - In case something goes wrong
    • getEncodedAsString

      default @Nullable String getEncodedAsString(@Nullable String sDecoded)
      Encode the passed string and return the result as a String.
      Parameters:
      sDecoded - The string to be encoded. May be null.
      Returns:
      null if the input string is null.
      Throws:
      EncodeException - In case something goes wrong