Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / Version.java @ 34510

History | View | Annotate | Download (2.46 KB)

1
package com.iver.cit.gvsig;
2

    
3
import java.util.Properties;
4

    
5
import org.apache.log4j.Logger;
6

    
7
import com.iver.cit.gvsig.DEMO.SingleView;
8
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
9

    
10
public class Version {
11
        private static Logger logger = Logger.getLogger(Version.class.getName());
12
        /**
13
         * @deprecated Use method getMajor 
14
         */
15
        public static int MAJOR_VERSION_NUMBER = 0;
16
        /**
17
         * @deprecated Use method getMinor 
18
         */
19
        public static int MINOR_VERSION_NUMBER = 0;
20
        /**
21
         * @deprecated Use method getRelease 
22
         */
23
        public static int RELEASE_NUMBER = 0;
24
        private static boolean loaded = false;
25

    
26
        private static String BUILD = null;
27

    
28
        static {
29
                Version version = new Version();
30
                version.loadVersion();
31
        }
32
        /**
33
         * @deprecated Use method getFormat 
34
         */
35
        public static String format() {
36

    
37
                Version version = new Version();
38
                return version.getFormat();
39
        }
40

    
41
        /**
42
         * @deprecated Use method getLongFormat 
43
         */
44
        public static String longFormat() {
45

    
46
                Version version = new Version();
47
                return version.getLongFormat();
48
        }
49
        
50
        /**
51
         * @deprecated Use method getBuildId 
52
         */
53
        public static String getBuild() {
54

    
55
                Version version = new Version();
56
                return version.getBuildId();
57
        }
58
        
59
        private void loadVersion() {
60
                if (!loaded) {
61
                        try {
62
                                Properties props=new Properties();
63
                                props.load(FPanelAbout.class.getResourceAsStream("/package.info"));
64
                                String version = props.getProperty("version", "0.0.0");
65
                                String[] versionSplit = version.split("[.]");
66
                                MAJOR_VERSION_NUMBER = Integer.parseInt(versionSplit[0]);
67
                                MINOR_VERSION_NUMBER = Integer.parseInt(versionSplit[1]);
68
                                RELEASE_NUMBER = Integer.parseInt(versionSplit[2]);
69
                                props=new Properties();
70
                                props.load(FPanelAbout.class.getResourceAsStream("/build.number"));
71
                                BUILD = props.getProperty("build.number", "0");
72
                                loaded = true;
73
                        } catch (Exception e) {
74
                                logger.error("cant_load_properties", e);
75
                        }
76

    
77
                }
78
                
79
        }
80
        
81
        
82
        public int getMinor() {
83
                loadVersion();
84
                return MINOR_VERSION_NUMBER;
85
        }
86

    
87
        public int getMajor() {
88
                loadVersion();
89
                return MAJOR_VERSION_NUMBER;
90
        }
91

    
92
        public int getRelease() {
93
                loadVersion();
94
                return RELEASE_NUMBER;
95
        }
96

    
97
        public String getBuildId() {
98
                loadVersion();
99
                return BUILD;
100
        }
101
        
102
        public String toString() {
103
                return getLongFormat();                
104
        }
105

    
106
    public String getFormat() {
107
                return this.getMajor() +"."+this.getMinor()+"."+this.getRelease();
108
    }
109

    
110
    public String getLongFormat() {
111
                return this.getMajor() +"."+this.getMinor()+"."+this.getRelease() + "(Build " + this.getBuildId() + ")";
112
    }
113

    
114
}