1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
4 * This program 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.
9 * This program 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com
.owncloud
.android
.utils
;
21 public class OwnCloudVersion
implements Comparable
<OwnCloudVersion
> {
22 public static final OwnCloudVersion owncloud_v1
= new OwnCloudVersion(
24 public static final OwnCloudVersion owncloud_v2
= new OwnCloudVersion(
26 public static final OwnCloudVersion owncloud_v3
= new OwnCloudVersion(
28 public static final OwnCloudVersion owncloud_v4
= new OwnCloudVersion(
31 // format is in version
33 // for version AA.BB.CC
34 // ie version 3.0.3 will be stored as 0x030003
36 private boolean mIsValid
;
38 public OwnCloudVersion(int version
) {
43 public OwnCloudVersion(String version
) {
46 parseVersionString(version
);
49 public String
toString() {
50 return ((mVersion
>> 16) % 256) + "." + ((mVersion
>> 8) % 256) + "."
54 public boolean isVersionValid() {
59 public int compareTo(OwnCloudVersion another
) {
60 return another
.mVersion
== mVersion ?
0
61 : another
.mVersion
< mVersion ?
1 : -1;
64 private void parseVersionString(String version
) {
66 String
[] nums
= version
.split("\\.");
67 if (nums
.length
> 0) {
68 mVersion
+= Integer
.parseInt(nums
[0]);
70 mVersion
= mVersion
<< 8;
71 if (nums
.length
> 1) {
72 mVersion
+= Integer
.parseInt(nums
[1]);
74 mVersion
= mVersion
<< 8;
75 if (nums
.length
> 2) {
76 mVersion
+= Integer
.parseInt(nums
[2]);
79 } catch (Exception e
) {