svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / extension / Version.java @ 39065
History | View | Annotate | Download (3.01 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program 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
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.extension; |
23 |
|
24 |
import java.util.StringTokenizer; |
25 |
|
26 |
import org.gvsig.andami.PluginsLocator; |
27 |
import org.gvsig.app.ApplicationLocator; |
28 |
import org.gvsig.installer.lib.api.InstallerLocator; |
29 |
import org.gvsig.installer.lib.api.PackageInfo; |
30 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
31 |
import org.slf4j.Logger; |
32 |
import org.slf4j.LoggerFactory; |
33 |
|
34 |
/**
|
35 |
* gvSIG application version information.
|
36 |
*
|
37 |
* @author gvSIG Team
|
38 |
* @version $Id: Version.java 39065 2012-10-16 11:26:12Z jldominguez $
|
39 |
*/
|
40 |
public class Version { |
41 |
|
42 |
private static final Logger LOG = LoggerFactory.getLogger(Version.class); |
43 |
private static final String APP_PACKAGE_CODE = "org.gvsig.app"; |
44 |
|
45 |
private org.gvsig.installer.lib.api.Version version;
|
46 |
|
47 |
@Deprecated
|
48 |
public static String format() { |
49 |
return ApplicationLocator.getManager().getVersion().getFormat();
|
50 |
} |
51 |
|
52 |
@Deprecated
|
53 |
public static String longFormat() { |
54 |
return ApplicationLocator.getManager().getVersion().getLongFormat();
|
55 |
} |
56 |
|
57 |
@Deprecated
|
58 |
public static String getBuild() { |
59 |
return ApplicationLocator.getManager().getVersion().getBuildId();
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* Constructor.
|
64 |
* Loads version information from the application installation information.
|
65 |
*/
|
66 |
public Version() {
|
67 |
|
68 |
PackageInfo pinfo = PluginsLocator.getManager().getPackageInfo(InitializeApplicationExtension.class); |
69 |
this.version = pinfo.getVersion();
|
70 |
LOG.debug("Loaded version information: {}", getLongFormat());
|
71 |
} |
72 |
|
73 |
public int getMinor() { |
74 |
return this.version.getMinor(); |
75 |
} |
76 |
|
77 |
public int getMajor() { |
78 |
return this.version.getMajor(); |
79 |
} |
80 |
|
81 |
public int getRelease() { |
82 |
return this.version.getRevision(); |
83 |
} |
84 |
|
85 |
public String getBuildId() { |
86 |
return Integer.toString(this.version.getBuild()); |
87 |
} |
88 |
|
89 |
public String toString() { |
90 |
return getLongFormat();
|
91 |
} |
92 |
|
93 |
public String getFormat() { |
94 |
return getMajor() + "." + getMinor() + "." + getRelease(); |
95 |
} |
96 |
|
97 |
public String getLongFormat() { |
98 |
return version.toString();
|
99 |
} |
100 |
|
101 |
public org.gvsig.installer.lib.api.Version asInstallerVersion() {
|
102 |
return version;
|
103 |
} |
104 |
} |