Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / Version.java @ 40558

History | View | Annotate | Download (3.05 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.extension;
25

    
26
import java.util.StringTokenizer;
27

    
28
import org.gvsig.andami.PluginsLocator;
29
import org.gvsig.app.ApplicationLocator;
30
import org.gvsig.installer.lib.api.InstallerLocator;
31
import org.gvsig.installer.lib.api.PackageInfo;
32
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

    
36
/**
37
 * gvSIG application version information.
38
 * 
39
 * @author gvSIG Team
40
 * @version $Id: Version.java 39065 2012-10-16 11:26:12Z jldominguez $
41
 */
42
public class Version {
43

    
44
    private static final Logger LOG = LoggerFactory.getLogger(Version.class);
45

    
46
    private org.gvsig.installer.lib.api.Version version;
47

    
48
    @Deprecated
49
    public static String format() {
50
        return ApplicationLocator.getManager().getVersion().getFormat();
51
    }
52

    
53
    @Deprecated
54
    public static String longFormat() {
55
        return ApplicationLocator.getManager().getVersion().getLongFormat();
56
    }
57

    
58
    @Deprecated
59
    public static String getBuild() {
60
        return ApplicationLocator.getManager().getVersion().getBuildId();
61
    }
62

    
63
    /**
64
     * Constructor.
65
     * Loads version information from the application installation information.
66
     */
67
    public Version() {
68
        
69
        PackageInfo pinfo = PluginsLocator.getManager().getPackageInfo(InitializeApplicationExtension.class);
70
        this.version = pinfo.getVersion();
71
        LOG.debug("Loaded version information: {}", getLongFormat());
72
    }
73

    
74
    public int getMinor() {
75
        return this.version.getMinor();
76
    }
77

    
78
    public int getMajor() {
79
        return this.version.getMajor();
80
    }
81

    
82
    public int getRelease() {
83
        return this.version.getRevision();
84
    }
85

    
86
    public String getBuildId() {
87
        return Integer.toString(this.version.getBuild());
88
    }
89

    
90
    public String toString() {
91
        return getLongFormat();
92
    }
93

    
94
    public String getFormat() {
95
        return getMajor() + "." + getMinor() + "." + getRelease();
96
    }
97

    
98
    public String getLongFormat() {
99
        return version.toString(); 
100
    }
101
    
102
    public org.gvsig.installer.lib.api.Version asInstallerVersion() {
103
        return version;
104
    }
105
}