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

public Class Surrogate

extends Object
Class Inheritance
Imports
java.nio.CharBuffer, java.nio.charset.CoderResult, .MalformedInputException, .UnmappableCharacterException

Utility class for dealing with surrogates.
Authors
Mark Reinhold, Martin Buchholz, Ulf Zibis

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Surrogate.Generator

Surrogate generation support.

public static class
Surrogate.Parser

Surrogate parsing support.

Field Summary

Modifier and TypeField and Description
public static final char
public static final char
public static final char
public static final char
public static final char
public static final char
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static char
high(int uc)

Returns the high UTF-16 surrogate for the given supplementary UCS-4 character.

public static boolean
is(int c)

Tells whether or not the given value is in the surrogate range.

public static boolean
isHigh(int c)

Tells whether or not the given value is in the high surrogate range.

public static boolean
isLow(int c)

Tells whether or not the given value is in the low surrogate range.

public static char
low(int uc)

Returns the low UTF-16 surrogate for the given supplementary UCS-4 character.

public static boolean
neededFor(int uc)

Tells whether or not the given UCS-4 character must be represented as a surrogate pair in UTF-16.

public static int
toUCS4(char c, char d)

Converts the given surrogate pair into a 32-bit UCS-4 character.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAXback to summary
public static final char MAX
MAX_HIGHback to summary
public static final char MAX_HIGH
MAX_LOWback to summary
public static final char MAX_LOW
MINback to summary
public static final char MIN
MIN_HIGHback to summary
public static final char MIN_HIGH
MIN_LOWback to summary
public static final char MIN_LOW
UCS4_MAXback to summary
public static final int UCS4_MAX
UCS4_MINback to summary
public static final int UCS4_MIN

Constructor Detail

Surrogateback to summary
private Surrogate()

Method Detail

highback to summary
public static char high(int uc)

Returns the high UTF-16 surrogate for the given supplementary UCS-4 character. Use of Character#highSurrogate is generally preferred.

isback to summary
public static boolean is(int c)

Tells whether or not the given value is in the surrogate range. Use of Character#isSurrogate is generally preferred.

isHighback to summary
public static boolean isHigh(int c)

Tells whether or not the given value is in the high surrogate range. Use of Character#isHighSurrogate is generally preferred.

isLowback to summary
public static boolean isLow(int c)

Tells whether or not the given value is in the low surrogate range. Use of Character#isLowSurrogate is generally preferred.

lowback to summary
public static char low(int uc)

Returns the low UTF-16 surrogate for the given supplementary UCS-4 character. Use of Character#lowSurrogate is generally preferred.

neededForback to summary
public static boolean neededFor(int uc)

Tells whether or not the given UCS-4 character must be represented as a surrogate pair in UTF-16. Use of Character#isSupplementaryCodePoint is generally preferred.

toUCS4back to summary
public static int toUCS4(char c, char d)

Converts the given surrogate pair into a 32-bit UCS-4 character. Use of Character#toCodePoint is generally preferred.

sun.nio.cs back to summary

public Class Surrogate.Generator

extends Object
Class Inheritance

Surrogate generation support. Charset implementations may use instances of this class to handle the details of generating UTF-16 surrogate pairs.

Field Summary

Modifier and TypeField and Description
private CoderResult

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CoderResult
error()

If the previous generation operation detected an error, return the object describing that error.

public int

Returns:

Either a positive count of the number of UTF-16 characters written to the destination buffer, or -1, in which case error() will return a descriptive result object
generate
(int
The UCS-4 character
uc
,
int
The number of input bytes from which the UCS-4 value was constructed (used when creating result objects)
len
,
CharBuffer
The destination buffer, to which one or two UTF-16 characters will be written
dst
)

Generates one or two UTF-16 characters to represent the given UCS-4 character.

public int

Returns:

Either a positive count of the number of UTF-16 characters written to the destination buffer, or -1, in which case error() will return a descriptive result object
generate
(int
The UCS-4 character
uc
,
int
The number of input bytes from which the UCS-4 value was constructed (used when creating result objects)
len
,
char[]
The destination array, to which one or two UTF-16 characters will be written
da
,
int
The destination position
dp
,
int
The destination limit
dl
)

Generates one or two UTF-16 characters to represent the given UCS-4 character.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorback to summary
private CoderResult error

