Top Inners Constructors Methods
org.glassfish.tyrus.core

public Class StrictUtf8

extends Charset
Class Inheritance
Imports
java.nio.Buffer, .ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetDecoder, .CharsetEncoder, .CoderResult, .CodingErrorAction

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
public static class
StrictUtf8.Parser

Surrogate parsing support.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(Charset
The given charset
cs
)

Implements abstract java.nio.charset.Charset.contains.

Tells whether or not this charset contains the given charset.

private static char
highSurrogate(int codePoint)

private static boolean
isSurrogate(char ch)

private static char
lowSurrogate(int codePoint)

public CharsetDecoder
newDecoder()

Implements abstract java.nio.charset.Charset.newDecoder.

Constructs a new decoder for this charset.

public CharsetEncoder
newEncoder()

Implements abstract java.nio.charset.Charset.newEncoder.

Constructs a new encoder for this charset.

private static void
updatePositions(ByteBuffer src, int sp, CharBuffer dst, int dp)

private static void
updatePositions(CharBuffer src, int sp, ByteBuffer dst, int dp)

Inherited from java.nio.charset.Charset:
aliasesavailableCharsetscanEncodecompareTodecodedefaultCharsetdisplayNamedisplayNameencodeencodeequalsforNameforNamehashCodeisRegisteredisSupportednametoString

Constructor Detail

StrictUtf8back to summary
public StrictUtf8()

Method Detail

containsback to summary
public boolean contains(Charset cs)

Implements abstract java.nio.charset.Charset.contains.

Doc from java.nio.charset.Charset.contains.

Tells whether or not this charset contains the given charset.

A charset C is said to contain a charset D if, and only if, every character representable in D is also representable in C. If this relationship holds then it is guaranteed that every string that can be encoded in D can also be encoded in C without performing any replacements.

That C contains D does not imply that each character representable in C by a particular byte sequence is represented in D by the same byte sequence, although sometimes this is the case.

Every charset contains itself.

This method computes an approximation of the containment relation: If it returns true then the given charset is known to be contained by this charset; if it returns false, however, then it is not necessarily the case that the given charset is not contained in this charset.

Parameters
cs:Charset

The given charset

Returns:boolean

true if the given charset is contained in this charset

Annotations
@Override
highSurrogateback to summary
private static char highSurrogate(int codePoint)
isSurrogateback to summary
private static boolean isSurrogate(char ch)
lowSurrogateback to summary
private static char lowSurrogate(int codePoint)
newDecoderback to summary
public CharsetDecoder newDecoder()

Implements abstract java.nio.charset.Charset.newDecoder.

Doc from java.nio.charset.Charset.newDecoder.

Constructs a new decoder for this charset.

Returns:CharsetDecoder

A new decoder for this charset

Annotations
@Override
newEncoderback to summary
public CharsetEncoder newEncoder()

Implements abstract java.nio.charset.Charset.newEncoder.

Doc from java.nio.charset.Charset.newEncoder.

Constructs a new encoder for this charset.

Returns:CharsetEncoder

A new encoder for this charset

Annotations
@Override
updatePositionsback to summary
private static void updatePositions(ByteBuffer src, int sp, CharBuffer dst, int dp)
updatePositionsback to summary
private static void updatePositions(CharBuffer src, int sp, ByteBuffer dst, int dp)
org.glassfish.tyrus.core back to summary

private Class StrictUtf8.Decoder

extends CharsetDecoder
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
decode(byte[] sa, int sp, int len, char[] da)

private CoderResult
private CoderResult
protected CoderResult
decodeLoop(ByteBuffer
The input byte buffer
src
,
CharBuffer
The output character buffer
dst
)

Implements abstract java.nio.charset.CharsetDecoder.decodeLoop.

Decodes one or more bytes into one or more characters.

private static ByteBuffer
getByteBuffer(ByteBuffer bb, byte[] ba, int sp)

private static boolean
isMalformed3(int b1, int b2, int b3)

private static boolean
isMalformed3_2(int b1, int b2)

private static boolean
isMalformed4(int b2, int b3, int b4)

private static boolean
isMalformed4_2(int b1, int b2)

private static boolean
private static boolean
private static CoderResult
malformed(ByteBuffer src, int sp, CharBuffer dst, int dp, int nb)

private static CoderResult
malformed(ByteBuffer src, int mark, int nb)

private static CoderResult
malformedForLength(ByteBuffer src, int sp, CharBuffer dst, int dp, int malformedNB)

private static CoderResult
malformedForLength(ByteBuffer src, int mark, int malformedNB)

private static CoderResult
malformedN(ByteBuffer src, int nb)

private static CoderResult
xflow(ByteBuffer src, int sp, int sl, CharBuffer dst, int dp, int nb)

private static CoderResult
xflow(Buffer src, int mark, int nb)

Inherited from java.nio.charset.CharsetDecoder:
averageCharsPerBytecharsetdecodedecodedetectedCharsetflushimplFlushimplOnMalformedInputimplOnUnmappableCharacterimplReplaceWithimplResetisAutoDetectingisCharsetDetectedmalformedInputActionmaxCharsPerByteonMalformedInputonUnmappableCharacterreplacementreplaceWithresetunmappableCharacterAction

Constructor Detail

Decoderback to summary
private Decoder(Charset cs)

Method Detail

decodeback to summary
public int decode(byte[] sa, int sp, int len, char[] da)
decodeArrayLoopback to summary
private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst)
decodeBufferLoopback to summary
private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst)
decodeLoopback to summary
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst)

