1 /*
2 * (C) Copyright 2013-2014 Nuxeo SA (http://nuxeo.com/) and contributors.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the GNU Lesser General Public License
6 * (LGPL) version 2.1 which accompanies this distribution, and is available at
7 * http://www.gnu.org/licenses/lgpl-2.1.html
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * Contributors:
15 * jcarsique
16 */
17 package org.nuxeo.build.ant;
18
19 /**
20 * Bridge to {@link org.nuxeo.connect.update.Version}.
21 *
22 * @see #parse(String) for fallback in case of parse error
23 */
24 public class Version extends org.nuxeo.connect.update.Version {
25
26 /**
27 * Prefer use of {@link #parse(String)}
28 *
29 * @param version
30 */
31 protected Version(String version) {
32 super(version);
33 }
34
35 public Version(int major) {
36 super(major);
37 }
38
39 public Version(int major, int minor) {
40 super(major, minor);
41 }
42
43 public Version(int major, int minor, int patch) {
44 super(major, minor, patch);
45 }
46
47 public Version(int major, int minor, int patch, String classifier) {
48 super(major, minor, patch, classifier);
49 }
50
51 /**
52 * Fallback on {@link OldVersion} in case of parsing error (
53 * {@link OldVersion} was more tolerant even if not compliant with Nuxeo
54 * versioning).
55 */
56 @SuppressWarnings("deprecation")
57 public static Version parse(String string) {
58 Version version;
59 try {
60 version = new Version(string);
61 } catch (NumberFormatException e) {
62 OldVersion oldVersion = new OldVersion(string);
63 version = new Version(oldVersion.major, oldVersion.minor,
64 oldVersion.patch, oldVersion.classifier);
65 }
66 return version;
67 }
68
69 }