View Javadoc

1   /*
2   	StatCvs - CVS statistics generation 
3   	Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
4   	http://statcvs.sf.net/
5       
6   	This library is free software; you can redistribute it and/or
7   	modify it under the terms of the GNU Lesser General Public
8   	License as published by the Free Software Foundation; either
9   	version 2.1 of the License, or (at your option) any later version.
10  
11  	This library is distributed in the hope that it will be useful,
12  	but WITHOUT ANY WARRANTY; without even the implied warranty of
13  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  	Lesser General Public License for more details.
15  
16  	You should have received a copy of the GNU Lesser General Public
17  	License along with this library; if not, write to the Free Software
18  	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19      
20  	$RCSfile: FilesLocComparator.java,v $
21  	$Date: 2009/08/20 17:44:05 $
22  */
23  package net.sf.statcvs.reports;
24  
25  import java.io.Serializable;
26  import java.util.Comparator;
27  
28  import net.sf.statcvs.model.VersionedFile;
29  
30  /**
31   * Compares two files according to their lines of code
32   * 
33   * @author Richard Cyganiak <rcyg@gmx.de>
34   * @version $Id: FilesLocComparator.java,v 1.4 2009/08/20 17:44:05 benoitx Exp $
35   */
36  public class FilesLocComparator implements Comparator, Serializable {
37  
38      /**
39       * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
40       */
41      public int compare(final Object o1, final Object o2) {
42          final VersionedFile file1 = (VersionedFile) o1;
43          final VersionedFile file2 = (VersionedFile) o2;
44          if (file1.getCurrentLinesOfCode() < file2.getCurrentLinesOfCode()) {
45              return 1;
46          } else if (file1.getCurrentLinesOfCode() == file2.getCurrentLinesOfCode()) {
47              return 0;
48          } else {
49              return -1;
50          }
51      }
52  }