Class LCSDetectionInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- oracle.i18n.lcsd.LCSDetectionInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
LCSDetectionHTMLInputStream
public class LCSDetectionInputStream extends FilterInputStream
TheLCSDetectionInputStreamclass is the language and character detector stream class that transparently detects the language and character set for the stream object.The output of
readmethods are the original contents of the input stream in its original state. If the character set conversion using the detected character set is needed, use theLCSDetectionReaderclass. If the input stream includes the HTML contents, use theLCSDetectionHTMLInputStreamclass or theLCSDetectionHTMLReaderclass. TheLCSDetectionInputStreamclass is used to determine the language and character set information used in the content.- Since:
- 10.2
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_SAMPLING_SIZEDefault buffer size for the dual stream objects.-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description LCSDetectionInputStream(InputStream in)Constructs the default LCS Detector input stream object.LCSDetectionInputStream(InputStream in, int size)Constructs the default LCS Detector input stream object with the sampling length.LCSDetectionInputStream(String profile, InputStream in)Constructs the LCS Detector input stream object using the specified LCSD profile.LCSDetectionInputStream(String profile, InputStream in, int size)Constructs the LCS Detector input stream object using the specified LCSD profile, input stream object, and sampling length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LCSDResultSetgetResult()Returns the result set of LCSD.intread()Reads the next byte of data from the input stream.intread(byte[] b)Reads some number of bytes from the input stream and stores them into the buffer arrayb.intread(byte[] b, int off, int len)Reads up tolenbytes of data from the input stream into an array of bytes.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
DEFAULT_SAMPLING_SIZE
protected static final int DEFAULT_SAMPLING_SIZE
Default buffer size for the dual stream objects.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LCSDetectionInputStream
public LCSDetectionInputStream(InputStream in) throws IOException, UTFDataFormatException
Constructs the default LCS Detector input stream object.- Parameters:
in- the input stream to be sampled by the detector- Throws:
IOException- if any I/O error occursUTFDataFormatException- if an UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
LCSDetectionInputStream
public LCSDetectionInputStream(InputStream in, int size) throws IOException, UTFDataFormatException
Constructs the default LCS Detector input stream object with the sampling length.- Parameters:
in- the input stream to be sampled by the detectorsize- the sampling size- Throws:
IOException- if any I/O error occursUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
LCSDetectionInputStream
public LCSDetectionInputStream(String profile, InputStream in) throws IOException, UTFDataFormatException
Constructs the LCS Detector input stream object using the specified LCSD profile.- Parameters:
profile- the LCSD profile name. Specifynullfor the default profile.in- the input stream to be sampled by the detector- Throws:
IOException- if any I/O error occursUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
LCSDetectionInputStream
public LCSDetectionInputStream(String profile, InputStream in, int size) throws IOException, UTFDataFormatException
Constructs the LCS Detector input stream object using the specified LCSD profile, input stream object, and sampling length.The sampling is performed for the specified length. The detection result does not change until the read operation exceeds the specified length. Each minimum data length will be sampled afterwards.
- Parameters:
profile- the LCSD profile name. Specifynullfor the default profile.in- the input stream to be sampled by the detectorsize- the sampling length- Throws:
IOException- if any I/O error occursUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
-
Method Detail
-
getResult
public LCSDResultSet getResult() throws IOException, EOFException, UTFDataFormatException
Returns the result set of LCSD.If your application requires information about the language, the character set, or both, call this method.
- Returns:
- The result set of LCSD.
- Throws:
IOException- if an I/O error occursEOFException- if the stream ends unexpectedlyUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
read
public int read() throws IOException, UTFDataFormatExceptionReads the next byte of data from the input stream.- Overrides:
readin classFilterInputStream- Returns:
- The next byte of data, or
-1if the end of the stream is reached. - Throws:
IOException- if an I/O error occursUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
read
public int read(byte[] b) throws IOException, UTFDataFormatExceptionReads some number of bytes from the input stream and stores them into the buffer arrayb.- Overrides:
readin classFilterInputStream- Parameters:
b- the buffer into which the data is read- Returns:
- The total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occursUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
read
public int read(byte[] b, int off, int len) throws IOException, UTFDataFormatExceptionReads up tolenbytes of data from the input stream into an array of bytes.- Overrides:
readin classFilterInputStream- Parameters:
b- the buffer into which the data is readoff- the start offset in arraybto where the data is writtenlen- the maximum number of bytes to read- Returns:
- The total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occursUTFDataFormatException- if an invalid UTF-8 data sequence is detected. Note this occurs only if the source is UTF-8 data.
-
-