public class Utf8Validator
extends java.lang.Object
Implements the algorithm "Flexible and Economical UTF-8 Decoder" by Bjoern Hoehrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/).
| Constructor and Description |
|---|
Utf8Validator()
Create new incremental UTF-8 validator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isValid()
Check if incremental validation (currently) has ended on
a complete encoded Unicode codepoint.
|
int |
position()
Get end of validated position within stream.
|
void |
reset()
Reset validator state to begin validation of new
UTF-8 stream.
|
boolean |
validate(byte[] data)
Validate a chunk of octets for UTF-8.
|
boolean |
validate(byte[] data,
int off,
int len)
Validate a chunk of octets for UTF-8.
|
public Utf8Validator()
public void reset()
public int position()
public boolean isValid()
public boolean validate(byte[] data,
int off,
int len)
data - Buffer which contains chunk to validate.off - Offset within buffer where to continue with validation.len - Length in octets to validate within buffer.public boolean validate(byte[] data)
data - Buffer which contains chunk to validate.