Coverage Report - org.galagosearch.tupleflow.VByteInput
 
Classes in this File Line Coverage Branch Coverage Complexity
VByteInput
35%
16/46
30%
3/10
1.353
 
 1  
 // BSD License (http://www.galagosearch.org/license)
 2  
 package org.galagosearch.tupleflow;
 3  
 
 4  
 import java.io.DataInput;
 5  
 import java.io.IOException;
 6  
 
 7  
 /**
 8  
  *
 9  
  * @author trevor
 10  
  */
 11  2
 public class VByteInput implements DataInput {
 12  
     DataInput input;
 13  
 
 14  2
     public VByteInput(DataInput input) {
 15  2
         this.input = input;
 16  2
     }
 17  
 
 18  
     public void readFully(byte[] b, int i, int i0) throws IOException {
 19  0
         input.readFully(b, i, i0);
 20  0
     }
 21  
 
 22  
     public void readFully(byte[] b) throws IOException {
 23  0
         input.readFully(b);
 24  0
     }
 25  
     
 26  
     public String readString() throws IOException {
 27  2
         int length = readInt();
 28  2
         byte[] data = new byte[length];
 29  2
         input.readFully(data);
 30  2
         return Utility.makeString(data);
 31  
     }
 32  
 
 33  
     public int skipBytes(int i) throws IOException {
 34  0
         return input.skipBytes(i);
 35  
     }
 36  
 
 37  
     public int readUnsignedShort() throws IOException {
 38  0
         int result = readInt();
 39  0
         return (int) (result & 0xffff);
 40  
     }
 41  
 
 42  
     public boolean readBoolean() throws IOException {
 43  0
         int result = readInt();
 44  0
         return result != 0 ? true : false;
 45  
     }
 46  
 
 47  
     public byte readByte() throws IOException {
 48  0
         int result = readInt();
 49  0
         return (byte) (result & 0xff);
 50  
     }
 51  
 
 52  
     public char readChar() throws IOException {
 53  0
         int result = readInt();
 54  0
         return (char) (result & 0xffff);
 55  
     }
 56  
 
 57  
     public double readDouble() throws IOException {
 58  0
         long result = input.readLong();
 59  0
         return Double.longBitsToDouble(result);
 60  
     }
 61  
 
 62  
     public float readFloat() throws IOException {
 63  0
         int result = input.readInt();
 64  0
         return Float.intBitsToFloat(result);
 65  
     }
 66  
 
 67  
     public int readInt() throws IOException {
 68  2
         int result = 0;
 69  
         int b;
 70  
 
 71  2
         for (int position = 0; true; position++) {
 72  2
             assert position < 6;
 73  2
             b = input.readUnsignedByte();
 74  
 
 75  2
             if ((b & 0x80) == 0x80) {
 76  2
                 result |= ((b & 0x7f) << (7 * position));
 77  2
                 break;
 78  
             } else {
 79  0
                 result |= (b << (7 * position));
 80  
             }
 81  
         }
 82  
 
 83  2
         return result;
 84  
     }
 85  
 
 86  
     public long readLong() throws IOException {
 87  0
         long result = 0;
 88  
         long b;
 89  
 
 90  0
         for (int position = 0; true; position++) {
 91  0
             b = input.readUnsignedByte();
 92  
 
 93  0
             if ((b & 0x80) == 0x80) {
 94  0
                 result |= ((long) (b & 0x7f) << (7 * position));
 95  0
                 break;
 96  
             } else {
 97  0
                 result |= ((long) b << (7 * position));
 98  
             }
 99  
         }
 100  
 
 101  0
         return result;
 102  
     }
 103  
 
 104  
     public String readLine() throws IOException {
 105  0
         throw new IOException("Operation not supported.");
 106  
     }
 107  
 
 108  
     public short readShort() throws IOException {
 109  0
         return (short) (readInt() & 0xffff);
 110  
     }
 111  
 
 112  
     public String readUTF() throws IOException {
 113  0
         throw new IOException("Operation not supported.");
 114  
     }
 115  
 
 116  
     public int readUnsignedByte() throws IOException {
 117  0
         return (readInt() & 0xff);
 118  
     }
 119  
 }