Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making driver default compliant to JDBC 4.2 Specs #711

Merged
merged 59 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
129459b
Feature | Added support for JDK 10 in both Maven and Gradle - builds …
cheenamalhotra May 4, 2018
5a2313d
Merge branch 'ms-dev' into jdk10
cheenamalhotra May 7, 2018
9cead24
JDK 10 | Merge 42 classes to base classes to reduce class redundancy.
cheenamalhotra May 8, 2018
bfc3c89
JDK 10 | Attempt to run JDK 10 with Appveyor
cheenamalhotra May 8, 2018
3fc6e68
Remove unwanted space
cheenamalhotra May 18, 2018
9a6f947
Updating Travis script to use JDK 10
cheenamalhotra May 30, 2018
14e7359
Merge branch 'dev' into jdk10
cheenamalhotra May 30, 2018
72382a0
Testing without addons
cheenamalhotra May 30, 2018
5bf71bd
Update script for Jacoco report to build 43 profile
cheenamalhotra May 30, 2018
dfd7eef
Merge branch dev into compliance_42
cheenamalhotra Jun 1, 2018
b56e70a
Minor fix in formatting to avoid conflicts
cheenamalhotra Jun 1, 2018
fe530c7
Merge branch 'ms-dev' into compliance_42
cheenamalhotra Jun 8, 2018
4d3b189
moving driver specific functions
rene-ye Jun 12, 2018
2954acd
Remove unwanted code + Update Adal4J library dependency
cheenamalhotra Jun 13, 2018
25f434a
changes for CallableStatement
rene-ye Jun 13, 2018
788ac26
Merge branch 'dev' into compliance_42
cheenamalhotra Jun 13, 2018
16001c6
Remove an extra bracket due to conflict
cheenamalhotra Jun 13, 2018
02f77fd
changes for ISQLServerConnection
rene-ye Jun 13, 2018
9d34fc6
Merge branch 'compliance_42' of https://github.com/cheenamalhotra/mss…
rene-ye Jun 13, 2018
ad4db2c
lambda touch-up
rene-ye Jun 13, 2018
7c8fd20
changes for ISQLServerDataSource
rene-ye Jun 13, 2018
8aa4a5a
updates for ISQLServerResultSet
rene-ye Jun 13, 2018
318be65
Merge pull request #10 from rene-ye/compliance_42
cheenamalhotra Jun 13, 2018
ffb3edc
Improvements | Missing interface APIs added + Code improvements
cheenamalhotra Jun 19, 2018
f0e9e6b
More changes for Interface missing methods
cheenamalhotra Jun 19, 2018
d230611
Implemented missing methods in SQLServerConnectionPoolProxy
cheenamalhotra Jun 19, 2018
bef801f
Removed ISQLServerConnection43 for duplicated method definitions
cheenamalhotra Jun 19, 2018
c7c0c28
Added APIs in interface for SQLServerResultSet
cheenamalhotra Jun 20, 2018
36b770f
More cleanup done
cheenamalhotra Jun 20, 2018
9deb557
Fix minor issues
cheenamalhotra Jun 20, 2018
c3ce584
Fix test failures and implement Serialization for HashKey
cheenamalhotra Jun 20, 2018
965fbcc
Fix JavaDoc errors and warnigs
cheenamalhotra Jun 20, 2018
52b4175
More changes for CallableStatement APIs
cheenamalhotra Jun 20, 2018
c1e870e
More changes for Statement and Prepared Statament public APIs
cheenamalhotra Jun 20, 2018
63a1f59
Javadoc fix
cheenamalhotra Jun 20, 2018
b345de1
More changes for SQL Server Bulk Record interface
cheenamalhotra Jun 20, 2018
b85e9d6
Callable Statement missing APIs for Interface
cheenamalhotra Jun 20, 2018
408af84
Add missing desciptions
cheenamalhotra Jun 21, 2018
615469d
Reverting pom.xml change for this PR
cheenamalhotra Jun 21, 2018
4aa31f0
Attempt to resolve conflicts
cheenamalhotra Jun 21, 2018
fe5653f
Merge branch 'dev' into compliance_42
cheenamalhotra Jun 21, 2018
4b2fc55
Remove Interface as not needed.
cheenamalhotra Jun 21, 2018
312f0b7
Added missing docs
cheenamalhotra Jun 21, 2018
0319680
Changes for Clob/Blob classes for compliance
cheenamalhotra Jun 21, 2018
6d4effc
Update ADAL4J with latest version
cheenamalhotra Jun 22, 2018
bfc6fd7
Changes for Data Source classes
cheenamalhotra Jun 22, 2018
7b3a6eb
Merge branch 'dev' into compliance_42
cheenamalhotra Jun 27, 2018
2fb50a4
Minor fixes to the new changes
cheenamalhotra Jun 27, 2018
bcfbe33
Fix for failing tests
cheenamalhotra Jun 27, 2018
c373d90
More changes for compliance
cheenamalhotra Jun 27, 2018
ef3157f
Add Javadocs and class headers
cheenamalhotra Jun 27, 2018
a93420b
Fixed Malformed HTML Error in Javadocs
cheenamalhotra Jun 27, 2018
e6f6e4a
javadoc changes
peterbae Jun 27, 2018
8972f66
more javadoc changes to make the abbreviations more clear
peterbae Jun 27, 2018
21945e5
fix unchecked warning issue
peterbae Jun 28, 2018
e6bef4e
Change HashKey in the driver to 256 Hash
cheenamalhotra Jun 28, 2018
0ad3a26
Add Interface back to SQLServerConnection43 class
cheenamalhotra Jun 28, 2018
2145eab
Revert "Change HashKey in the driver to 256 Hash"
cheenamalhotra Jun 28, 2018
ef0f748
Changes for exceptions to throw SQLServerException type
cheenamalhotra Jun 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems a bit inconsistent - why is this spelled out "WellKnownText" when the others are all wkt?

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