HHH-10211 - Checkstyle fixes

This commit is contained in:
Karel Maesen 2016-11-01 16:58:25 +01:00
parent 70d55987f8
commit 55ed5faa3b
18 changed files with 103 additions and 74 deletions

View File

@ -16,6 +16,7 @@ import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction;
/**
*
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/
public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDialect {

View File

@ -1,3 +1,9 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.spatial.dialect.oracle;
import java.sql.Connection;
@ -12,6 +18,7 @@ public class TestConnectionFinder implements ConnectionFinder {
final private ConnectionFinder internal = new DefaultConnectionFinder();
/**
* Find an instance of Connection that can be cast to an {@code OracleConnection} instance.
*

View File

@ -1,3 +1,9 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.spatial.dialect.postgis;
import java.sql.SQLException;

View File

@ -747,4 +747,4 @@ public class TestSpatialFunctions extends SpatialFunctionalTestCase {
}
}
}
}

View File

@ -13,8 +13,6 @@ import java.util.Map;
import org.jboss.logging.Logger;
import org.junit.Test;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
@ -25,6 +23,9 @@ import org.hibernate.spatial.criterion.SpatialRestrictions;
import org.hibernate.spatial.integration.jts.GeomEntity;
import org.hibernate.spatial.testing.SpatialDialectMatcher;
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
import org.junit.Test;
import org.hibernate.testing.Skip;
import static junit.framework.Assert.assertEquals;
@ -221,4 +222,4 @@ public class TestSpatialRestrictions extends SpatialFunctionalTestCase {
}
return false;
}
}
}

View File

@ -92,5 +92,3 @@ public class GeomEntity {
}
}

View File

@ -15,16 +15,16 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.spatial.HSMessageLogger;
import org.jboss.logging.Logger;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader;
import org.jboss.logging.Logger;
import org.hibernate.spatial.HSMessageLogger;
/**
* An <code>AbstractExpectationsFactory</code> provides the expected
* values to be used in the integration tests of the spatial functions
@ -754,7 +754,7 @@ public abstract class AbstractExpectationsFactory {
polygon.setSRID( getTestSrid() );
return polygon;
}
catch ( ParseException e ) {
catch (ParseException e) {
throw new RuntimeException( e );
}
}
@ -771,7 +771,7 @@ public abstract class AbstractExpectationsFactory {
point.setSRID( getTestSrid() );
return point;
}
catch ( ParseException e ) {
catch (ParseException e) {
throw new RuntimeException( e );
}
}
@ -814,7 +814,7 @@ public abstract class AbstractExpectationsFactory {
//this code is a hack to deal with Oracle Spatial that returns Blob's for asWKB() function
//TODO -- clean up
if ( val instanceof Blob ) {
val = (T) ( (Blob) val ).getBytes( 1, MAX_BYTE_LEN );
val = (T) ((Blob) val).getBytes( 1, MAX_BYTE_LEN );
}
expected.put( id, val );
}
@ -822,20 +822,26 @@ public abstract class AbstractExpectationsFactory {
return expected;
}
finally {
if (results != null) {
if ( results != null ) {
try {
results.close();
}catch(SQLException e) {}
}
catch (SQLException e) {
}
}
if ( preparedStatement != null ) {
try {
preparedStatement.close();
}catch(SQLException e) {}
}
catch (SQLException e) {
}
}
if ( cn != null ) {
try {
cn.close();
}catch(SQLException e){}
}
catch (SQLException e) {
}
}
}
}

View File

@ -16,8 +16,9 @@ import com.vividsolutions.jts.geom.GeometryCollection;
* <p/>
* The notion of geometric equality can differ slightly between
* spatial databases.
*
* @deprecated Should be replaced by Geolatte-geom GeometryEquality
*/
//TODO -- replace by Geolatte-geom
@Deprecated
public class GeometryEquality {
@ -32,10 +33,12 @@ public class GeometryEquality {
if ( geom1.isEmpty() ) {
return geom2.isEmpty();
}
if (!ignoreSRID && !equalSRID(geom1, geom2)) return false;
if ( !ignoreSRID && !equalSRID( geom1, geom2 ) ) {
return false;
}
if ( geom1 instanceof GeometryCollection ) {
if ( !( geom2 instanceof GeometryCollection ) ) {
if ( !(geom2 instanceof GeometryCollection) ) {
return false;
}
GeometryCollection expectedCollection = (GeometryCollection) geom1;
@ -59,11 +62,12 @@ public class GeometryEquality {
*
* @param geom1
* @param geom2
*
* @return
*/
private boolean equalSRID(Geometry geom1, Geometry geom2) {
return geom1.getSRID() == geom2.getSRID() ||
( geom1.getSRID() < 1 && geom2.getSRID() < 1);
(geom1.getSRID() < 1 && geom2.getSRID() < 1);
}
/**
@ -76,7 +80,7 @@ public class GeometryEquality {
*/
protected boolean testSimpleGeometryEquality(Geometry geom1, Geometry geom2) {
//return geom1.equals(geom2);
return testTypeAndVertexEquality( geom1, geom2);
return testTypeAndVertexEquality( geom1, geom2 );
}
protected boolean testTypeAndVertexEquality(Geometry geom1, Geometry geom2) {
@ -118,4 +122,3 @@ public class GeometryEquality {
return c1.x == c2.x && c1.y == c2.y;
}
}

View File

@ -52,10 +52,10 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
try {
dataSourceUtils.insertTestData( testData );
}
catch ( BatchUpdateException e ) {
catch (BatchUpdateException e) {
throw new RuntimeException( e.getNextException() );
}
catch ( SQLException e ) {
catch (SQLException e) {
throw new RuntimeException( e );
}
}
@ -74,12 +74,12 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
try {
session = openSession();
tx = session.beginTransaction();
String hql = String.format("delete from org.hibernate.spatial.integration.%s.GeomEntity", pckg);
String hql = String.format( "delete from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
Query q = session.createQuery( hql );
q.executeUpdate();
tx.commit();
}
catch ( Exception e ) {
catch (Exception e) {
if ( tx != null ) {
tx.rollback();
}
@ -98,7 +98,7 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
* @return
*/
protected void afterConfigurationBuilt(Configuration cfg) {
super.afterConfigurationBuilt(cfg);
super.afterConfigurationBuilt( cfg );
initializeSpatialTestSupport( serviceRegistry() );
}
@ -110,7 +110,7 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
testData = support.createTestData( this );
geometryEquality = support.createGeometryEquality();
}
catch ( Exception e ) {
catch (Exception e) {
throw new RuntimeException( e );
}
}
@ -139,7 +139,7 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
}
public String[] getMappings() {
return new String[] { };
return new String[] {};
}
@Override
@ -198,7 +198,7 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
}
protected <T> void compare(Map<Integer, T> expected, Map<Integer, T> received, String geometryType) {
for ( Map.Entry<Integer, T> entry: expected.entrySet()) {
for ( Map.Entry<Integer, T> entry : expected.entrySet() ) {
Integer id = entry.getKey();
getLogger().debug( "Case :" + id );
getLogger().debug( "expected: " + expected.get( id ) );
@ -212,9 +212,10 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
if ( expected instanceof byte[] ) {
assertArrayEquals( "Failure on testsuite-suite for case " + id, (byte[]) expected, (byte[]) received );
} else if ( expected instanceof Geometry ) {
if ( JTS.equals(geometryType) ) {
if ( !( received instanceof Geometry ) ) {
}
else if ( expected instanceof Geometry ) {
if ( JTS.equals( geometryType ) ) {
if ( !(received instanceof Geometry) ) {
fail(
"Expected a JTS Geometry, but received an object of type " + received.getClass()
.getCanonicalName()
@ -224,8 +225,9 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
"Failure on testsuite-suite for case " + id,
geometryEquality.test( (Geometry) expected, (Geometry) received )
);
} else {
if ( !( received instanceof org.geolatte.geom.Geometry ) ) {
}
else {
if ( !(received instanceof org.geolatte.geom.Geometry) ) {
fail(
"Expected a Geolatte Geometry, but received an object of type " + received.getClass()
.getCanonicalName()
@ -233,14 +235,17 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
}
assertTrue(
"Failure on testsuite-suite for case " + id,
geometryEquality.test( (Geometry) expected, (Geometry) org.geolatte.geom.jts.JTS.to((org.geolatte.geom.Geometry)received) )
geometryEquality.test(
(Geometry) expected,
(Geometry) org.geolatte.geom.jts.JTS.to( (org.geolatte.geom.Geometry) received )
)
);
}
}
else {
if ( expected instanceof Long ) {
assertEquals( "Failure on testsuite-suite for case " + id, ( (Long) expected ).intValue(), received );
assertEquals( "Failure on testsuite-suite for case " + id, ((Long) expected).intValue(), received );
}
else {
assertEquals( "Failure on testsuite-suite for case " + id, expected, received );

View File

@ -26,4 +26,3 @@ public class TestDataElement {
}
}

View File

@ -29,7 +29,7 @@ public class TestDataReader {
Document document = reader.read( getInputStream( fileName ) );
addDataElements( document, testDataElements );
}
catch ( DocumentException e ) {
catch (DocumentException e) {
throw new RuntimeException( e );
}
return testDataElements;
@ -47,7 +47,7 @@ public class TestDataReader {
int id = Integer.parseInt( element.selectSingleNode( "id" ).getText() );
String type = element.selectSingleNode( "type" ).getText();
String wkt = element.selectSingleNode( "wkt" ).getText();
TestDataElement testDataElement = new TestDataElement( id, type, wkt);
TestDataElement testDataElement = new TestDataElement( id, type, wkt );
testDataElements.add( testDataElement );
}
@ -58,4 +58,4 @@ public class TestDataReader {
}
return is;
}
}
}

View File

@ -9,8 +9,8 @@ package org.hibernate.spatial.testing;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -52,4 +52,4 @@ public abstract class TestSupport {
protected String passwd() {
return configurationService.getSetting( AvailableSettings.PASS, String.class, "" );
}
}
}

View File

@ -79,4 +79,3 @@ public class TestSupportFactories {
}
}

View File

@ -14,10 +14,10 @@ public class WktUtility {
static public int getSRID(String wkt) {
String[] tokens = wkt.split( ";" );
if (tokens.length == 1){
if ( tokens.length == 1 ) {
return 0;
}
String[] sridTokens = tokens[0].split("=");
String[] sridTokens = tokens[0].split( "=" );
if ( sridTokens.length < 2 ) {
throw new IllegalArgumentException( "Can't parse " + wkt );
}
@ -25,10 +25,11 @@ public class WktUtility {
}
static public String getWkt(String wkt) {
String[] tokens = wkt.split(";");
String[] tokens = wkt.split( ";" );
if ( tokens.length > 1 ) {
return tokens[1];
} else {
}
else {
return wkt;
}

View File

@ -43,14 +43,14 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
@Override
protected NativeSQLStatement createNativeBoundaryStatement() {
return createNativeSQLStatement("select id, ST_Boundary(geom) from GEOMTEST");
return createNativeSQLStatement( "select id, ST_Boundary(geom) from GEOMTEST" );
}
@Override
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
return createNativeSQLStatement(
"select t.id, ST_Buffer(t.geom,?) from GEOMTEST t where ST_SRID(t.geom) = 4326",
new Object[] { distance }
new Object[] {distance}
);
}
@ -87,7 +87,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
@Override
protected NativeSQLStatement createNativeDimensionSQL() {
return createNativeSQLStatement("select id, ST_Dimension(geom) from GEOMTEST");
return createNativeSQLStatement( "select id, ST_Dimension(geom) from GEOMTEST" );
}
@Override
@ -277,15 +277,17 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
*/
@Override
protected NativeSQLStatement createNativeRelateStatement(Geometry geom,
String matrix) {
protected NativeSQLStatement createNativeRelateStatement(
Geometry geom,
String matrix) {
String sql = "select t.id, ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "' ) from GEOMTEST t where ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "') = 'true' and ST_SRID(t.geom) = 4326";
return createNativeSQLStatementAllWKTParams(sql, geom.toText());
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
}
@Override
protected NativeSQLStatement createNativeDwithinStatement(Point geom,
double distance) {
protected NativeSQLStatement createNativeDwithinStatement(
Point geom,
double distance) {
String sql = "select t.id, ST_DWithin(t.geom, ST_GeomFromText(?, 4326), "
+ distance
+ " ) from GEOMTEST t where st_dwithin(t.geom, ST_GeomFromText(?, 4326), "

View File

@ -20,8 +20,9 @@ import org.hibernate.spatial.testing.GeometryEquality;
* Geometry objects, which cannot be cast to {@link org.hibernate.spatial.jts.mgeom.MGeometry} objects.
*
* @author Jan Boonen, Geodan IT b.v.
* @deprecated This should no longer be necesseary
*/
@Deprecated //NO LONGER REQUIRED
@Deprecated
public class GeoDBGeometryEquality extends GeometryEquality {
@Override

View File

@ -10,23 +10,24 @@
*/
package org.hibernate.spatial.testing.dialects.h2geodb;
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
import org.hibernate.spatial.testing.NativeSQLStatement;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Point;
import org.geolatte.geom.ByteBuffer;
import org.geolatte.geom.codec.Wkb;
import org.geolatte.geom.jts.JTS;
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
import org.hibernate.spatial.testing.NativeSQLStatement;
/**
* A Factory class that generates expected {@link org.hibernate.spatial.testing.NativeSQLStatement}s for GeoDB
* version < 0.4. These versions don't support storage of the SRID value with
* the geometry.
*
* @author Jan Boonen, Geodan IT b.v.
* @deprecated No longer used
*/
@Deprecated //Class no longer used. Remove.
@Deprecated
public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory {
public GeoDBNoSRIDExpectationsFactory(GeoDBDataSourceUtils dataSourceUtils) {
@ -54,7 +55,7 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
return createNativeSQLStatement(
"select t.id, ST_Buffer(t.geom,?) from GEOMTEST t where ST_SRID(t.geom) = 4326",
new Object[] { distance }
new Object[] {distance}
);
}
@ -192,8 +193,9 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
}
@Override
protected NativeSQLStatement createNativeRelateStatement(Geometry geom,
String matrix) {
protected NativeSQLStatement createNativeRelateStatement(
Geometry geom,
String matrix) {
throw new UnsupportedOperationException(
"Method ST_Relate() is not implemented in the current version of GeoDB."
);

View File

@ -10,8 +10,6 @@ package org.hibernate.spatial.testing.dialects.h2geodb;
import java.io.IOException;
import java.sql.SQLException;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
import org.hibernate.spatial.testing.DataSourceUtils;
@ -19,6 +17,7 @@ import org.hibernate.spatial.testing.GeometryEquality;
import org.hibernate.spatial.testing.SQLExpressionTemplate;
import org.hibernate.spatial.testing.TestData;
import org.hibernate.spatial.testing.TestSupport;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
@ -32,10 +31,10 @@ public class GeoDBTestSupport extends TestSupport {
try {
return new GeoDBDataSourceUtils( driver(), url(), user(), passwd(), getSQLExpressionTemplate() );
}
catch ( SQLException e ) {
catch (SQLException e) {
throw new RuntimeException( e );
}
catch ( IOException e ) {
catch (IOException e) {
throw new RuntimeException( e );
}
}
@ -49,10 +48,11 @@ public class GeoDBTestSupport extends TestSupport {
}
public AbstractExpectationsFactory createExpectationsFactory(DataSourceUtils dataSourceUtils) {
if ( dataSourceUtils instanceof GeoDBDataSourceUtils) {
if ( dataSourceUtils instanceof GeoDBDataSourceUtils ) {
return new GeoDBExpectationsFactory( (GeoDBDataSourceUtils) dataSourceUtils );
} else {
throw new IllegalArgumentException("Requires a GeoDBDataSourceUtils instance");
}
else {
throw new IllegalArgumentException( "Requires a GeoDBDataSourceUtils instance" );
}
}
@ -60,6 +60,4 @@ public class GeoDBTestSupport extends TestSupport {
return new GeoDBExpressionTemplate();
}
}