Coverage Report - com.ccg.macros.InputReader
 
Classes in this File Line Coverage Branch Coverage Complexity
InputReader
76% 
67% 
1.5
 
 1  
 /*----------------------------------------------------------------
 2  
  * $Id: InputReader.java,v 1.1.1.1 2004/01/26 20:46:18 pkb Exp $
 3  
  * 
 4  
  * (c)2000 - Paul Blankenbaker
 5  
  *
 6  
  * Revision Log
 7  
  * 
 8  
  *  2000-11-16 10:53:02        Paul Blankenbaker 
 9  
  * 
 10  
  *         Created initial version
 11  
  */
 12  
 //----------------------------------------------------------------
 13  
 
 14  
 package com.ccg.macros;
 15  
 
 16  
 import java.io.*;                // needed for I/O operations
 17  
 
 18  
 //----------------------------------------------------------------
 19  
 /** Describe...
 20  
  * 
 21  
  * <code><pre>
 22  
  * class Example {
 23  
  *   public void main(String[] args) {
 24  
  *     com.ccg.macros.InputReader o = new com.ccg.macros.InputReader();
 25  
  *           System.out.println(o);
 26  
  *   }
 27  
  * }
 28  
  * </pre></code>
 29  
  * 
 30  
  * @version $Revision: 1.1.1.1 $
 31  
  * 
 32  
  * @since 1.0
 33  
  * 
 34  
  * @author $Author: pkb $
 35  
  * 
 36  
  * @see Input */
 37  
 //----------------------------------------------------------------
 38  
 
 39  
 public class InputReader extends Input {
 40  
 
 41  
   //----------------------------------------------------------------
 42  
   /** Initializes object to... It performs the following tasks:
 43  
    * 
 44  
    * <ul><li>Initializes </li>
 45  
    * 
 46  
    * <li></li>
 47  
    * 
 48  
    * </ul>
 49  
    * 
 50  
    * @since        1.0 */
 51  
   //----------------------------------------------------------------
 52  
 
 53  
   public InputReader() {
 54  0
     super();
 55  0
     _in = null;
 56  0
   }
 57  
 
 58  
 
 59  
   public InputReader(Reader r) {
 60  52
     super(new char[2048],2048,2048);
 61  52
     _in = r;
 62  52
   }
 63  
 
 64  
   public InputReader(File f) throws IOException {
 65  2
     this(new FileReader(f));
 66  2
   }
 67  
 
 68  
   public InputReader(InputStream in) {
 69  8
     this(new InputStreamReader(in));
 70  8
   }
 71  
 
 72  
   public void close() throws IOException {
 73  0
     if (_in != null) _in.close();
 74  0
   }
 75  
     
 76  
 
 77  
   int shiftAndFill(int cur_ofs) throws IOException {
 78  
                                 // shift above
 79  122
     int len = super.shiftAndFill(cur_ofs);
 80  
 
 81  
                                 // see if we have room to add more
 82  122
     char[] buf = getBuffer();
 83  
 
 84  
                                 // see if room to read in more
 85  122
     int fetch = buf.length - len;
 86  122
     if ((fetch > 0) && (_in != null)) {
 87  122
       fetch = _in.read(buf,len,fetch);
 88  122
       if (fetch == -1) _in = null;
 89  
       else {
 90  70
         len += fetch;
 91  70
         setLength(len);
 92  
       }
 93  
     }
 94  
 
 95  122
     return len;
 96  
   }
 97  
 
 98  
   private Reader _in;
 99  
 
 100  
 }