Implements abstract java.nio.charset.CharsetDecoder.decodeLoop.

Doc from java.nio.charset.CharsetDecoder.decodeLoop.

Decodes one or more bytes into one or more characters.

This method encapsulates the basic decoding loop, decoding as many bytes as possible until it either runs out of input, runs out of room in the output buffer, or encounters a decoding error. This method is invoked by the decode 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() bytes will be read, and at most out.remaining() characters will be written. The buffers' positions will be advanced to reflect the bytes read and the characters 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 decode method. Most implementations of this method will handle decoding errors by returning an appropriate result object for interpretation by the decode 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.

Parameters
src:ByteBuffer

The input byte buffer

dst:CharBuffer

The output character buffer

Returns:CoderResult

A coder-result object describing the reason for termination

Annotations
@Override
getByteBufferback to summary
private static ByteBuffer getByteBuffer(ByteBuffer bb, byte[] ba, int sp)
isMalformed3back to summary
private static boolean isMalformed3(int b1, int b2, int b3)
isMalformed3_2back to summary
private static boolean isMalformed3_2(int b1, int b2)
isMalformed4back to summary
private static boolean isMalformed4(int b2, int b3, int b4)
isMalformed4_2back to summary
private static boolean isMalformed4_2(int b1, int b2)
isMalformed4_3back to summary
private static boolean isMalformed4_3(int b3)
isNotContinuationback to summary
private static boolean isNotContinuation(int b)
malformedback to summary
private static CoderResult malformed(ByteBuffer src, int sp, CharBuffer dst, int dp, int nb)
malformedback to summary
private static CoderResult malformed(ByteBuffer src, int mark, int nb)
malformedForLengthback to summary
private static CoderResult malformedForLength(ByteBuffer src, int sp, CharBuffer dst, int dp, int malformedNB)
malformedForLengthback to summary
private static CoderResult malformedForLength(ByteBuffer src, int mark, int malformedNB)
malformedNback to summary
private static CoderResult malformedN(ByteBuffer src, int nb)
xflowback to summary
private static CoderResult xflow(ByteBuffer src, int sp, int sl, CharBuffer dst, int dp, int nb)
xflowback to summary
private static CoderResult xflow(Buffer src, int mark, int nb)
org.glassfish.tyrus.core back to summary

pack-priv final Class StrictUtf8.Encoder

extends CharsetEncoder
Class Inheritance

Field Summary

Modifier and TypeField and Description
private StrictUtf8.Parser

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
canEncode(char
The given character
c
)

Overrides java.nio.charset.CharsetEncoder.canEncode.

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

public int
encode(char[] sa, int sp, int len, byte[] da)

private CoderResult
private CoderResult
protected final CoderResult
encodeLoop(CharBuffer
The input character buffer
src
,
ByteBuffer
The output byte buffer
dst
)

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

Encodes one or more characters into one or more bytes.

public boolean
isLegalReplacement(byte[]
The byte array to be tested
repl
)

Overrides java.nio.charset.CharsetEncoder.isLegalReplacement.

Tells whether or not the given byte array is a legal replacement value for this encoder.

private static CoderResult
overflow(CharBuffer src, int sp, ByteBuffer dst, int dp)

private static CoderResult
overflow(CharBuffer src, int mark)

Inherited from java.nio.charset.CharsetEncoder:
averageBytesPerCharcanEncodecharsetencodeencodeflushimplFlushimplOnMalformedInputimplOnUnmappableCharacterimplReplaceWithimplResetmalformedInputActionmaxBytesPerCharonMalformedInputonUnmappableCharacterreplacementreplaceWithresetunmappableCharacterAction

Field Detail

sgpback to summary
private StrictUtf8.Parser sgp

Constructor Detail

Encoderback to summary
private Encoder(Charset cs)

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.

Parameters
c:char

The given character

Returns:boolean

true if, and only if, this encoder can encode the given character

Annotations
@Override
encodeback to summary
public int encode(char[] sa, int sp, int len, byte[] da)
encodeArrayLoopback to summary
private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst)
encodeBufferLoopback to summary
private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst)
encodeLoopback to summary
protected final 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.

Parameters
src:CharBuffer

The input character buffer

dst:ByteBuffer

The output byte buffer

Returns:CoderResult

A coder-result object describing the reason for termination

Annotations
@Override
isLegalReplacementback to summary
public boolean isLegalReplacement(byte[] repl)

Overrides java.nio.charset.CharsetEncoder.isLegalReplacement.

Doc from java.nio.charset.CharsetEncoder.isLegalReplacement.

Tells whether or not the given byte array is a legal replacement value for this encoder.

A replacement is legal if, and only if, it is a legal sequence of bytes in this encoder's charset; that is, it must be possible to decode the replacement into one or more sixteen-bit Unicode characters.

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

Parameters
repl:byte[]

The byte array to be tested

Returns:boolean

true if, and only if, the given byte array is a legal replacement value for this encoder

Annotations
@Override
overflowback to summary
private static CoderResult overflow(CharBuffer src, int sp, ByteBuffer dst, int dp)
overflowback to summary
private static CoderResult overflow(CharBuffer src, int mark)
org.glassfish.tyrus.core back to summary

public Class StrictUtf8.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 CoderResult

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CoderResult

Returns:

object describing encountered parse error.
error
()

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

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorback to summary
private CoderResult error

Constructor Detail

Parserback to summary
public Parser()

Method Detail

errorback to summary
public CoderResult error()

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

Returns:CoderResult

object describing encountered parse error.

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