Most visited

Recently visited

Added in API level 1

CoderResult

public class CoderResult
extends Object

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


编码器结果状态的描述。

字符编码器,即解码器或编码器,消耗来自输入缓冲器的字节(或字符),翻译它们,并将结果字符(或字节)写入输出缓冲器。 编码过程因以下四类原因之一而终止:该类由实例描述:

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.

Summary

Fields

public static final CoderResult OVERFLOW

结果对象指示溢出,意味着输出缓冲区中没有足够的空间。

public static final CoderResult UNDERFLOW

指示下溢的结果对象,表示输入缓冲区已被完全消耗,或者如果输入缓冲区尚未为空,则需要额外的输入。

Public methods

boolean isError()

告诉这个对象是否描述了一个错误条件。

boolean isMalformed()

告诉这个对象是否描述格式错误的输入错误。

boolean isOverflow()

告诉这个对象是否描述了溢出情况。

boolean isUnderflow()

告诉这个对象是否描述了一个下溢条件。

boolean isUnmappable()

告诉这个对象是否描述了一个不可映射的字符错误。

int length()

返回此对象描述的错误输入的长度 (可选操作)

static CoderResult malformedForLength(int length)

静态工厂方法,返回描述给定长度的格式错误的输入错误的唯一对象。

void throwException()

引发适用于此对象描述的结果的异常。

String toString()

返回描述此编码器结果的字符串。

static CoderResult unmappableForLength(int length)

静态工厂方法,返回描述给定长度的不可映射字符错误的唯一结果对象。

Inherited methods

From class java.lang.Object

Fields

OVERFLOW

Added in API level 1
CoderResult OVERFLOW

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

UNDERFLOW

Added in API level 1
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

isError

Added in API level 1
boolean isError ()

告诉这个对象是否描述了一个错误条件。

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

isMalformed

Added in API level 1
boolean isMalformed ()

告诉这个对象是否描述格式错误的输入错误。

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

isOverflow

Added in API level 1
boolean isOverflow ()

告诉这个对象是否描述了溢出情况。

Returns
boolean true if, and only if, this object denotes overflow

isUnderflow

Added in API level 1
boolean isUnderflow ()

告诉这个对象是否描述了一个下溢条件。

Returns
boolean true if, and only if, this object denotes underflow

isUnmappable

Added in API level 1
boolean isUnmappable ()

告诉这个对象是否描述了一个不可映射的字符错误。

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

length

Added in API level 1
int length ()

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

Returns
int The length of the erroneous input, a positive integer
Throws
UnsupportedOperationException If this object does not describe an error condition, that is, if the isError does not return true

malformedForLength

Added in API level 1
CoderResult malformedForLength (int length)

静态工厂方法,返回描述给定长度的格式错误的输入错误的唯一对象。

Parameters
length int
Returns
CoderResult The requested coder-result object

throwException

Added in API level 1
void throwException ()

引发适用于此对象描述的结果的异常。

Throws
BufferUnderflowException If this object is UNDERFLOW
BufferOverflowException If this object is OVERFLOW
MalformedInputException If this object represents a malformed-input error; the exception's length value will be that of this object
UnmappableCharacterException If this object represents an unmappable-character error; the exceptions length value will be that of this object
CharacterCodingException

toString

Added in API level 1
String toString ()

返回描述此编码器结果的字符串。

Returns
String A descriptive string

unmappableForLength

Added in API level 1
CoderResult unmappableForLength (int length)

静态工厂方法,返回描述给定长度的不可映射字符错误的唯一结果对象。

Parameters
length int
Returns
CoderResult The requested coder-result object

Hooray!