1 9 package com.vladium.emma.report.html.doc; 10 11 import java.io.IOException ; 12 import java.io.Writer ; 13 14 import com.vladium.util.IConstants; 15 import com.vladium.util.asserts.$assert; 16 import com.vladium.emma.IAppErrorCodes; 17 import com.vladium.emma.EMMARuntimeException; 18 19 23 public 24 final class HTMLWriter 25 { 26 28 30 public HTMLWriter (final Writer out) 31 { 32 if (out == null) throw new IllegalArgumentException ("null input: out"); 33 34 m_out = out; 35 } 36 37 38 public void write (final String s) 39 { 40 if ($assert.ENABLED) $assert.ASSERT (s != null, "s = null"); 41 42 if (m_out != null) 43 { 44 try 45 { 46 m_out.write (s); 47 } 48 catch (IOException ioe) 49 { 50 throw new EMMARuntimeException (IAppErrorCodes.REPORT_IO_FAILURE, ioe); 51 } 52 } 53 } 54 55 public void write (final char c) 56 { 57 if (m_out != null) 58 { 59 try 60 { 61 m_out.write (c); 62 } 63 catch (IOException ioe) 64 { 65 throw new EMMARuntimeException (IAppErrorCodes.REPORT_IO_FAILURE, ioe); 66 } 67 } 68 } 69 70 public void eol () 71 { 72 if (m_out != null) 73 { 74 try 75 { 76 m_out.write (IConstants.EOL); 77 } 78 catch (IOException ioe) 79 { 80 throw new EMMARuntimeException (IAppErrorCodes.REPORT_IO_FAILURE, ioe); 81 } 82 } 83 } 84 85 public void flush () 86 { 87 if (m_out != null) 88 { 89 try 90 { 91 m_out.flush (); 92 } 93 catch (IOException ioe) 94 { 95 throw new EMMARuntimeException (IAppErrorCodes.REPORT_IO_FAILURE, ioe); 96 } 97 } 98 } 99 100 public void close () 101 { 102 if (m_out != null) 103 { 104 try { m_out.close (); } catch (IOException ignore) {} 105 m_out = null; 106 } 107 } 108 109 111 113 115 116 private Writer m_out; 117 118 } | Popular Tags |