Class RFC1522QCodec

java.lang.Object
com.helger.base.codec.impl.AbstractRFC1522Codec
com.helger.base.codec.impl.RFC1522QCodec
All Implemented Interfaces:
ICodec<String>, IDecoder<String,String>, IEncoder<String,String>

public class RFC1522QCodec extends AbstractRFC1522Codec
Similar to the Quoted-Printable content-transfer-encoding defined in RFC 1521 and designed to allow text containing mostly ASCII characters to be decipherable on an ASCII terminal without decoding.

RFC 1522 describes techniques to allow the encoding of non-ASCII text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message handling software.

This class is conditionally thread-safe. The instance field m_bEncodeBlanks is mutable setEncodeBlanks(boolean) but is not volatile, and accesses are not synchronised. If an instance of the class is shared between threads, the caller needs to ensure that suitable synchronisation is used to ensure safe publication of the value between threads, and must not invoke setEncodeBlanks(boolean) after initial setup.

See Also:
  • Field Details

    • DEFAULT_ENCODE_BLANKS

      public static final boolean DEFAULT_ENCODE_BLANKS
      See Also:
  • Constructor Details

    • RFC1522QCodec

      public RFC1522QCodec()
      Default constructor with the UTF-8 charset.
    • RFC1522QCodec

      public RFC1522QCodec(@NonNull Charset aCharset)
      Constructor which allows for the selection of a default charset.
      Parameters:
      aCharset - the default string charset to use.
  • Method Details

    • getAllPrintableChars

      @ReturnsMutableCopy public static @NonNull BitSet getAllPrintableChars()
      Returns:
      A mutable copy of the default printable characters as defined in RFC 1522. Never null.
    • getRFC1522Encoding

      protected String getRFC1522Encoding()
      Description copied from class: AbstractRFC1522Codec
      Returns the codec name (referred to as encoding in the RFC 1522).
      Specified by:
      getRFC1522Encoding in class AbstractRFC1522Codec
      Returns:
      name of the codec
    • isEncodeBlanks

      public boolean isEncodeBlanks()
      Tests if optional transformation of SPACE characters is to be used
      Returns:
      true if SPACE characters are to be transformed, false otherwise
    • setEncodeBlanks

      public void setEncodeBlanks(boolean bEncodeBlanks)
      Defines whether optional transformation of SPACE characters is to be used
      Parameters:
      bEncodeBlanks - true if SPACE characters are to be transformed, false otherwise
    • getEncoded

      @ReturnsMutableCopy protected byte @Nullable [] getEncoded(byte @Nullable [] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
      Specified by:
      getEncoded in class AbstractRFC1522Codec
    • getDecoded

      @ReturnsMutableCopy protected byte @Nullable [] getDecoded(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
      Specified by:
      getDecoded in class AbstractRFC1522Codec