Skip to content

Commit

Permalink
HHH-14442 Fix checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maesenka authored and dreab8 committed Feb 9, 2021
1 parent 5af975d commit 8463865
Show file tree
Hide file tree
Showing 53 changed files with 555 additions and 370 deletions.
Expand Up @@ -7,10 +7,11 @@

package org.hibernate.spatial;

import java.util.Locale;

import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry;

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
Expand Down Expand Up @@ -49,7 +50,7 @@ public Geometry fromString(String string) {
return reader.read( string );
}
catch (ParseException e) {
throw new RuntimeException( String.format( "Can't parse string %s as WKT", string ) );
throw new RuntimeException( String.format( Locale.ENGLISH, "Can't parse string %s as WKT", string ) );
}
}

Expand Down
Expand Up @@ -29,8 +29,6 @@
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;

import static java.lang.String.format;

/**
* @author David Adler, Adtech Geospatial
* creation-date: 5/22/2014
Expand Down Expand Up @@ -228,24 +226,11 @@ private void registerSpatialFunctions() {
) );

// Register non-SFS functions listed in Hibernate Spatial
registerFunction( "dwithin", new DWithinFunction());

// // The srid parameter needs to be explicitly cast to INTEGER to avoid a -245 SQLCODE,
// // ambiguous parameter.
// registerFunction( "transform", new SQLFunctionTemplate(
// geolatteGemetryType,
// "DB2GSE.ST_Transform(?1, CAST (?2 AS INTEGER))"
// ) );
registerFunction( "dwithin", new DWithinFunction() );

registerFunction( "geomFromText", new StandardSQLFunction(
"DB2GSE.ST_GeomFromText"
) );

// // Register spatial aggregate function
// registerFunction( "extent", new SQLFunctionTemplate(
// geolatteGemetryType,
// "db2gse.ST_GetAggrResult(MAX(db2gse.st_BuildMBRAggr(?1)))"
// ) );
}

@Override
Expand All @@ -271,7 +256,7 @@ public String getIsEmptySQL(String columnName, boolean isEmpty) {
@Override
public String getSpatialAggregateSQL(String columnName, int type) {
switch ( type ) {
case SpatialAggregate.EXTENT: // same as extent function above???
case SpatialAggregate.EXTENT:
return "db2gse.ST_GetAggrResult(MAX(db2gse.st_BuildMBRAggr(" + columnName + ")))";
case SpatialAggregate.UNION:
return "db2gse.ST_GetAggrResult(MAX(db2gse.st_BuildUnionAggr(" + columnName + ")))";
Expand Down Expand Up @@ -304,7 +289,8 @@ public String getSpatialRelateSQL(String columnName, int spatialRelation) {
if ( spatialRelation != SpatialRelation.DISJOINT ) {
return " db2gse." + relationName + "(" + columnName + ", ?) = 1 SELECTIVITY .0001";
}
else { // SELECTIVITY not supported for ST_Disjoint UDF
else {
// SELECTIVITY not supported for ST_Disjoint UDF
return " db2gse." + relationName + "(" + columnName + ", ?) = 1";
}
}
Expand All @@ -328,17 +314,17 @@ public boolean supportsFiltering() {
private static class DWithinFunction extends StandardSQLFunction {

public DWithinFunction() {
super( "db2gse.ST_Dwithin" , StandardBasicTypes.NUMERIC_BOOLEAN);
super( "db2gse.ST_Dwithin", StandardBasicTypes.NUMERIC_BOOLEAN );
}

public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) {
StringBuilder sb = new StringBuilder( "db2gse.ST_Intersects( " );
sb.append( (String)args.get(0) ) //
.append(", db2gse.ST_Buffer(")
.append((String)args.get(1) )
.append(", ")
.append((String)args.get(2) )
.append(", 'METER'))");
sb.append( (String) args.get( 0 ) )
.append( ", db2gse.ST_Buffer(" )
.append( (String) args.get( 1 ) )
.append( ", " )
.append( (String) args.get( 2 ) )
.append( ", 'METER'))" );
return sb.toString();
}

Expand Down
Expand Up @@ -8,6 +8,7 @@
package org.hibernate.spatial.dialect.h2geodb;

import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -177,7 +178,7 @@ public String render(
Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) {
int argumentCount = arguments.size();
if ( argumentCount != 2 ) {
throw new QueryException( String.format( "2 arguments expected, received %d", argumentCount ) );
throw new QueryException( String.format( Locale.ENGLISH,"2 arguments expected, received %d", argumentCount ) );
}

return Stream.of(
Expand Down
Expand Up @@ -11,6 +11,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Locale;

import org.geolatte.geom.ByteBuffer;
import org.geolatte.geom.ByteOrder;
Expand All @@ -23,6 +24,10 @@ public class HANASpatialUtils {

private static final int POSTGIS_SRID_FLAG = 0x20000000;

private HANASpatialUtils(){
//prevent instantiation of Utility class
}

@SuppressWarnings("resource")
public static Geometry<?> toGeometry(ResultSet rs, String name) throws SQLException {
ByteBuffer buffer = toByteBuffer( rs.getObject( name ) );
Expand All @@ -36,7 +41,7 @@ public static Geometry<?> toGeometry(ResultSet rs, String name) throws SQLExcept
String columnName = null;
for ( int i = 1; i <= rs.getMetaData().getColumnCount(); i++ ) {
if ( name.equals( rs.getMetaData().getColumnLabel( i ) ) ||
name.toUpperCase().equals( rs.getMetaData().getColumnLabel( i ) ) ) {
name.toUpperCase( Locale.ENGLISH ).equals( rs.getMetaData().getColumnLabel( i ) ) ) {
tableName = rs.getMetaData().getTableName( i );
columnName = rs.getMetaData().getColumnName( i );
}
Expand Down Expand Up @@ -80,17 +85,20 @@ public static Geometry<?> toGeometry(ResultSet rs, String name) throws SQLExcept
}

private static ByteBuffer addCrsId(byte[] wkb, byte orderByte, int typeCode, int crsId) {
ByteBuffer buffer = ByteBuffer.allocate( wkb.length + 4 ); // original capacity + 4 bytes for the CRS ID
// original capacity + 4 bytes for the CRS ID
ByteBuffer buffer = ByteBuffer.allocate( wkb.length + 4 );
buffer.setByteOrder( ByteOrder.valueOf( orderByte ) );

buffer.put( orderByte ); // write byte order
// write byte order
buffer.put( orderByte );

buffer.putUInt( typeCode | POSTGIS_SRID_FLAG ); // set SRID flag
// set SRID flag
buffer.putUInt( typeCode | POSTGIS_SRID_FLAG );

buffer.putInt( crsId ); // write CRS ID
// write CRS ID
buffer.putInt( crsId );

// write remaining data

for ( int i = 5; i < wkb.length; i++ ) {
buffer.put( wkb[i] );
}
Expand Down
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.spatial.dialect.mysql;

import java.util.Locale;
import java.util.Map;

import org.hibernate.boot.model.TypeContributions;
Expand Down Expand Up @@ -93,7 +94,10 @@ public String getSpatialAggregateSQL(String columnName, int aggregation) {

@Override
public String getDWithinSQL(String columnName) {
throw new UnsupportedOperationException( String.format( "Mysql doesn't support the Dwithin function" ) );
throw new UnsupportedOperationException( String.format(
Locale.ENGLISH,
"Mysql doesn't support the Dwithin function"
) );
}

@Override
Expand Down
Expand Up @@ -42,11 +42,10 @@ class OracleSDOSupport implements SpatialDialect, Serializable, WithCustomJPAFil
OracleSpatial10gDialect.class.getName()
);

private final boolean isOgcStrict;

private final SpatialFunctionsRegistry sdoFunctions;

OracleSDOSupport(boolean isOgcStrict) {
this.isOgcStrict = isOgcStrict;
this.sdoFunctions = new OracleSpatialFunctions( isOgcStrict, this );
}

Expand Down Expand Up @@ -262,7 +261,7 @@ public String getSpatialAggregateSQL(String columnName, int aggregation) {
aggregateFunction.append( "SDOAGGRTYPE(" );
}
aggregateFunction.append( columnName );
// TODO tolerance must by configurable
// Can we make tolerance configurable
if ( sa.isAggregateType() ) {
aggregateFunction.append( ", " ).append( .001 ).append( ")" );
}
Expand Down Expand Up @@ -292,7 +291,7 @@ public String getDWithinSQL(String columnName) {
*/
@Override
public String getHavingSridSQL(String columnName) {
return String.format( " (MDSYS.ST_GEOMETRY(%s).ST_SRID() = ?)", columnName , Locale.US);
return String.format( Locale.ENGLISH, " (MDSYS.ST_GEOMETRY(%s).ST_SRID() = ?)", columnName );
}

/**
Expand All @@ -306,7 +305,12 @@ public String getHavingSridSQL(String columnName) {
*/
@Override
public String getIsEmptySQL(String columnName, boolean isEmpty) {
return String.format( "( MDSYS.ST_GEOMETRY(%s).ST_ISEMPTY() = %d )", columnName, isEmpty ? 1 : 0 , Locale.US);
return String.format(
Locale.ENGLISH,
"( MDSYS.ST_GEOMETRY(%s).ST_ISEMPTY() = %d )",
columnName,
isEmpty ? 1 : 0
);
}

/**
Expand Down
Expand Up @@ -7,6 +7,7 @@
package org.hibernate.spatial.dialect.postgis;

import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -226,7 +227,11 @@ public String render(
Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) {
int argumentCount = arguments.size();
if ( argumentCount != 2 ) {
throw new QueryException( String.format( "2 arguments expected, received %d", argumentCount ) );
throw new QueryException( String.format(
Locale.ENGLISH,
"2 arguments expected, received %d",
argumentCount
) );
}

return Stream.of(
Expand Down

0 comments on commit 8463865

Please sign in to comment.