/jEdit/branches/4.3.x-merge-request-2980833/org/gjt/sp/jedit/io/Encoding.java

# · Java · 64 lines · 13 code · 5 blank · 46 comment · 0 complexity · a9b6fb715416ff3a1f34e3a6fd1765f6 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.OutputStream;
  23. import java.io.Reader;
  24. import java.io.Writer;
  25. import java.io.IOException;
  26. /**
  27. * An interface to represent an encoding.
  28. * An encoding is a mapping between a character stream and a byte
  29. * stream. It is like java.nio.charset.Charset but has slightly
  30. * different form. This can represents some extended encodings like
  31. * UTF-8Y which drops (inserts) the BOM bytes before actual decoding
  32. * (encoding). This also enables to add some extended encodings such
  33. * as ASCII representation used by Java property files.
  34. *
  35. * @since 4.3pre10
  36. * @author Kazutoshi Satoda
  37. */
  38. public interface Encoding
  39. {
  40. /**
  41. * Map an InputStream to a Reader.
  42. * Decode-error while reading from this Reader should be reported
  43. * by throwing an IOException.
  44. */
  45. public Reader getTextReader(InputStream in) throws IOException;
  46. /**
  47. * Map an OutputStream to a Writer.
  48. * Encode-error while writing to this Writer should be reported
  49. * by throwing an IOException.
  50. */
  51. public Writer getTextWriter(OutputStream out) throws IOException;
  52. /**
  53. * Map an InputStream to a Reader.
  54. * Decode-error while reading from this Reader should be ignored
  55. * or replaced.
  56. */
  57. public Reader getPermissiveTextReader(InputStream in)
  58. throws IOException;
  59. }