7623 |
07 Mar 19 |
nicklas |
1 |
package net.sf.basedb.util.charset; |
7623 |
07 Mar 19 |
nicklas |
2 |
|
7623 |
07 Mar 19 |
nicklas |
3 |
import java.io.IOException; |
7623 |
07 Mar 19 |
nicklas |
4 |
|
7623 |
07 Mar 19 |
nicklas |
5 |
/** |
7623 |
07 Mar 19 |
nicklas |
Interface for checking if a text line in a file seems to be decoded correctly |
7623 |
07 Mar 19 |
nicklas |
with the current character set. See the {@link SimpleStringDetector} for a |
7623 |
07 Mar 19 |
nicklas |
simple implementation that can be used to detect the encoding in a datafile |
7623 |
07 Mar 19 |
nicklas |
that contains a header line. |
7623 |
07 Mar 19 |
nicklas |
10 |
|
7623 |
07 Mar 19 |
nicklas |
@author nicklas |
7623 |
07 Mar 19 |
nicklas |
@since 3.15 |
7623 |
07 Mar 19 |
nicklas |
13 |
*/ |
7623 |
07 Mar 19 |
nicklas |
14 |
public interface StringDetector |
7623 |
07 Mar 19 |
nicklas |
15 |
{ |
7623 |
07 Mar 19 |
nicklas |
16 |
|
7623 |
07 Mar 19 |
nicklas |
17 |
/** |
7623 |
07 Mar 19 |
nicklas |
Check the given line. The detector should return TRUE if it |
7623 |
07 Mar 19 |
nicklas |
can be certain that the file has been decoded correctly. |
7623 |
07 Mar 19 |
nicklas |
If it can be sure that the file has been decoded incorrecty |
7623 |
07 Mar 19 |
nicklas |
it should throw an IOException. If the detector is not sure |
7623 |
07 Mar 19 |
nicklas |
without more data, it should return false. |
7623 |
07 Mar 19 |
nicklas |
23 |
*/ |
7623 |
07 Mar 19 |
nicklas |
24 |
public boolean checkLine(int lineNo, String line) |
7623 |
07 Mar 19 |
nicklas |
25 |
throws IOException; |
7623 |
07 Mar 19 |
nicklas |
26 |
|
7623 |
07 Mar 19 |
nicklas |
27 |
/** |
7623 |
07 Mar 19 |
nicklas |
This is called when the end of file has been reached and the checkLine |
7623 |
07 Mar 19 |
nicklas |
method has returned false for all lines. If this is considered to be an |
7623 |
07 Mar 19 |
nicklas |
incorrect decoding condition, the detector should throw an IOException, |
7623 |
07 Mar 19 |
nicklas |
otherwise it should simply return. Note that this method is not called |
7623 |
07 Mar 19 |
nicklas |
if TRUE is returned from the checkLine method. |
7623 |
07 Mar 19 |
nicklas |
33 |
*/ |
7623 |
07 Mar 19 |
nicklas |
34 |
public void eof(int parsedLines) |
7623 |
07 Mar 19 |
nicklas |
35 |
throws IOException; |
7623 |
07 Mar 19 |
nicklas |
36 |
|
7623 |
07 Mar 19 |
nicklas |
37 |
} |