/jEdit/tags/jedit-4-3-pre15/org/gjt/sp/jedit/io/EncodingDetector.java

# · Java · 45 lines · 7 code · 3 blank · 35 comment · 0 complexity · ad8e752cf5555db414248ace5f3e7a2f MD5 · raw file

  1. /*
  2. * :tabSize=8:indentSize=8:noTabs=false:
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * Copyright (C) 2007 Kazutoshi Satoda
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * 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. package org.gjt.sp.jedit.io;
  21. import java.io.InputStream;
  22. import java.io.IOException;
  23. /**
  24. * An interface to detect a reasonable encoding from some bytes at the
  25. * beginning of a file. To offer your own EncodingDetector, implement this
  26. * interface and define a service in your <tt>services.xml</tt> file.
  27. * For example:<pre>
  28. &lt;SERVICE CLASS=&quot;org.gjt.sp.jedit.io.EncodingDetector&quot; NAME=&quot;XML-PI&quot;&gt;
  29. new XMLEncodingDetector();
  30. &lt;/SERVICE&gt; </pre>
  31. *
  32. * @since 4.3pre10
  33. * @author Kazutoshi Satoda
  34. */
  35. public interface EncodingDetector
  36. {
  37. /**
  38. * Returns the name of a detected encoding for the bytes in sample.
  39. * Returns null if this instance could not detect reasonable one.
  40. */
  41. public String detectEncoding(InputStream sample) throws IOException;
  42. }