Constructor Detail

Generatorback to summary
public Generator()

Method Detail

errorback to summary
public CoderResult error()

If the previous generation operation detected an error, return the object describing that error.

generateback to summary
public int generate(int uc, int len, CharBuffer dst)

Generates one or two UTF-16 characters to represent the given UCS-4 character.

Parameters
uc:int

The UCS-4 character

len:int

The number of input bytes from which the UCS-4 value was constructed (used when creating result objects)

dst:CharBuffer

The destination buffer, to which one or two UTF-16 characters will be written

Returns:int

Either a positive count of the number of UTF-16 characters written to the destination buffer, or -1, in which case error() will return a descriptive result object

generateback to summary
public int generate(int uc, int len, char[] da, int dp, int dl)

Generates one or two UTF-16 characters to represent the given UCS-4 character.

Parameters
uc:int

The UCS-4 character

len:int

The number of input bytes from which the UCS-4 value was constructed (used when creating result objects)

da:char[]

The destination array, to which one or two UTF-16 characters will be written

dp:int

The destination position

dl:int

The destination limit

Returns:int

Either a positive count of the number of UTF-16 characters written to the destination buffer, or -1, in which case error() will return a descriptive result object

sun.nio.cs back to summary

public Class Surrogate.Parser

extends Object
Class Inheritance

Surrogate parsing support. Charset implementations may use instances of this class to handle the details of parsing UTF-16 surrogate pairs.

Field Summary

Modifier and TypeField and Description
private int
private CoderResult
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
character()

Returns the UCS-4 character previously parsed.

public CoderResult
error()

If the previous parse operation detected an error, return the object describing that error.

public int
increment()

Returns the number of UTF-16 characters consumed by the previous parse.

public boolean
isPair()

Tells whether or not the previously-parsed UCS-4 character was originally represented by a surrogate pair.

public int

Returns:

Either a parsed UCS-4 character, in which case the isPair() and increment() methods will return meaningful values, or -1, in which case error() will return a descriptive result object
parse
(char
The first character
c
,
CharBuffer
The source buffer, from which one more character will be consumed if c is a high surrogate
in
)

Parses a UCS-4 character from the given source buffer, handling surrogates.

public int

Returns:

Either a parsed UCS-4 character, in which case the isPair() and increment() methods will return meaningful values, or -1, in which case error() will return a descriptive result object
parse
(char
The first character
c
,
char[]
The input array, from which one more character will be consumed if c is a high surrogate
ia
,
int
The input index
ip
,
int
The input limit
il
)

Parses a UCS-4 character from the given source buffer, handling surrogates.

public CoderResult
unmappableResult()

Returns an unmappable-input result object, with the appropriate input length, for the previously-parsed character.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

characterback to summary
private int character
errorback to summary
private CoderResult error
isPairback to summary
private boolean isPair

Constructor Detail

Parserback to summary
public Parser()

Method Detail

characterback to summary
public int character()

Returns the UCS-4 character previously parsed.

errorback to summary
public CoderResult error()

If the previous parse operation detected an error, return the object describing that error.

incrementback to summary
public int increment()

Returns the number of UTF-16 characters consumed by the previous parse.

isPairback to summary
public boolean isPair()

Tells whether or not the previously-parsed UCS-4 character was originally represented by a surrogate pair.

parseback to summary
public int parse(char c, CharBuffer in)

Parses a UCS-4 character from the given source buffer, handling surrogates.

Parameters
c:char

The first character

in:CharBuffer

The source buffer, from which one more character will be consumed if c is a high surrogate

Returns:int

Either a parsed UCS-4 character, in which case the isPair() and increment() methods will return meaningful values, or -1, in which case error() will return a descriptive result object

parseback to summary
public int parse(char c, char[] ia, int ip, int il)

Parses a UCS-4 character from the given source buffer, handling surrogates.

Parameters
c:char

The first character

ia:char[]

The input array, from which one more character will be consumed if c is a high surrogate

ip:int

The input index

il:int

The input limit

Returns:int

Either a parsed UCS-4 character, in which case the isPair() and increment() methods will return meaningful values, or -1, in which case error() will return a descriptive result object

unmappableResultback to summary
public CoderResult unmappableResult()

Returns an unmappable-input result object, with the appropriate input length, for the previously-parsed character.