Clover coverage report - ActiveIO - 1.0
Coverage timestamp: Fri Apr 22 2005 14:27:22 PDT
file stats: LOC: 98   Methods: 11
NCLOC: 56   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Location.java 50% 63.6% 72.7% 64.9%
coverage coverage
 1   
 /**
 2   
  *
 3   
  * Copyright 2004 Hiram Chirino
 4   
  *
 5   
  * Licensed under the Apache License, Version 2.0 (the "License");
 6   
  * you may not use this file except in compliance with the License.
 7   
  * You may obtain a copy of the License at
 8   
  *
 9   
  * http://www.apache.org/licenses/LICENSE-2.0
 10   
  *
 11   
  * Unless required by applicable law or agreed to in writing, software
 12   
  * distributed under the License is distributed on an "AS IS" BASIS,
 13   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14   
  * See the License for the specific language governing permissions and
 15   
  * limitations under the License.
 16   
  *
 17   
  **/
 18   
 package org.activeio.journal.active;
 19   
 
 20   
 import java.io.DataInput;
 21   
 import java.io.DataOutput;
 22   
 import java.io.IOException;
 23   
 
 24   
 import org.activeio.Packet;
 25   
 import org.activeio.PacketData;
 26   
 import org.activeio.journal.RecordLocation;
 27   
 
 28   
 /**
 29   
  * Defines a where a record can be located in the Journal.
 30   
  * 
 31   
  * @version $Revision: 1.1 $
 32   
  */
 33   
 final public class Location implements RecordLocation {
 34   
     
 35   
     static final public int SERIALIZED_SIZE=8;
 36   
 
 37   
     final private int logFileId;
 38   
     final private int logFileOffset;
 39   
 
 40  94
     public Location(int logFileId, int fileOffset) {
 41  94
         this.logFileId = logFileId;
 42  94
         this.logFileOffset = fileOffset;
 43   
     }
 44   
 
 45  14
     public int compareTo(Object o) {
 46  14
         int rc = logFileId - ((Location) o).logFileId;
 47  14
         if (rc != 0)
 48  0
             return rc;
 49   
 
 50  14
         return logFileOffset - ((Location) o).logFileOffset;
 51   
     }
 52   
 
 53  0
     public int hashCode() {
 54  0
         return logFileOffset ^ logFileId;
 55   
     }
 56   
 
 57  2
     public boolean equals(Object o) {
 58  2
         if (o == null || o.getClass() != Location.class)
 59  0
             return false;
 60  2
         Location rl = (Location) o;
 61  2
         return rl.logFileId == this.logFileId && rl.logFileOffset == this.logFileOffset;
 62   
     }
 63   
 
 64  2
     public String toString() {
 65  2
         return "" + logFileId + ":" + logFileOffset;
 66   
     }
 67   
 
 68  58
     public int getLogFileId() {
 69  58
         return logFileId;
 70   
     }
 71   
 
 72  94
     public int getLogFileOffset() {
 73  94
         return logFileOffset;
 74   
     }
 75   
     
 76  0
     public void writeToPacket(Packet packet) throws IOException {
 77  0
         PacketData data = new PacketData(packet);
 78  0
         data.writeInt(logFileId);
 79  0
         data.writeInt(logFileOffset);
 80   
     }
 81   
 
 82  44
     public void writeToDataOutput(DataOutput data) throws IOException {
 83  44
         data.writeInt(logFileId);
 84  44
         data.writeInt(logFileOffset);
 85   
     }    
 86   
 
 87  0
     static public Location readFromPacket(Packet packet) throws IOException {
 88  0
         PacketData data = new PacketData(packet);
 89  0
         return new Location(data.readInt(), data.readInt());
 90   
     }
 91   
 
 92  30
     public static Location readFromDataInput(DataInput data) throws IOException {
 93  30
         return new Location(data.readInt(), data.readInt());
 94   
     }
 95   
 
 96   
     
 97   
 }
 98