Top Description Constructors Methods
org.apache.tomcat.util.buf

public Class Utf8Encoder

extends CharsetEncoder
Class Inheritance
Imports
java.nio.ByteBuffer, .CharBuffer, java.nio.charset.CharsetEncoder, .CoderResult, .StandardCharsets

Encodes characters as bytes using UTF-8. Extracted from Apache Harmony with some minor bug fixes applied.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private CoderResult
protected CoderResult
encodeLoop(CharBuffer
The input character buffer
in
,
ByteBuffer
The output byte buffer
out
)

Implements abstract java.nio.charset.CharsetEncoder.encodeLoop.

Encodes one or more characters into one or more bytes.

private CoderResult
Inherited from java.nio.charset.CharsetEncoder:
averageBytesPerCharcanEncodecanEncodecharsetencodeencodeflushimplFlushimplOnMalformedInputimplOnUnmappableCharacterimplReplaceWithimplResetisLegalReplacementmalformedInputActionmaxBytesPerCharonMalformedInputonUnmappableCharacterreplacementreplaceWithresetunmappableCharacterAction

Constructor Detail

Utf8Encoderback to summary
public Utf8Encoder()

Method Detail

encodeHasArrayback to summary
private CoderResult encodeHasArray(CharBuffer in, ByteBuffer out)
encodeLoopback to summary
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out)

Implements abstract java.nio.charset.CharsetEncoder.encodeLoop.

Doc from java.nio.charset.CharsetEncoder.encodeLoop.

Encodes one or more characters into one or more bytes.

This method encapsulates the basic encoding loop, encoding as many characters as possible until it either runs out of input, runs out of room in the output buffer, or encounters an encoding error. This method is invoked by the encode method, which handles result interpretation and error recovery.

The buffers are read from, and written to, starting at their current positions. At most in.remaining() characters will be read, and at most out.remaining() bytes will be written. The buffers' positions will be advanced to reflect the characters read and the bytes written, but their marks and limits will not be modified.

This method returns a CoderResult object to describe its reason for termination, in the same manner as the encode method. Most implementations of this method will handle encoding errors by returning an appropriate result object for interpretation by the encode method. An optimized implementation may instead examine the relevant error action and implement that action itself.

An implementation of this method may perform arbitrary lookahead by returning CoderResult#UNDERFLOW until it receives sufficient input.

Parameters
in:CharBuffer

The input character buffer

out:ByteBuffer

The output byte buffer

Returns:CoderResult

A coder-result object describing the reason for termination

Annotations
@Override
encodeNotHasArrayback to summary
private CoderResult encodeNotHasArray(CharBuffer in, ByteBuffer out)