org.apache.tomcat.util.buf (Apache Tomcat 9.0.120 API Documentation)
Description: declaration: package: org.apache.tomcat.util.buf

# Package org.apache.tomcat.util.buf

package org.apache.tomcat.util.buf

## Buffers and Encodings

This package contains buffers and utils to perform encoding/decoding of buffers. That includes byte to char conversions, URL encodings, etc.

Encoding is a critical operation for performance. There are few tricks in this package - the C2B and B2C converters are caching an ISReader/OSWriter and keep everything allocated to do the conversions in any VM without any garbage.

This package must accommodate future extensions and additional converters ( most important: the nio.charset, which should be detected and used if available ). Also, we do have one handwritten UTF8Decoder, and other tuned encoders could be added.

My benchmarks ( I'm costin :-) show only small differences between C2B, B2C and handwritten coders/decoders, so UTF8Decoder may be disabled.

- Related Packages
  Package
  Description
  org.apache.tomcat.util
- Class
  Description
  AbstractChunk
  Base class for the *Chunk implementation to reduce duplication.
  Ascii
  This class implements some basic ASCII character handling functions.
  Asn1Parser
  This is a very basic ASN.1 parser that provides the limited functionality required by Tomcat.
  Asn1Writer
  Utility class for writing ASN.1 DER-encoded data structures.
  B2CConverter
  NIO based character decoder.
  ByteBufferHolder
  Simple wrapper for a `ByteBuffer` that remembers if the buffer has been flipped or not.
  ByteBufferUtils
  Utility methods for working with `ByteBuffer` instances.
  ByteChunk
  This class is used to represent a chunk of bytes, and utilities to manipulate byte[].
  ByteChunk.BufferOverflowException
  Exception thrown when a byte chunk buffer overflows.
  ByteChunk.ByteInputChannel
  Input interface, used when the buffer is empty.
  ByteChunk.ByteOutputChannel
  When we need more space we'll either grow the buffer ( up to the limit ) or send it to a channel.
  C2BConverter
  NIO based character encoder.
  CharChunk
  Utilities to manipulate char chunks.
  CharChunk.CharInputChannel
  Input interface, used when the buffer is empty.
  CharChunk.CharOutputChannel
  When we need more space we'll either grow the buffer ( up to the limit ) or send it to a channel.
  CharsetCache
  Cache for Charset instances.
  CharsetUtil
  Utility methods for charset operations.
  EncodedSolidusHandling
  Enumerates the possible handling strategies for encoded solidus characters (%2F) in URI paths.
  HexUtils
  Tables useful when converting byte arrays to and from strings of hexadecimal digits.
  MessageBytes
  This class is used to represent a sub array of bytes in an HTTP message.
  StringCache
  This class implements a String cache for ByteChunk and CharChunk.
  StringCache.ByteEntry
  Cache entry for byte chunk to String mapping.
  StringCache.CharEntry
  Cache entry for char chunk to String mapping.
  StringUtils
  Utility methods to build a separated list from a given set (not java.util.Set) of inputs and return that list as a string or append it to an existing StringBuilder.
  ToStringUtil
  Utility class used to provide String representations of objects.
  UDecoder
  All URL decoding happens here.
  UEncoder
  Efficient implementation of a UTF-8 encoder.
  UEncoder.SafeCharsSet
  Pre-defined sets of safe characters for URL encoding.
  UriUtil
  Utility class for working with URIs and URLs.
  Utf8Decoder
  Decodes bytes to UTF-8.
  Utf8Encoder
  Encodes characters as bytes using UTF-8.