Coverage report

  %line %branch
org.apache.jcs.auxiliary.disk.indexed.IndexedDiskElementDescriptor
72% 
95% 

 1  
 package org.apache.jcs.auxiliary.disk.indexed;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.Serializable;
 23  
 
 24  
 /**
 25  
  * Disk objects are located by descriptor entries. These are saved on shutdown and loaded into
 26  
  * memory on startup.
 27  
  */
 28  
 public class IndexedDiskElementDescriptor
 29  
     implements Serializable, Comparable
 30  
 {
 31  
     private static final long serialVersionUID = -3029163572847659450L;
 32  
 
 33  
     /** Position of the cache data entry on disk. */
 34  
     long pos;
 35  
 
 36  
     /** Number of bytes the serialized form of the cache data takes. */
 37  
     public int len;
 38  
 
 39  
     /**
 40  
      * Set the offset (i.e. position, and the size of the element)
 41  
      * <p>
 42  
      * @param pos
 43  
      * @param data
 44  
      */
 45  
     public void init( long pos, byte[] data )
 46  
     {
 47  0
         this.pos = pos;
 48  0
         this.len = data.length;
 49  0
     }
 50  
 
 51  
     /** Constructor for the DiskElementDescriptor object */
 52  
     public IndexedDiskElementDescriptor()
 53  
     {
 54  0
         super();
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Constructs a usable disk element descriptor.
 59  
      * <p>
 60  
      * @param pos
 61  
      * @param len
 62  
      */
 63  
     public IndexedDiskElementDescriptor( long pos, int len )
 64  245151
     {
 65  245156
         this.pos = pos;
 66  245124
         this.len = len;
 67  245168
     }
 68  
 
 69  
     public String toString()
 70  
     {
 71  8
         StringBuffer buf = new StringBuffer();
 72  8
         buf.append( "[DED: " );
 73  8
         buf.append( " pos = " + pos );
 74  8
         buf.append( " len = " + len );
 75  8
         buf.append( "]" );
 76  8
         return buf.toString();
 77  
     }
 78  
 
 79  
     /**
 80  
      * Compares based on length.
 81  
      * <p>
 82  
      * @param o Object
 83  
      * @return int
 84  
      */
 85  
     public int compareTo( Object o )
 86  
     {
 87  1068700
         if ( o == null )
 88  
         {
 89  0
             return 1;
 90  
         }
 91  
 
 92  1069281
         int oLen = ( (IndexedDiskElementDescriptor) o ).len;
 93  1069323
         if ( oLen == len )
 94  
         {
 95  268141
             return 0;
 96  
         }
 97  801066
         else if ( oLen > len )
 98  
         {
 99  264132
             return -1;
 100  
         }
 101  536619
         else if ( oLen < len )
 102  
         {
 103  536937
             return 1;
 104  
         }
 105  0
         return 0;
 106  
     }
 107  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.