Skip to content

Commit

Permalink
Fix thread safety issues in a multi threaded environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
kad-kleijm authored and maesenka committed Feb 3, 2021
1 parent f800583 commit 6c7b1bd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 27 deletions.
27 changes: 3 additions & 24 deletions geom/src/main/java/org/geolatte/geom/codec/db/oracle/Decoders.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,15 @@
import org.geolatte.geom.codec.db.Decoder;

import java.sql.Struct;
import java.util.ArrayList;
import java.util.List;

/**
* Created by Karel Maesen, Geovise BVBA on 19/03/15.
*/
public class Decoders {

final private static List<AbstractSDODecoder> DECODERS = new ArrayList<AbstractSDODecoder>();

static {
//Decoders
DECODERS.add( new PointSdoDecoder() );
DECODERS.add( new LineStringSdoDecoder() );
DECODERS.add( new PolygonSdoDecoder() );
DECODERS.add( new MultiLineSdoDecoder( ) );
DECODERS.add( new MultiPolygonSdoDecoder( ) );
DECODERS.add( new MultiPointSdoDecoder( ) );
DECODERS.add( new GeometryCollectionSdoDecoder( ) );
}


public static Decoder decoderFor(SDOGeometry object) {
for ( Decoder decoder : DECODERS ) {
if ( decoder.accepts( object ) ) {
return decoder;
}
}
throw new IllegalArgumentException( "No decoder for type " + object.getGType().getTypeGeometry() );
}
public static Decoder decoderFor(SDOGeometry object) {
return object.getGType().getTypeGeometry().createDecoder();
}

/**
* Decodes the SQL Server Geometry object to its JTS Geometry instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,74 @@

package org.geolatte.geom.codec.db.oracle;

import org.geolatte.geom.codec.db.Decoder;

/**
* @author Karel Maesen, Geovise BVBA
* creation-date: Jul 1, 2010
*/
enum TypeGeometry {

UNKNOWN_GEOMETRY( 0 ), POINT( 1 ), LINE( 2 ), POLYGON( 3 ), COLLECTION( 4 ), MULTIPOINT(
5
), MULTILINE( 6 ), MULTIPOLYGON( 7 ), SOLID( 8 ), MULTISOLID( 9 );
UNKNOWN_GEOMETRY(0) {
@Override
Decoder createDecoder() {
throw new UnsupportedOperationException();
}
},
POINT(1) {
@Override
Decoder createDecoder() {
return new PointSdoDecoder();
}
},
LINE(2) {
@Override
Decoder createDecoder() {
return new LineStringSdoDecoder();
}
},
POLYGON(3) {
@Override
Decoder createDecoder() {
return new PolygonSdoDecoder();
}
},
COLLECTION(4) {
@Override
Decoder createDecoder() {
return new GeometryCollectionSdoDecoder();
}
},
MULTIPOINT(5) {
@Override
Decoder createDecoder() {
return new MultiPointSdoDecoder();
}
},
MULTILINE(6) {
@Override
Decoder createDecoder() {
return new MultiLineSdoDecoder();
}
},
MULTIPOLYGON(7) {
@Override
Decoder createDecoder() {
return new MultiPolygonSdoDecoder();
}
},
SOLID(8) {
@Override
Decoder createDecoder() {
throw new UnsupportedOperationException();
}
},
MULTISOLID(9) {
@Override
Decoder createDecoder() {
throw new UnsupportedOperationException();
}
};

private int gtype;

Expand All @@ -53,4 +112,5 @@ static TypeGeometry parse(int v) {
);
}

abstract Decoder createDecoder();
}

0 comments on commit 6c7b1bd

Please sign in to comment.