src/core/net/sf/basedb/util/charset/StringDetector.java

Code
Comments
Other
Rev Date Author Line
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 6   Interface for checking if a text line in a file seems to be decoded correctly
7623 07 Mar 19 nicklas 7   with the current character set. See the {@link SimpleStringDetector} for a
7623 07 Mar 19 nicklas 8   simple implementation that can be used to detect the encoding in a datafile
7623 07 Mar 19 nicklas 9   that contains a header line.
7623 07 Mar 19 nicklas 10   
7623 07 Mar 19 nicklas 11   @author nicklas
7623 07 Mar 19 nicklas 12   @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 18     Check the given line. The detector should return TRUE if it
7623 07 Mar 19 nicklas 19     can be certain that the file has been decoded correctly. 
7623 07 Mar 19 nicklas 20     If it can be sure that the file has been decoded incorrecty
7623 07 Mar 19 nicklas 21     it should throw an IOException. If the detector is not sure 
7623 07 Mar 19 nicklas 22     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 28     This is called when the end of file has been reached and the checkLine
7623 07 Mar 19 nicklas 29     method has returned false for all lines. If this is considered to be an
7623 07 Mar 19 nicklas 30     incorrect decoding condition, the detector should throw an IOException,
7623 07 Mar 19 nicklas 31     otherwise it should simply return. Note that this method is not called
7623 07 Mar 19 nicklas 32     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 }