APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.cs

public abstract Class UnicodeEncoder

extends CharsetEncoder
Class Inheritance
Known Direct Subclasses
sun.nio.cs.UTF_16.Encoder, sun.nio.cs.UTF_16BE.Encoder, sun.nio.cs.UTF_16LE.Encoder, sun.nio.cs.UTF_16LE_BOM.Encoder
Imports
java.nio.*, java.nio.charset.*

Base class for different flavors of UTF-16 encoders

Field Summary

Modifier and TypeField and Description
protected static final int
protected static final char
private int
protected static final int
private boolean
protected static final char
private final Surrogate.Parser
private boolean

Constructor Summary

AccessConstructor and Description
protected
UnicodeEncoder(Charset cs, int bo, boolean m)

Method Summary

Modifier and TypeMethod and Description
public boolean
canEncode(char c)

Overrides java.nio.charset.CharsetEncoder.canEncode.

Tells whether or not this encoder can encode the given character.

public boolean
canEncode(CharSequence cs)

Overrides java.nio.charset.CharsetEncoder.canEncode.

Tells whether or not this encoder can encode the given character sequence.

protected CoderResult
encodeLoop(CharBuffer src, ByteBuffer dst)

Implements abstract java.nio.charset.CharsetEncoder.encodeLoop.

Encodes one or more characters into one or more bytes.

protected void
implReset()

Overrides java.nio.charset.CharsetEncoder.implReset.

Resets this encoder, clearing any charset-specific internal state.

private void
put(char c, ByteBuffer dst)

Inherited from java.nio.charset.CharsetEncoder:
averageBytesPerCharcharsetencodeencodeflushimplFlushimplOnMalformedInputimplOnUnmappableCharacterimplReplaceWithisLegalReplacementmalformedInputActionmaxBytesPerCharonMalformedInputonUnmappableCharacterreplacementreplaceWithresetunmappableCharacterAction

Field Detail

BIGback to summary
protected static final int BIG
BYTE_ORDER_MARKback to summary
protected static final char BYTE_ORDER_MARK
byteOrderback to summary
private int byteOrder
LITTLEback to summary
protected static final int LITTLE
needsMarkback to summary
private boolean needsMark
REVERSED_MARKback to summary
protected static final char REVERSED_MARK
sgpback to summary
private final Surrogate.Parser sgp
usesMarkback to summary
private boolean usesMark

Constructor Detail

UnicodeEncoderback to summary
protected UnicodeEncoder(Charset cs, int bo, boolean m)

Method Detail

canEncodeback to summary
public boolean canEncode(char c)

Overrides java.nio.charset.CharsetEncoder.canEncode.

Doc from java.nio.charset.CharsetEncoder.canEncode.

Tells whether or not this encoder can encode the given character.

This method returns false if the given character is a surrogate character; such characters can be interpreted only when they are members of a pair consisting of a high surrogate followed by a low surrogate. The canEncode(CharSequence) method may be used to test whether or not a character sequence can be encoded.

This method may modify this encoder's state; it should therefore not be invoked if an encoding operation is already in progress.

The default implementation of this method is not very efficient; it should generally be overridden to improve performance.

canEncodeback to summary
public boolean canEncode(CharSequence cs)

Overrides java.nio.charset.CharsetEncoder.canEncode.

Doc from java.nio.charset.CharsetEncoder.canEncode.

Tells whether or not this encoder can encode the given character sequence.

If this method returns false for a particular character sequence then more information about why the sequence cannot be encoded may be obtained by performing a full encoding operation.

This method may modify this encoder's state; it should therefore not be invoked if an encoding operation is already in progress.

The default implementation of this method is not very efficient; it should generally be overridden to improve performance.

encodeLoopback to summary
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst)

Implements abstract java.nio.charset.CharsetEncoder.encodeLoop.

Doc from java.nio.charset.CharsetEncoder.encodeLoop.

Encodes one or more characters into one or more bytes.

This method encapsulates the basic encoding loop, encoding as many characters as possible until it either runs out of input, runs out of room in the output buffer, or encounters an encoding error. This method is invoked by the encode method, which handles result interpretation and error recovery.

The buffers are read from, and written to, starting at their current positions. At most in.remaining() characters will be read, and at most out.remaining() bytes will be written. The buffers' positions will be advanced to reflect the characters read and the bytes written, but their marks and limits will not be modified.

This method returns a CoderResult object to describe its reason for termination, in the same manner as the encode method. Most implementations of this method will handle encoding errors by returning an appropriate result object for interpretation by the encode method. An optimized implementation may instead examine the relevant error action and implement that action itself.

An implementation of this method may perform arbitrary lookahead by returning CoderResult#UNDERFLOW until it receives sufficient input.

implResetback to summary
protected void implReset()

Overrides java.nio.charset.CharsetEncoder.implReset.

Doc from java.nio.charset.CharsetEncoder.implReset.

Resets this encoder, clearing any charset-specific internal state.

The default implementation of this method does nothing. This method should be overridden by encoders that maintain internal state.

putback to summary
private void put(char c, ByteBuffer dst)