Clover coverage report - Clover results for XOM 1.2d1
Coverage timestamp: Wed Feb 8 2006 08:31:33 EST
file stats: LOC: 88   Methods: 8
NCLOC: 46   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UnsynchronizedBufferedWriter.java 100% 90.5% 75% 89.2%
coverage coverage
 1    /* Copyright 2002-2005 Elliotte Rusty Harold
 2   
 3    This library is free software; you can redistribute it and/or modify
 4    it under the terms of version 2.1 of the GNU Lesser General Public
 5    License as published by the Free Software Foundation.
 6   
 7    This library is distributed in the hope that it will be useful,
 8    but WITHOUT ANY WARRANTY; without even the implied warranty of
 9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 10    GNU Lesser General Public License for more details.
 11   
 12    You should have received a copy of the GNU Lesser General Public
 13    License along with this library; if not, write to the
 14    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 15    Boston, MA 02111-1307 USA
 16   
 17    You can contact Elliotte Rusty Harold by sending e-mail to
 18    elharo@metalab.unc.edu. Please include the word "XOM" in the
 19    subject line. The XOM home page is located at http://www.xom.nu/
 20    */
 21    package nu.xom;
 22   
 23    import java.io.IOException;
 24    import java.io.Writer;
 25   
 26    final class UnsynchronizedBufferedWriter extends Writer {
 27   
 28    private final static int CAPACITY = 8192;
 29    private char[] buffer = new char[CAPACITY];
 30    private int position = 0;
 31    private Writer out;
 32   
 33   
 34  19228 public UnsynchronizedBufferedWriter(Writer out) {
 35  19228 this.out = out;
 36    }
 37   
 38   
 39  0 public void write(char[] buffer, int offset, int length) throws IOException {
 40  0 throw new UnsupportedOperationException("XOM bug: this statement shouldn't be reachable.");
 41    }
 42   
 43   
 44  2803384 public void write(String s) throws IOException {
 45  2803384 write(s, 0, s.length());
 46    }
 47   
 48   
 49  2803384 public void write(String s, int offset, int length) throws IOException {
 50   
 51  2803384 while (length > 0) {
 52  2767044 int n = Math.min(CAPACITY - position, length);
 53  2767044 s.getChars(offset, offset + n, buffer, position);
 54  2767044 position += n;
 55  2767044 offset += n;
 56  2767044 length -= n;
 57  1854 if (position >= CAPACITY) flushInternal();
 58    }
 59   
 60    }
 61   
 62   
 63  30625142 public void write(int c) throws IOException {
 64  3203 if (position >= CAPACITY) flushInternal();
 65  30625142 buffer[position] = (char) c;
 66  30625142 position++;
 67    }
 68   
 69   
 70  37703 public void flush() throws IOException {
 71  37703 flushInternal();
 72  37703 out.flush();
 73    }
 74   
 75   
 76  42760 private void flushInternal() throws IOException {
 77  42760 if (position != 0) {
 78  24267 out.write(buffer, 0, position);
 79  24267 position = 0;
 80    }
 81    }
 82   
 83   
 84  0 public void close() throws IOException {
 85  0 throw new UnsupportedOperationException("How;d we get here?");
 86    }
 87   
 88    }