Skip to content

Most visited

Recently visited

navigation
Added in API level 1

CoderResult

public class CoderResult
extends Object

java.lang.Object
   ↳ java.nio.charset.CoderResult


Used to indicate the result of encoding/decoding. There are four types of results:

  1. UNDERFLOW indicates that all input has been processed but more input is required. It is represented by the unique object CoderResult.UNDERFLOW.
  2. OVERFLOW indicates an insufficient output buffer size. It is represented by the unique object CoderResult.OVERFLOW.
  3. A malformed-input error indicates that an unrecognizable sequence of input units has been encountered. Get an instance of this type of result by calling CoderResult.malformedForLength(int) with the length of the malformed-input.
  4. An unmappable-character error indicates that a sequence of input units can not be mapped to the output charset. Get an instance of this type of result by calling CoderResult.unmappableForLength(int) with the input sequence size indicating the identity of the unmappable character.

Summary

Fields

public static final CoderResult OVERFLOW

Result object used to indicate that the output buffer does not have enough space available to store the result of the encoding/decoding.

public static final CoderResult UNDERFLOW

Result object indicating that there is insufficient data in the encoding/decoding buffer or that additional data is required.

Public methods

boolean isError()

Returns true if this result represents a malformed-input error or an unmappable-character error.

boolean isMalformed()

Returns true if this result represents a malformed-input error.

boolean isOverflow()

Returns true if this result is an overflow condition.

boolean isUnderflow()

Returns true if this result is an underflow condition.

boolean isUnmappable()

Returns true if this result represents an unmappable-character error.

int length()

Returns the length of the erroneous input.

static CoderResult malformedForLength(int length)

Gets a CoderResult object indicating a malformed-input error.

void throwException()

Throws an exception corresponding to this coder result.

String toString()

Returns a text description of this result.

static CoderResult unmappableForLength(int length)

Gets a CoderResult object indicating an unmappable character error.

Inherited methods

From class java.lang.Object

Fields

OVERFLOW

Added in API level 1
CoderResult OVERFLOW

Result object used to indicate that the output buffer does not have enough space available to store the result of the encoding/decoding.

UNDERFLOW

Added in API level 1
CoderResult UNDERFLOW

Result object indicating that there is insufficient data in the encoding/decoding buffer or that additional data is required.

Public methods

isError

Added in API level 1
boolean isError ()

Returns true if this result represents a malformed-input error or an unmappable-character error.

Returns
boolean

isMalformed

Added in API level 1
boolean isMalformed ()

Returns true if this result represents a malformed-input error.

Returns
boolean

isOverflow

Added in API level 1
boolean isOverflow ()

Returns true if this result is an overflow condition.

Returns
boolean

isUnderflow

Added in API level 1
boolean isUnderflow ()

Returns true if this result is an underflow condition.

Returns
boolean

isUnmappable

Added in API level 1
boolean isUnmappable ()

Returns true if this result represents an unmappable-character error.

Returns
boolean

length

Added in API level 1
int length ()

Returns the length of the erroneous input. The length is only meaningful for a malformed-input error or an unmappable character error.

Returns
int
Throws
UnsupportedOperationException if this result is an overflow or underflow.

malformedForLength

Added in API level 1
CoderResult malformedForLength (int length)

Gets a CoderResult object indicating a malformed-input error.

Parameters
length int: the length of the malformed-input.
Returns
CoderResult a CoderResult object indicating a malformed-input error.
Throws
IllegalArgumentException if length is non-positive.

throwException

Added in API level 1
void throwException ()

Throws an exception corresponding to this coder result.

Throws
BufferUnderflowException in case this is an underflow.
BufferOverflowException in case this is an overflow.
UnmappableCharacterException in case this is an unmappable-character error.
MalformedInputException in case this is a malformed-input error.
CharacterCodingException the default exception.

toString

Added in API level 1
String toString ()

Returns a text description of this result.

Returns
String a text description of this result.

unmappableForLength

Added in API level 1
CoderResult unmappableForLength (int length)

Gets a CoderResult object indicating an unmappable character error.

Parameters
length int: the length of the input unit sequence denoting the unmappable character.
Returns
CoderResult a CoderResult object indicating an unmappable character error.
Throws
IllegalArgumentException if length is non-positive.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.