01: /*
02: * :tabSize=8:indentSize=8:noTabs=false:
03: * :folding=explicit:collapseFolds=1:
04: *
05: * Copyright (C) 2007 Kazutoshi Satoda
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or any later version.
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: */
20:
21: package org.gjt.sp.jedit.io;
22:
23: import java.io.InputStream;
24: import java.io.IOException;
25:
26: /**
27: * An interface to detect a reasonable encoding from some bytes at the
28: * beginning of a file. To offer your own EncodingDetector, implement this
29: * interface and define a service in your <tt>services.xml</tt> file.
30: * For example:<pre>
31: <SERVICE CLASS="org.gjt.sp.jedit.io.EncodingDetector" NAME="XML-PI">
32: new XMLEncodingDetector();
33: </SERVICE> </pre>
34: *
35: * @since 4.3pre10
36: * @author Kazutoshi Satoda
37: */
38: public interface EncodingDetector {
39: /**
40: * Returns the name of a detected encoding for the bytes in sample.
41: * Returns null if this instance could not detect reasonable one.
42: */
43: public String detectEncoding(InputStream sample) throws IOException;
44: }
|