Clover Coverage Report - Subsonic-Android Coverage Report
Coverage timestamp: ven dic 19 2014 17:57:13 EST
../../../../../img/srcFileCovDistChart2.png 83% of files have more coverage
53   142   27   7,57
38   77   0,51   7
7     3,86  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  Version       Line # 27 53 27 20,4% 0.20408164
 
No Tests
 
1    /*
2    This file is part of Subsonic.
3   
4    Subsonic is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8   
9    Subsonic is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12    GNU General Public License for more details.
13   
14    You should have received a copy of the GNU General Public License
15    along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
16   
17    Copyright 2009 (C) Sindre Mehus
18    */
19    package net.sourceforge.subsonic.androidapp.domain;
20   
21    /**
22    * Represents the version number of the Subsonic Android app.
23    *
24    * @author Sindre Mehus
25    * @version $Revision: 1.3 $ $Date: 2006/01/20 21:25:16 $
26    */
 
27    public class Version implements Comparable<Version> {
28    private int major;
29    private int minor;
30    private int beta;
31    private int bugfix;
32   
33    /**
34    * Creates a new version instance by parsing the given string.
35    * @param version A string of the format "1.27", "1.27.2" or "1.27.beta3".
36    */
 
37  46 toggle public Version(String version) {
38  46 String[] s = version.split("\\.");
39  46 major = Integer.valueOf(s[0]);
40  46 minor = Integer.valueOf(s[1]);
41   
42  46 if (s.length > 2) {
43  37 if (s[2].contains("beta")) {
44  0 beta = Integer.valueOf(s[2].replace("beta", ""));
45    } else {
46  37 bugfix = Integer.valueOf(s[2]);
47    }
48    }
49    }
50   
 
51  0 toggle public int getMajor() {
52  0 return major;
53    }
54   
 
55  0 toggle public int getMinor() {
56  0 return minor;
57    }
58   
59    /**
60    * Return whether this object is equal to another.
61    * @param o Object to compare to.
62    * @return Whether this object is equals to another.
63    */
 
64  0 toggle public boolean equals(Object o) {
65  0 if (this == o) return true;
66  0 if (o == null || getClass() != o.getClass()) return false;
67   
68  0 final Version version = (Version) o;
69   
70  0 if (beta != version.beta) return false;
71  0 if (bugfix != version.bugfix) return false;
72  0 if (major != version.major) return false;
73  0 return minor == version.minor;
74    }
75   
76    /**
77    * Returns a hash code for this object.
78    * @return A hash code for this object.
79    */
 
80  0 toggle public int hashCode() {
81  0 int result;
82  0 result = major;
83  0 result = 29 * result + minor;
84  0 result = 29 * result + beta;
85  0 result = 29 * result + bugfix;
86  0 return result;
87    }
88   
89    /**
90    * Returns a string representation of the form "1.27", "1.27.2" or "1.27.beta3".
91    * @return A string representation of the form "1.27", "1.27.2" or "1.27.beta3".
92    */
 
93  0 toggle public String toString() {
94  0 StringBuffer buf = new StringBuffer();
95  0 buf.append(major).append('.').append(minor);
96  0 if (beta != 0) {
97  0 buf.append(".beta").append(beta);
98  0 } else if (bugfix != 0) {
99  0 buf.append('.').append(bugfix);
100    }
101   
102  0 return buf.toString();
103    }
104   
105    /**
106    * Compares this object with the specified object for order.
107    * @param version The object to compare to.
108    * @return A negative integer, zero, or a positive integer as this object is less than, equal to, or
109    * greater than the specified object.
110    */
 
111  9 toggle @Override
112    public int compareTo(Version version) {
113  9 if (major < version.major) {
114  0 return -1;
115  9 } else if (major > version.major) {
116  0 return 1;
117    }
118   
119  9 if (minor < version.minor) {
120  0 return -1;
121  9 } else if (minor > version.minor) {
122  9 return 1;
123    }
124   
125  0 if (bugfix < version.bugfix) {
126  0 return -1;
127  0 } else if (bugfix > version.bugfix) {
128  0 return 1;
129    }
130   
131  0 int thisBeta = beta == 0 ? Integer.MAX_VALUE : beta;
132  0 int otherBeta = version.beta == 0 ? Integer.MAX_VALUE : version.beta;
133   
134  0 if (thisBeta < otherBeta) {
135  0 return -1;
136  0 } else if (thisBeta > otherBeta) {
137  0 return 1;
138    }
139   
140  0 return 0;
141    }
142    }