Skip to content

Commit

Permalink
Fix | Making driver default compliant to JDBC 4.2 Specs and update AD…
Browse files Browse the repository at this point in the history
…AL4J dependency to 1.6.0 (#711)

* Feature | Added support for JDK 10 in both Maven and Gradle - builds jre10 jars for the driver, replacing jre9

* JDK 10 | Merge 42 classes to base classes to reduce class redundancy.

* JDK 10 | Attempt to run JDK 10 with Appveyor

* Remove unwanted space

* Updating Travis script to use JDK 10

* Testing without addons

* Update script for Jacoco report to build 43 profile

* Minor fix in formatting to avoid conflicts

* moving driver specific functions

for SQLServerPreparedStatement

* Remove unwanted code + Update Adal4J library dependency

* changes for CallableStatement

repeptitive delcarations

* Remove an extra bracket due to conflict

* changes for ISQLServerConnection

there are problems with moving all Driver sepcific public methods. SQLServerConnectionPoolProxy also implements this interface and there are many public APIs (such as preparedstmt cacheing stuff) which it doesn't implement, and cannot be moved into the interface at this time.

* lambda touch-up

should generally stick to 1 line if possible.

* changes for ISQLServerDataSource

* updates for ISQLServerResultSet

* Improvements | Missing interface APIs added + Code improvements

* More changes for Interface missing methods

* Implemented missing methods in SQLServerConnectionPoolProxy

* Removed ISQLServerConnection43 for duplicated method definitions

* Added APIs in interface for SQLServerResultSet

* More cleanup done

* Fix minor issues

* Fix test failures and implement Serialization for HashKey

* Fix JavaDoc errors and warnigs

* More changes for CallableStatement APIs

* More changes for Statement and Prepared Statament public APIs

* Javadoc fix

* More changes for SQL Server Bulk Record interface

* Callable Statement missing APIs for Interface

* Add missing desciptions

* Reverting pom.xml change for this PR

* Attempt to resolve conflicts

* Remove Interface as not needed.

* Added missing docs

* Changes for Clob/Blob classes for compliance

* Update ADAL4J with latest version

* Changes for Data Source classes

* Minor fixes to the new changes

* Fix for failing tests

* More changes for compliance

* Add Javadocs and class headers

* Fixed Malformed HTML Error in Javadocs

* javadoc changes

* more javadoc changes to make the abbreviations more clear

* fix unchecked warning issue

* Change HashKey in the driver to 256 Hash

* Add Interface back to SQLServerConnection43 class

* Revert "Change HashKey in the driver to 256 Hash"

This reverts commit e6bef4e.

* Changes for exceptions to throw SQLServerException type
  • Loading branch information
cheenamalhotra authored Jun 29, 2018
1 parent 9b871b8 commit 18abb70
Show file tree
Hide file tree
Showing 65 changed files with 10,829 additions and 8,732 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
<optional>true</optional>
</dependency>

Expand Down
126 changes: 104 additions & 22 deletions src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ public class Geography extends SQLServerSpatialDatatype {

/**
* Private constructor used for creating a Geography object from WKT and srid.
*
* @param WellKnownText
* Well-Known Text (WKT) provided by the user.
* @param srid
* Spatial Reference Identifier (SRID) provided by the user.
* @throws SQLServerException
* if an exception occurs
*/
private Geography(String WellKnownText, int srid) throws SQLServerException {
this.wkt = WellKnownText;
Expand All @@ -35,7 +41,11 @@ private Geography(String WellKnownText, int srid) throws SQLServerException {

/**
* Private constructor used for creating a Geography object from WKB.
*
* @param wkb
* Well-Known Binary (WKB) provided by the user.
* @throws SQLServerException
* if an exception occurs
*/
private Geography(byte[] wkb) throws SQLServerException {
this.wkb = wkb;
Expand All @@ -54,18 +64,18 @@ private Geography(byte[] wkb) throws SQLServerException {
isNull = false;
}

public Geography() {
// TODO Auto-generated constructor stub
}

/**
* Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT)
* representation augmented with any Z (elevation) and M (measure) values carried by the instance.
*
* @param wkt WKT
* @param srid SRID
* @return Geography instance
* @param wkt
* Well-Known Text (WKT) provided by the user.
* @param srid
* Spatial Reference Identifier (SRID) provided by the user.
* @return Geography
* Geography instance created from WKT and SRID
* @throws SQLServerException
* if an exception occurs
*/
public static Geography STGeomFromText(String wkt, int srid) throws SQLServerException {
return new Geography(wkt, srid);
Expand All @@ -75,9 +85,12 @@ public static Geography STGeomFromText(String wkt, int srid) throws SQLServerExc
* Returns a Geography instance from an Open Geospatial Consortium (OGC)
* Well-Known Binary (WKB) representation.
*
* @param wkb WKB
* @return Geography instance
* @param wkb
* Well-Known Binary (WKB) provided by the user.
* @return Geography
* Geography instance created from WKB
* @throws SQLServerException
* if an exception occurs
*/
public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException {
return new Geography(wkb);
Expand All @@ -86,9 +99,12 @@ public static Geography STGeomFromWKB(byte[] wkb) throws SQLServerException {
/**
* Returns a constructed Geography from an internal SQL Server format for spatial data.
*
* @param wkb WKB
* @return Geography instance
* @param wkb
* Well-Known Binary (WKB) provided by the user.
* @return Geography
* Geography instance created from WKB
* @throws SQLServerException
* if an exception occurs
*/
public static Geography deserialize(byte[] wkb) throws SQLServerException {
return new Geography(wkb);
Expand All @@ -98,9 +114,12 @@ public static Geography deserialize(byte[] wkb) throws SQLServerException {
* Returns a Geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
* SRID is defaulted to 4326.
*
* @param wkt WKt
* @return Geography instance
* @param wkt
* Well-Known Text (WKT) provided by the user.
* @return Geography
* Geography instance created from WKT
* @throws SQLServerException
* if an exception occurs
*/
public static Geography parse(String wkt) throws SQLServerException {
return new Geography(wkt, 4326);
Expand All @@ -109,11 +128,16 @@ public static Geography parse(String wkt) throws SQLServerException {
/**
* Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID.
*
* @param x x coordinate
* @param y y coordinate
* @param srid SRID
* @return Geography instance
* @param x
* x coordinate
* @param y
* y coordinate
* @param srid
* SRID
* @return Geography
* Geography instance
* @throws SQLServerException
* if an exception occurs
*/
public static Geography point(double x, double y, int srid) throws SQLServerException {
return new Geography("POINT (" + x + " " + y + ")", srid);
Expand All @@ -123,8 +147,10 @@ public static Geography point(double x, double y, int srid) throws SQLServerExce
* Returns the Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation of a
* Geography instance. This text will not contain any Z (elevation) or M (measure) values carried by the instance.
*
* @return the WKT representation without the Z and M values.
* @return
* the WKT representation without the Z and M values.
* @throws SQLServerException
* if an exception occurs
*/
public String STAsText() throws SQLServerException {
if (null == wktNoZM) {
Expand All @@ -144,7 +170,8 @@ public String STAsText() throws SQLServerException {
/**
* Returns the Open Geospatial Consortium (OGC) Well-Known Binary (WKB) representation of a
* Geography instance. This value will not contain any Z or M values carried by the instance.
* @return WKB
*
* @return byte array representation of the Geography object.
*/
public byte[] STAsBinary() {
if (null == wkbNoZM) {
Expand All @@ -156,64 +183,109 @@ public byte[] STAsBinary() {
/**
* Returns the bytes that represent an internal SQL Server format of Geography type.
*
* @return WKB
* @return byte array representation of the Geography object.
*/
public byte[] serialize() {
return wkb;
}

/**
* Returns if the object contains a M (measure) value.
*
* @return boolean that indicates if the object contains M value.
*/
public boolean hasM() {
return hasMvalues;
}

/**
* Returns if the object contains a Z (elevation) value.
*
* @return boolean that indicates if the object contains Z value.
*/
public boolean hasZ() {
return hasZvalues;
}

/**
* Returns the X coordinate value.
*
* @return double value that represents the X coordinate.
*/
public Double getX() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) {
return points[0];
}
return null;
}

/**
* Returns the Y coordinate value.
*
* @return double value that represents the Y coordinate.
*/
public Double getY() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && points.length == 2) {
return points[1];
}
return null;
}

/**
* Returns the M (measure) value of the object.
*
* @return double value that represents the M value.
*/
public Double getM() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasM()) {
return mValues[0];
}
return null;
}

/**
* Returns the Z (elevation) value of the object.
*
* @return double value that represents the Z value.
*/
public Double getZ() {
if (null != internalType && internalType == InternalSpatialDatatype.POINT && hasZ()) {
return zValues[0];
}
return null;
}

/**
* Returns the Spatial Reference Identifier (SRID) value.
*
* @return int value of SRID.
*/
public int getSrid() {
return srid;
}

/**
* Returns if the Geography object is null.
*
* @return boolean that indicates if the object is null.
*/
public boolean isNull() {
return isNull;
}

/**
* Returns the number of points in the Geography object.
*
* @return int that indicates the number of points in the Geography object.
*/
public int STNumPoints() {
return numberOfPoints;
}

/**
* Returns the Open Geospatial Consortium (OGC) type name represented by a Geography instance.
*
* @return type name
* @return String that contains the Geography object's type name
*/
public String STGeographyType() {
if (null != internalType) {
Expand All @@ -222,10 +294,21 @@ public String STGeographyType() {
return null;
}

/**
* Returns the Well-Known Text (WKT) representation of the Geography object.
*
* @return String that contains the WKT representation of the Geography object.
*/
public String asTextZM() {
return wkt;
}

/**
* Returns the String representation of the Geography object.
*
* @return String that contains the WKT representation of the Geography object.
*/
@Override
public String toString() {
return wkt;
}
Expand Down Expand Up @@ -254,7 +337,6 @@ protected void serializeToWkb(boolean noZM) {
buf.putDouble(zValues[i]);
}
}

if (hasMvalues) {
for (int i = 0; i < numberOfPoints; i++) {
buf.putDouble(mValues[i]);
Expand Down
Loading

0 comments on commit 18abb70

Please sign in to comment.