Coverage Report - com.buckosoft.PicMan.util.SetsCRC
 
Classes in this File Line Coverage Branch Coverage Complexity
SetsCRC
0%
0/21
0%
0/14
4.5
 
 1  
 /******************************************************************************
 2  
  * SetsCRC.java - Calculate a CRC of the Sets
 3  
  * 
 4  
  * PicManService - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2008 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.util;
 9  
 
 10  
 import com.buckosoft.PicMan.domain.Set;
 11  
 
 12  
 /** Calculate a CRC of the Sets.
 13  
  * This is used between the client and service to determine if sets have changed and need sync.
 14  
  * @author Dick Balaska
 15  
  * @since 2008/11/11
 16  
  * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicManService/src/com/buckosoft/PicMan/util/SetsCRC.java">SetsCRC.java</a>
 17  
  */
 18  0
 public class SetsCRC {
 19  
 
 20  0
         private        long        crc = 0;
 21  
         
 22  
         public long getCRC() {
 23  0
                 return(crc);
 24  
         }
 25  
 
 26  
         public void addSet(Set set) {
 27  0
                 int x = 1;
 28  
                 int i;
 29  0
                 for (i=0; i<set.getName().length(); i++) {
 30  0
                         int c = set.getName().charAt(i);
 31  0
                         crc += c*x;
 32  0
                         if (x++ > 5)
 33  0
                                 x = 1;
 34  
                 }
 35  0
                 for (i=0; i<set.getDescription().length(); i++) {
 36  0
                         int c = set.getDescription().charAt(i);
 37  0
                         crc += c*x;
 38  0
                         if (x++ > 5)
 39  0
                                 x = 1;
 40  
                 }
 41  0
                 if (set.isMetaSet())
 42  0
                         crc += x;
 43  0
                 x++;
 44  0
                 if (set.isMicroSet() || set.isNanoSet())
 45  0
                         crc += x;
 46  0
                 x++;
 47  
                 
 48  0
         }
 49  
 }