Package oracle.i18n.text
Class UTF8ValidationFilter
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.BufferedInputStream
-
- oracle.i18n.text.UTF8ValidationFilter
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class UTF8ValidationFilter extends BufferedInputStream
TheUTF8ValidationFilterclass is used to check the illegal UTF-8 byte sequence to replace with the replacement character U+FFFD or raise an exception.The validation occurs transparently for the users. The output has the same contents as the input if an invalid UTF-8 sequence is not found. If an invalid UTF-8 sequence is found and
UTF8ValidationFilter.ValidationBehavior.REPLACEis specified as the conversion behavior, the output will include U+FFFD, or 0xef, 0xbf, 0xbd in UTF-8 encoding where the problem occurs. By default, the illegal UTF-8 sequence is reported by the exceptionUTFDataFormatException.- Since:
- 10.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUTF8ValidationFilter.ValidationBehaviorTheValidationBehaviorclass is the class used to determine the behavior in case the conversion fails.
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description UTF8ValidationFilter(InputStream in)Constructs the object with theInputStreamobject.UTF8ValidationFilter(InputStream in, int size)Constructs the object with theInputStreamobject with the buffer size.UTF8ValidationFilter(InputStream in, int size, UTF8ValidationFilter.ValidationBehavior action)Constructs the object with theInputStreamobject with the buffer size and the validation behavior.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intread()Reads one byte.intread(byte[] b, int off, int len)Reads the byte array.-
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, reset, skip
-
Methods inherited from class java.io.FilterInputStream
read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
UTF8ValidationFilter
public UTF8ValidationFilter(InputStream in)
Constructs the object with theInputStreamobject.- Parameters:
in- theInputStreamobject
-
UTF8ValidationFilter
public UTF8ValidationFilter(InputStream in, int size)
Constructs the object with theInputStreamobject with the buffer size.- Parameters:
in- theInputStreamobjectsize- the buffer size
-
UTF8ValidationFilter
public UTF8ValidationFilter(InputStream in, int size, UTF8ValidationFilter.ValidationBehavior action)
Constructs the object with theInputStreamobject with the buffer size and the validation behavior.- Parameters:
in- theInputStreamobjectsize- the buffer sizeaction- specifies the error action to be eitherREPLACEorREPORT
-
-
Method Detail
-
read
public int read() throws UTFDataFormatException, IOExceptionReads one byte.- Overrides:
readin classBufferedInputStream- Returns:
- a byte from the input stream
- Throws:
UTFDataFormatException- if any illegal UTF-8 sequence is foundIOException- if any other I/O error occurs
-
read
public int read(byte[] b, int off, int len) throws UTFDataFormatException, IOExceptionReads the byte array.- Overrides:
readin classBufferedInputStream- Parameters:
b- bufferoff- offsetlen- length- Returns:
- the number of bytes copied
- Throws:
UTFDataFormatException- if any illegal UTF-8 sequence is foundIOException- if any other I/O error occurs
-
-