PageRenderTime 209ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/cldc/src/javaapi/cldc1.0/com/sun/cldc/i18n/j2me/ISO8859_1_Writer.java

http://github.com/borman/phoneme-qtopia
Java | 88 lines | 24 code | 8 blank | 56 comment | 2 complexity | 3c1e2db2e88596ab3f968f120481568b MD5 | raw file
  1. /*
  2. *
  3. *
  4. * Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
  5. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
  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 version
  9. * 2 only, as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License version 2 for more details (a copy is
  15. * included at /legal/license.txt).
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * version 2 along with this work; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
  23. * Clara, CA 95054 or visit www.sun.com if you need additional
  24. * information or have any questions.
  25. */
  26. package com.sun.cldc.i18n.j2me;
  27. import java.io.*;
  28. import com.sun.cldc.i18n.*;
  29. /**
  30. * Default class for writing output streams.
  31. *
  32. * @version 1.0 10/18/99
  33. */
  34. public class ISO8859_1_Writer extends StreamWriter {
  35. /**
  36. * Write a single character.
  37. *
  38. * @exception IOException If an I/O error occurs
  39. */
  40. synchronized public void write(int c) throws IOException {
  41. if(c > 255) {
  42. c = '?'; // was ----> throw new RuntimeException("Unknown character "+c);
  43. }
  44. out.write(c);
  45. }
  46. /**
  47. * Write a portion of an array of characters.
  48. *
  49. * @param cbuf Buffer of characters to be written
  50. * @param off Offset from which to start reading characters
  51. * @param len Number of characters to be written
  52. *
  53. * @exception IOException If an I/O error occurs
  54. */
  55. synchronized public void write(char cbuf[], int off, int len) throws IOException {
  56. while(len-- > 0) {
  57. write(cbuf[off++]);
  58. }
  59. }
  60. /**
  61. * Write a portion of a string.
  62. *
  63. * @param str String to be written
  64. * @param off Offset from which to start reading characters
  65. * @param len Number of characters to be written
  66. *
  67. * @exception IOException If an I/O error occurs
  68. */
  69. synchronized public void write(String str, int off, int len) throws IOException {
  70. for (int i = 0 ; i < len ; i++) {
  71. write(str.charAt(off + i));
  72. }
  73. }
  74. /**
  75. * Get the size in bytes of an array of chars
  76. */
  77. public int sizeOf(char[] array, int offset, int length) {
  78. return length;
  79. }
  80. }