4
* PostGIS extension for PostgreSQL JDBC driver - current version identification
6
* (C) 2005 Markus Schaber, markus@schabi.de
8
* This library is free software; you can redistribute it and/or modify it under
9
* the terms of the GNU Lesser General Public License as published by the Free
10
* Software Foundation, either version 2.1 of the License.
12
* This library is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this library; if not, write to the Free Software Foundation, Inc.,
19
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
22
* $Id: Version.java,v 1.6 2005/03/30 15:24:40 mschaber Exp $
27
import java.io.BufferedReader;
28
import java.io.IOException;
29
import java.io.InputStreamReader;
32
/** Corresponds to the appropriate PostGIS that carried this source */
33
public class Version {
34
/** We read our version information from this ressource... */
35
private static final String RESSOURCENAME = "org/postgis/version.properties";
37
/** The major version */
38
public static final int MAJOR;
40
/** The minor version */
41
public static final int MINOR;
44
* The micro version, usually a number including possibly textual suffixes
47
public static final String MICRO;
52
String micro = "INVALID";
54
ClassLoader loader = Version.class.getClassLoader();
55
URL ver = loader.getResource(RESSOURCENAME);
57
throw new ExceptionInInitializerError(
58
"Error initializing PostGIS JDBC version! Cause: Ressource "+RESSOURCENAME+" not found!");
60
BufferedReader rd = new BufferedReader(new InputStreamReader(ver.openStream()));
63
while ((line = rd.readLine()) != null) {
65
if (line.startsWith("JDBC_MAJOR_VERSION")) {
66
major = Integer.parseInt(line.substring(19));
67
} else if (line.startsWith("JDBC_MINOR_VERSION")) {
68
minor = Integer.parseInt(line.substring(19));
69
} else if (line.startsWith("JDBC_MICRO_VERSION")) {
70
micro = line.substring(19);
75
if (major == -1 || minor == -1 || micro.equals("INVALID")) {
76
throw new ExceptionInInitializerError("Error initializing PostGIS JDBC version! Cause: Ressource "+RESSOURCENAME+" incomplete!");
78
} catch (IOException e) {
79
throw new ExceptionInInitializerError("Error initializing PostGIS JDBC version! Cause: " + e.getMessage());
87
/** Full version for human reading - code should use the constants above */
88
public static final String FULL = "PostGIS JDBC V" + MAJOR + "." + MINOR + "." + MICRO;
90
public static void main(String[] args) {
91
System.out.println(FULL);
94
public static String getFullVersion() {