# CoderResult

public class **CoderResult** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
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:

- *Underflow* is reported when there is no more input to be
  processed, or there is insufficient input and additional input is
  required. This condition is represented by the unique result object
  `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#UNDERFLOW`, whose `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isUnderflow()` method
  returns true.

- *Overflow* is reported when there is insufficient room
  remaining in the output buffer. This condition is represented by the
  unique result object `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#OVERFLOW`, whose `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isOverflow()` method returns true.

- A *malformed-input error* is reported when a sequence of
  input units is not well-formed. Such errors are described by instances of
  this class whose `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isMalformed()` method returns
  true and whose `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#length()` method returns the length
  of the malformed sequence. There is one unique instance of this class for
  all malformed-input errors of a given length.

- An *unmappable-character error* is reported when a sequence
  of input units denotes a character that cannot be represented in the
  output charset. Such errors are described by instances of this class
  whose `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isUnmappable()` method returns true and
  whose `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#length()` method returns the length of the input
  sequence denoting the unmappable character. There is one unique instance
  of this class for all unmappable-character errors of a given length.

For convenience, the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#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.

<br />

### Field Summary

|---|---|---|
| public static final [CoderResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html) | [OVERFLOW](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#OVERFLOW) | Result object indicating overflow, meaning that there is insufficient room in the output buffer. |
| public static final [CoderResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html) | [UNDERFLOW](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#UNDERFLOW) | Result object indicating underflow, meaning that either the input buffer has been completely consumed or, if the input buffer is not yet empty, that additional input is required. |

### Public Method Summary

|---|---|
| boolean | [isError](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isError())() Tells whether or not this object describes an error condition. |
| boolean | [isMalformed](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isMalformed())() Tells whether or not this object describes a malformed-input error. |
| boolean | [isOverflow](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isOverflow())() Tells whether or not this object describes an overflow condition. |
| boolean | [isUnderflow](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isUnderflow())() Tells whether or not this object describes an underflow condition. |
| boolean | [isUnmappable](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isUnmappable())() Tells whether or not this object describes an unmappable-character error. |
| int | [length](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#length())() Returns the length of the erroneous input described by this object *(optional operation)*. |
| static [CoderResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html) | [malformedForLength](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#malformedForLength(int))(int length) Static factory method that returns the unique object describing a malformed-input error of the given length. |
| void | [throwException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#throwException())() Throws an exception appropriate to the result described by this object. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#toString())() Returns a string describing this coder result. |
| static [CoderResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html) | [unmappableForLength](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#unmappableForLength(int))(int length) Static factory method that returns the unique result object describing an unmappable-character error of the given length. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Fields

#### public static final CoderResult
**OVERFLOW**

Result object indicating overflow, meaning that there is insufficient
room in the output buffer.

#### public static final CoderResult
**UNDERFLOW**

Result object indicating underflow, meaning that either the input buffer
has been completely consumed or, if the input buffer is not yet empty,
that additional input is required.

## Public Methods

#### public boolean
**isError**
()

Tells whether or not this object describes an error condition.

##### Returns

- true if, and only if, this object denotes either a malformed-input error or an unmappable-character error

#### public boolean
**isMalformed**
()

Tells whether or not this object describes a malformed-input error.

##### Returns

- true if, and only if, this object denotes a malformed-input error

#### public boolean
**isOverflow**
()

Tells whether or not this object describes an overflow condition.

##### Returns

- true if, and only if, this object denotes overflow

#### public boolean
**isUnderflow**
()

Tells whether or not this object describes an underflow condition.

##### Returns

- true if, and only if, this object denotes underflow

#### public boolean
**isUnmappable**
()

Tells whether or not this object describes an unmappable-character
error.

##### Returns

- true if, and only if, this object denotes an unmappable-character error

#### public int
**length**
()

Returns the length of the erroneous input described by this
object *(optional operation)*.

##### Returns

- The length of the erroneous input, a positive integer

##### Throws

| [UnsupportedOperationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/UnsupportedOperationException.html) | If this object does not describe an error condition, that is, if the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#isError()` does not return true |
|---|---|

#### public static [CoderResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html)
**malformedForLength**
(int length)

Static factory method that returns the unique object describing a
malformed-input error of the given length.

##### Parameters

| length | The given length |
|---|---|

##### Returns

- The requested coder-result object

#### public void
**throwException**
()

Throws an exception appropriate to the result described by this object.

##### Throws

| [BufferUnderflowException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/BufferUnderflowException.html) | If this object is `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#UNDERFLOW` |
| [BufferOverflowException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/BufferOverflowException.html) | If this object is `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html#OVERFLOW` |
| [MalformedInputException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/MalformedInputException.html) | If this object represents a malformed-input error; the exception's length value will be that of this object |
| [UnmappableCharacterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/UnmappableCharacterException.html) | If this object represents an unmappable-character error; the exceptions length value will be that of this object |
| [CharacterCodingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CharacterCodingException.html) |   |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a string describing this coder result.

##### Returns

- A descriptive string

#### public static [CoderResult](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/CoderResult.html)
**unmappableForLength**
(int length)

Static factory method that returns the unique result object describing
an unmappable-character error of the given length.

##### Parameters

| length | The given length |
|---|---|

##### Returns

- The requested coder-result object