Class RFC3986Codec

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

@Immutable public class RFC3986Codec extends Object implements IByteArrayCodec
Encoder and decoder for URL stuff based on RFC 3986.
Author:
Philip Helger
  • Constructor Details

    • RFC3986Codec

      public RFC3986Codec()
      Default constructor with the RFC 3986 printable characters.
    • RFC3986Codec

      public RFC3986Codec(@NonNull BitSet aPrintableChars)
      Constructor with an arbitrary set of printable characters.
      Parameters:
      aPrintableChars - The printable character BitSet to use. May not be null.
  • Method Details

    • getDefaultPrintableChars

      @ReturnsMutableCopy public static @NonNull BitSet getDefaultPrintableChars()
      Returns:
      A copy of the default bit set to be used. Never null.
    • getPrintableChars

      @ReturnsMutableCopy public @NonNull BitSet getPrintableChars()
      Returns:
      A copy of the default bit set to be used. Never null.
    • writeEncodedURLByte

      public static final void writeEncodedURLByte(int b, @NonNull OutputStream aOS) throws IOException
      Encodes byte into its URL representation.
      Parameters:
      b - byte to encode
      aOS - the output stream to write to. May not be null.
      Throws:
      IOException - In case writing to the OutputStream failed
    • encode

      public void encode(byte @Nullable [] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS)
      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!
    • decode

      public void decode(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS)
      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!