forked from DeBortoliWines/openerp-java-api
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathVersion.java
More file actions
98 lines (84 loc) · 2.33 KB
/
Copy pathVersion.java
File metadata and controls
98 lines (84 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright 2013-2014 De Bortoli Wines Pty Limited (Australia)
*
* This file is part of OpenERPJavaAPI.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.odoojava.api;
/**
* Breaks up the OpenERP server version into a major, minor and build number
* @author Pieter van der Merwe
* @since May 30, 2013
*/
public class Version {
private final String full_version;
private final int major;
private final int minor;
private final String build;
public Version(String version){
this.full_version = version;
int build_separator_idx = version.indexOf("-");
String major_minor = version;
// If there is a build number
if (build_separator_idx >= 0 && version.length() > 1){
major_minor = version.substring(0,build_separator_idx);
this.build = version.substring(build_separator_idx + 1);
}
else this.build = "0";
String[] major_minor_obj = major_minor.split("\\.");
int maj = -1;
try{
maj = Integer.parseInt(major_minor_obj[0]);
}
catch(Exception e){
maj = -1;
}
this.major = maj;
int min = -1;
try{
if (major_minor_obj.length > 1)
min = Integer.parseInt(major_minor_obj[1]);
}
catch(Exception e){
min = -1;
}
this.minor = min;
}
/**
* Get the major version of the OpenERP version string
* @return Major version number
*/
public int getMajor() {
return major;
}
/**
* Get the minor version of the OpenERP version string
* @return Minor version number
*/
public int getMinor() {
return minor;
}
/**
* Get the build number of the OpenERP version string
* @return Build number
*/
public String getBuild() {
return build;
}
@Override
public String toString() {
return this.full_version;
}
}