### Question:
RFC2616Codec implements ICharArrayCodec { public void encode (@Nullable final char [] aDecodedBuffer, @Nonnegative final int nOfs, @Nonnegative final int nLen, @Nonnull @WillNotClose final Writer aWriter) { if (aDecodedBuffer == null) return; try { aWriter.write (QUOTE_CHAR); for (int i = 0; i < nLen; ++i) { final char b = aDecodedBuffer[nOfs + i]; if (b == ESCAPE_CHAR || b == QUOTE_CHAR) aWriter.write (ESCAPE_CHAR); aWriter.write (b); } aWriter.write (QUOTE_CHAR); } catch (final IOException ex) { throw new EncodeException ("Failed to encode RFC2616", ex); } } RFC2616Codec(); static boolean isToken(@Nullable final String s); static boolean isToken(@Nullable final char [] aChars); static boolean isMaybeEncoded(@Nullable final String s); static boolean isMaybeEncoded(@Nullable final char [] s); @Nonnegative @Override int getMaximumEncodedLength(@Nonnegative final int nDecodedLen); void encode(@Nullable final char [] aDecodedBuffer,
                      @Nonnegative final int nOfs,
                      @Nonnegative final int nLen,
                      @Nonnull @WillNotClose final Writer aWriter); @Nonnegative @Override int getMaximumDecodedLength(@Nonnegative final int nEncodedLen); void decode(@Nullable final char [] aEncodedBuffer,
                      @Nonnegative final int nOfs,
                      @Nonnegative final int nLen,
                      @Nonnull @WillNotClose final Writer aWriter);  }### Answer:
@Test public void testEncode () { final RFC2616Codec aCodec = new RFC2616Codec (); assertNull (aCodec.getEncodedAsString ((char []) null)); assertNull (aCodec.getEncodedAsString ((String) null)); assertEquals ("\"\"", aCodec.getEncodedAsString (ArrayHelper.EMPTY_CHAR_ARRAY)); assertEquals ("\"\"", aCodec.getEncodedAsString ("")); assertEquals ("\"abc\"", aCodec.getEncodedAsString ("abc")); assertEquals ("\"\\\"abc\\\"\"", aCodec.getEncodedAsString ("\"abc\"")); assertEquals ("\"a b c\"", aCodec.getEncodedAsString ("a b c")); assertEquals ("\" \\\\ \\\" \"", aCodec.getEncodedAsString (" \\ \" ")); }