CoderResult (Java 2 Platform SE 5.0) (original) (raw)


java.nio.charset

Class CoderResult

java.lang.Object extended by java.nio.charset.CoderResult


public class CoderResult

extends Object

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:

Since:

1.4


Field Summary
static CoderResult OVERFLOW Result object indicating overflow, meaning that there is insufficient room in the output buffer.
static 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.
Method Summary
boolean isError() Tells whether or not this object describes an error condition.
boolean isMalformed() Tells whether or not this object describes a malformed-input error.
boolean isOverflow() Tells whether or not this object describes an overflow condition.
boolean isUnderflow() Tells whether or not this object describes an underflow condition.
boolean isUnmappable() Tells whether or not this object describes an unmappable-character error.
int length() Returns the length of the erroneous input described by this object (optional operation).
static CoderResult malformedForLength(int length) Static factory method that returns the unique object describing a malformed-input error of the given length.
void throwException() Throws an exception appropriate to the result described by this object.
String toString() Returns a string describing this coder result.
static CoderResult unmappableForLength(int length) Static factory method that returns the unique result object describing an unmappable-character error of the given length.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29)
Field Detail

UNDERFLOW

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.


OVERFLOW

public static final CoderResult OVERFLOW

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

Method Detail

toString

public String toString()

Returns a string describing this coder result.

Overrides:

[toString](../../../java/lang/Object.html#toString%28%29) in class [Object](../../../java/lang/Object.html "class in java.lang")

Returns:

A descriptive string


isUnderflow

public boolean isUnderflow()

Tells whether or not this object describes an underflow condition.

Returns:

true if, and only if, this object denotes underflow


isOverflow

public boolean isOverflow()

Tells whether or not this object describes an overflow condition.

Returns:

true if, and only if, this object denotes overflow


isError

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


isMalformed

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


isUnmappable

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


length

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](../../../java/lang/UnsupportedOperationException.html "class in java.lang") - If this object does not describe an error condition, that is, if the isError does not return true


malformedForLength

public static CoderResult malformedForLength(int length)

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

Returns:

The requested coder-result object


unmappableForLength

public static CoderResult unmappableForLength(int length)

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

Returns:

The requested coder-result object


throwException

public void throwException() throws CharacterCodingException

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

Throws:

[BufferUnderflowException](../../../java/nio/BufferUnderflowException.html "class in java.nio") - If this object is UNDERFLOW

[BufferOverflowException](../../../java/nio/BufferOverflowException.html "class in java.nio") - If this object is OVERFLOW

[MalformedInputException](../../../java/nio/charset/MalformedInputException.html "class in java.nio.charset") - If this object represents a malformed-input error; the exception's length value will be that of this object

[UnmappableCharacterException](../../../java/nio/charset/UnmappableCharacterException.html "class in java.nio.charset") - If this object represents an unmappable-character error; the exceptions length value will be that of this object

[CharacterCodingException](../../../java/nio/charset/CharacterCodingException.html "class in java.nio.charset")



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.