Android
java.nio.charset
public class

java.nio.charset.CoderResult

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

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

  1. UNDERFLOW indicates all input has been processed, or more input is required. It is represented by the unique object CoderResult.UNDERFLOW.
  2. OVERFLOW indicates insufficient output buffer. It is represented by the unique object CoderResult.OVERFLOW.
  3. A malformed-input error indicates 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 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

Constants

      Value  
CoderResult  OVERFLOW  Result object used to signify that the out buffer does not have enough space available in it to store the result of the encoding/decoding.     
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()
Gets the length of the erroneous input.
  synchronized    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.
  synchronized    static    CoderResult  unmappableForLength(int length)
Gets a CoderResult object indicating an unmappable character error.
Methods inherited from class java.lang.Object

Details

Constants

public static final CoderResult OVERFLOW

Result object used to signify that the out buffer does not have enough space available in it 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

public boolean isError()

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

Returns

  • true if a malformed-input error or an unmappable-character error, otherwise false

public boolean isMalformed()

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

Returns

  • true if a malformed-input error, otherwise false

public boolean isOverflow()

Returns true if this result is an overflow condition.

Returns

  • true if an overflow, otherwise false

public boolean isUnderflow()

Returns true if this result is an underflow condition.

Returns

  • true if an underflow, otherwise false

public boolean isUnmappable()

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

Returns

  • true if an unmappable-character error, otherwise false

public int length()

Gets the length of the erroneous input. The length is only meaningful to a malformed-input error or an unmappble character error.

Returns

  • the length, as an integer, of this object's erroneous input

Throws

UnsupportedOperationException If this result is an overflow or underflow.

public static synchronized CoderResult malformedForLength(int length)

Gets a CoderResult object indicating a malformed-input error.

Parameters

length the length of the malformed-input

Returns

  • a CoderResult object indicating a malformed-input error

Throws

IllegalArgumentException If length is non-positive.

public void throwException()

Throws an exception corresponding to this coder result.

Throws

BufferUnderflowException If an underflow.
BufferOverflowException If an overflow.
UnmappableCharacterException If an unmappable-character error.
MalformedInputException If a malformed-input error.
CharacterCodingException The default exception.

public String toString()

Returns a text description of this result.

Returns

  • a text description of this result

public static synchronized CoderResult unmappableForLength(int length)

Gets a CoderResult object indicating an unmappable character error.

Parameters

length the length of the input unit sequence denoting the unmappable character

Returns

  • a CoderResult object indicating an unmappable character error

Throws

IllegalArgumentException If length is non-positive.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48