From 94ae08701bbd7585a0b7e5a92d1975965a503c03 Mon Sep 17 00:00:00 2001 From: Dennis Kao <ulysseskao@gmail.com> Date: Wed, 15 Jan 2014 11:28:52 +0800 Subject: [PATCH] Merge branch 'origin/2.1.x' --- xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java | 57 ++++++++++++++++++++++++--------------------------------- 1 files changed, 24 insertions(+), 33 deletions(-) diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java index b87f551..6720216 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java +++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java @@ -27,6 +27,7 @@ import java.sql.Connection; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; @@ -54,8 +55,7 @@ * * @author markus.schaber@logix-tt.com */ -public class JtsWrapper extends Driver -{ +public class JtsWrapper extends Driver { protected static final Logger logger = Logger.getLogger("org.postgis.DriverWrapper"); @@ -63,19 +63,15 @@ private static final String POSTGIS_PROTOCOL = "jdbc:postgres_jts:"; public static final String REVISION = "$Revision: 2570 $"; - public JtsWrapper() - { + public JtsWrapper() { super(); } - static - { - try - { + static { + try { // Try to register ourself to the DriverManager java.sql.DriverManager.registerDriver(new JtsWrapper()); - } catch (SQLException e) - { + } catch (SQLException e) { logger.log(Level.WARNING, "Error registering PostgreSQL Jts Wrapper Driver", e); } } @@ -91,8 +87,7 @@ * @see java.sql.Driver#connect * @see org.postgresql.Driver */ - public java.sql.Connection connect(String url, Properties info) throws SQLException - { + public java.sql.Connection connect(String url, Properties info) throws SQLException { url = mangleURL(url); Connection result = super.connect(url, info); addGISTypes((PGConnection) result); @@ -102,27 +97,24 @@ /** * adds the JTS/PostGIS Data types to a PG Connection. * - * @param pgconn postgres connection + * @param pgconn postgres connection * @throws SQLException error */ - public static void addGISTypes(PGConnection pgconn) throws SQLException - { + public static void addGISTypes(PGConnection pgconn) throws SQLException { pgconn.addDataType("geometry", JtsGeometry.class); } /** * Mangles the PostGIS URL to return the original PostGreSQL URL + * * @param url url * @return string * @throws java.sql.SQLException erroe */ - public static String mangleURL(String url) throws SQLException - { - if (url.startsWith(POSTGIS_PROTOCOL)) - { + public static String mangleURL(String url) throws SQLException { + if (url.startsWith(POSTGIS_PROTOCOL)) { return POSTGRES_PROTOCOL + url.substring(POSTGIS_PROTOCOL.length()); - } else - { + } else { throw new SQLException("Unknown protocol or subprotocol in url " + url); } } @@ -136,13 +128,10 @@ * driver, should not happen. * @see java.sql.Driver#acceptsURL */ - public boolean acceptsURL(String url) throws SQLException - { - try - { + public boolean acceptsURL(String url) throws SQLException { + try { url = mangleURL(url); - } catch (SQLException e) - { + } catch (SQLException e) { return false; } return super.acceptsURL(url); @@ -154,8 +143,7 @@ * @return the drivers major version number */ - public int getMajorVersion() - { + public int getMajorVersion() { return super.getMajorVersion(); } @@ -164,17 +152,20 @@ * * @return the drivers minor version number */ - public int getMinorVersion() - { + public int getMinorVersion() { return super.getMinorVersion(); } /** * Returns our own CVS version plus postgres Version + * * @return version */ - public static String getVersion() - { + public static String getVersion() { return "JtsGisWrapper " + REVISION + ", wrapping " + Driver.getVersion(); } + + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new UnsupportedOperationException("Not supported yet."); + } } -- Gitblit v0.0.0-SNAPSHOT