Generated by
JDiff

java.nio.charset Documentation Differences

This file contains all the changes in documentation in the package java.nio.charset as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class CharsetDecoder

An engine that can transform a sequence of bytes in a specific charset into a sequence of sixteen-bit Unicode characters.

The input byte sequence is provided in a byte buffer or a series of such buffers. The output character sequence is written to a character buffer or a series of such buffers. A decoder should always be used by making the following sequence of method invocations hereinafter referred to as a decoding operation:

  1. Reset the decoder via the reset method unless it has not been used before;

  2. Invoke the decode method zero or more times as long as additional input may be available passing false for the endOfInput argument and filling the input buffer and flushing the output buffer between invocations;

  3. Invoke the decode method one final time passing true for the endOfInput argument; and then

  4. Invoke the flush method so that the decoder can flush any internal state to the output buffer.

Each invocation of the decode method will decode as many bytes as possible from the input buffer writing the resulting characters to the output buffer. The decode method returns when more input is required when there is not enough room in the output buffer or when a decoding error has occurred. In each case a CoderResult object is returned to describe the reason for termination. An invoker can examine this object and fill the input buffer flush the output buffer or attempt to recover from a decoding error as appropriate and try again.

There are two general types of decoding errors. If the input byte sequence is not legal for this charset then the input is considered malformed. If the input byte sequence is legal but cannot be mapped to a valid Unicode character then an unmappable character has been encountered.

How a decoding error is handled depends upon the action requested for that type of error which is described by an instance of the CodingErrorAction class. The possible error actions are to ignore the erroneous input report the error to the invoker via the returned CoderResult object or replace the erroneous input with the current value of the replacement string. The replacement has the initial value "\uFFFD"; its value may be changed via the replaceWith method.

The default action for malformed-input and unmappable-character errors is to report them. The malformed-input error action may be changed via the onMalformedInput method; the unmappable-character action may be changed via the onUnmappableCharacter method.

This class is designed to handle many of the details of the decoding process including the implementation of error actions. A decoder for a specific charset which is a concrete subclass of this class need only implement the abstract decodeLoop method which encapsulates the basic decoding loop. A subclass that maintains internal state should additionally override the flush and reset methods.

Instances of this class are not safe for use by multiple concurrent threads.

@version 1.35 0136 02/1204/0310 @author Mark Reinhold @author JSR-51 Expert Group @since 1.4 @see ByteBuffer @see CharBuffer @see Charset @see CharsetEncoder

Class CharsetEncoder

An engine that can transform a sequence of sixteen-bit Unicode characters into a sequence of bytes in a specific charset.

The input character sequence is provided in a character buffer or a series of such buffers. The output byte sequence is written to a byte buffer or a series of such buffers. An encoder should always be used by making the following sequence of method invocations hereinafter referred to as an encoding operation:

  1. Reset the encoder via the reset method unless it has not been used before;

  2. Invoke the encode method zero or more times as long as additional input may be available passing false for the endOfInput argument and filling the input buffer and flushing the output buffer between invocations;

  3. Invoke the encode method one final time passing true for the endOfInput argument; and then

  4. Invoke the flush method so that the encoder can flush any internal state to the output buffer.

Each invocation of the encode method will encode as many characters as possible from the input buffer writing the resulting bytes to the output buffer. The encode method returns when more input is required when there is not enough room in the output buffer or when an encoding error has occurred. In each case a CoderResult object is returned to describe the reason for termination. An invoker can examine this object and fill the input buffer flush the output buffer or attempt to recover from an encoding error as appropriate and try again.

There are two general types of encoding errors. If the input character sequence is not a legal sixteen-bit Unicode sequence then the input is considered malformed. If the input character sequence is legal but cannot be mapped to a valid byte sequence in the given charset then an unmappable character has been encountered.

How an encoding error is handled depends upon the action requested for that type of error which is described by an instance of the CodingErrorAction class. The possible error actions are to ignore the erroneous input report the error to the invoker via the returned CoderResult object or replace the erroneous input with the current value of the replacement byte array. The replacement is initially set to the encoder's default replacement which often (but not always) has the initial value { (byte)' ' }; its value may be changed via the replaceWith method.

The default action for malformed-input and unmappable-character errors is to report them. The malformed-input error action may be changed via the onMalformedInput method; the unmappable-character action may be changed via the onUnmappableCharacter method.

This class is designed to handle many of the details of the encoding process including the implementation of error actions. An encoder for a specific charset which is a concrete subclass of this class need only implement the abstract encodeLoop method which encapsulates the basic encoding loop. A subclass that maintains internal state should additionally override the flush and reset methods.

Instances of this class are not safe for use by multiple concurrent threads.

@version 1.35 0136 02/1204/0310 @author Mark Reinhold @author JSR-51 Expert Group @since 1.4 @see ByteBuffer @see CharBuffer @see Charset @see CharsetDecoder

Class CoderResult

A description of the result state of a coder.

A charset coder that is either a decoder or an encoder consumes bytes (or characters) from an input buffer translates them and writes the resulting characters (or bytes) to an output buffer. A coding process terminates for one of four categories of reasons which are described by instances of this class:

For convenience the isError method returns true for result objects that describe malformed-input and unmappable-character errors but false for those that describe underflow or overflow conditions.

@author Mark Reinhold @author JSR-51 Expert Group @version 1.5 016 02/1204/0310 @since 1.4