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

Remove explicit boxing and unboxing #84

Merged
merged 3 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 31 additions & 31 deletions AppVeyorJCE/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# JCE chocolatey package
### Disclaimers:
1. All contents within this directory originate from [this GitHub project](https://github.com/TobseF/jce-chocolatey-package). This project was added to allow us to test the Always Encrypted feature on AppVeyor builds.
2. This is not an official project of Oracle. It\`s only easy of the manual installation: It downloads the JCE from oracle.com and unpacks it to the installed JDK.
[Chocolatey](https://chocolatey.org/) package for the [JCE (Unlimited Strength Java Cryptography Extension Policy Files)](http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html)
This chocolatey package adds the JCE to latest installed Java SDK. The The `JAVA_HOME` environment variable has to point to the JDK. If `JAVA_HOME` is not set, nothing will be changed. The original files are backuped (renamed to `*_old`) and can be reverted at any time. This package is a perfect addion to the [JDK8 package](https://chocolatey.org/packages/jdk8).
#### Install with [Chocolatey](https://chocolatey.org/)
```PowerShell
choco install jce -y
```
#### Build from source:
1. Install [Chocolatey](https://chocolatey.org/).
2. Open cmd with admin rights in jce package directory.
3. Pack NuGet Package (.nupkg).
```PowerShell
cpack
```
4. Install JCE NuGet Package.
```PowerShell
choco install jce -fdv -s . -y
```
# JCE chocolatey package

### Disclaimers:
1. All contents within this directory originate from [this GitHub project](https://github.com/TobseF/jce-chocolatey-package). This project was added to allow us to test the Always Encrypted feature on AppVeyor builds.

2. This is not an official project of Oracle. It\`s only easy of the manual installation: It downloads the JCE from oracle.com and unpacks it to the installed JDK.


[Chocolatey](https://chocolatey.org/) package for the [JCE (Unlimited Strength Java Cryptography Extension Policy Files)](http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html)

This chocolatey package adds the JCE to latest installed Java SDK. The The `JAVA_HOME` environment variable has to point to the JDK. If `JAVA_HOME` is not set, nothing will be changed. The original files are backuped (renamed to `*_old`) and can be reverted at any time. This package is a perfect addion to the [JDK8 package](https://chocolatey.org/packages/jdk8).

#### Install with [Chocolatey](https://chocolatey.org/)
```PowerShell
choco install jce -y
```

#### Build from source:
1. Install [Chocolatey](https://chocolatey.org/).
2. Open cmd with admin rights in jce package directory.
3. Pack NuGet Package (.nupkg).
```PowerShell
cpack
```
4. Install JCE NuGet Package.
```PowerShell
choco install jce -fdv -s . -y
```



2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Object getValue(JDBCType jdbcType,
}

int getInt(TDSReader tdsReader) throws SQLServerException {
return ((Integer) getValue(JDBCType.INTEGER, null, null, tdsReader)).intValue();
return (Integer) getValue(JDBCType.INTEGER, null, null, tdsReader);
}

void updateValue(JDBCType jdbcType,
Expand Down
84 changes: 42 additions & 42 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ static final Object convertIntegerToObject(int intValue,
StreamType streamType) {
switch (jdbcType) {
case INTEGER:
return new Integer(intValue);
return intValue;
case SMALLINT: // 2.21 small and tinyint returned as short
case TINYINT:
return new Short((short) intValue);
return (short) intValue;
case BIT:
case BOOLEAN:
return new Boolean(0 != intValue);
return 0 != intValue;
case BIGINT:
return new Long(intValue);
return (long) intValue;
case DECIMAL:
case NUMERIC:
case MONEY:
case SMALLMONEY:
return new BigDecimal(Integer.toString(intValue));
case FLOAT:
case DOUBLE:
return new Double(intValue);
return (double) intValue;
case REAL:
return new Float(intValue);
return (float) intValue;
case BINARY:
return convertIntToBytes(intValue, valueLength);
default:
Expand All @@ -99,25 +99,25 @@ static final Object convertLongToObject(long longVal,
StreamType streamType) {
switch (jdbcType) {
case BIGINT:
return new Long(longVal);
return longVal;
case INTEGER:
return new Integer((int) longVal);
return (int) longVal;
case SMALLINT: // small and tinyint returned as short
case TINYINT:
return new Short((short) longVal);
return (short) longVal;
case BIT:
case BOOLEAN:
return new Boolean(0 != longVal);
return 0 != longVal;
case DECIMAL:
case NUMERIC:
case MONEY:
case SMALLMONEY:
return new BigDecimal(Long.toString(longVal));
case FLOAT:
case DOUBLE:
return new Double(longVal);
return (double) longVal;
case REAL:
return new Float(longVal);
return (float) longVal;
case BINARY:
byte[] convertedBytes = convertLongToBytes(longVal);
int bytesToReturnLength;
Expand Down Expand Up @@ -152,23 +152,23 @@ static final Object convertLongToObject(long longVal,
case VARBINARY:
switch (baseSSType) {
case BIGINT:
return new Long(longVal);
return longVal;
case INTEGER:
return new Integer((int) longVal);
return (int) longVal;
case SMALLINT: // small and tinyint returned as short
case TINYINT:
return new Short((short) longVal);
return (short) longVal;
case BIT:
return new Boolean(0 != longVal);
return 0 != longVal;
case DECIMAL:
case NUMERIC:
case MONEY:
case SMALLMONEY:
return new BigDecimal(Long.toString(longVal));
case FLOAT:
return new Double(longVal);
return (double) longVal;
case REAL:
return new Float(longVal);
return (float) longVal;
case BINARY:
return convertLongToBytes(longVal);
default:
Expand Down Expand Up @@ -214,25 +214,25 @@ static final Object convertFloatToObject(float floatVal,
StreamType streamType) {
switch (jdbcType) {
case REAL:
return new Float(floatVal);
return floatVal;
case INTEGER:
return new Integer((int) floatVal);
return (int) floatVal;
case SMALLINT: // small and tinyint returned as short
case TINYINT:
return new Short((short) floatVal);
return (short) floatVal;
case BIT:
case BOOLEAN:
return new Boolean(0 != Float.compare(0.0f, floatVal));
return 0 != Float.compare(0.0f, floatVal);
case BIGINT:
return new Long((long) floatVal);
return (long) floatVal;
case DECIMAL:
case NUMERIC:
case MONEY:
case SMALLMONEY:
return new BigDecimal(Float.toString(floatVal));
case FLOAT:
case DOUBLE:
return new Double((new Float(floatVal)).doubleValue());
return (new Float(floatVal)).doubleValue();
case BINARY:
return convertIntToBytes(Float.floatToRawIntBits(floatVal), 4);
default:
Expand Down Expand Up @@ -273,19 +273,19 @@ static final Object convertDoubleToObject(double doubleVal,
switch (jdbcType) {
case FLOAT:
case DOUBLE:
return new Double(doubleVal);
return doubleVal;
case REAL:
return new Float((new Double(doubleVal)).floatValue());
return (new Double(doubleVal)).floatValue();
case INTEGER:
return new Integer((int) doubleVal);
return (int) doubleVal;
case SMALLINT: // small and tinyint returned as short
case TINYINT:
return new Short((short) doubleVal);
return (short) doubleVal;
case BIT:
case BOOLEAN:
return new Boolean(0 != Double.compare(0.0d, doubleVal));
return 0 != Double.compare(0.0d, doubleVal);
case BIGINT:
return new Long((long) doubleVal);
return (long) doubleVal;
case DECIMAL:
case NUMERIC:
case MONEY:
Expand Down Expand Up @@ -355,19 +355,19 @@ static final Object convertBigDecimalToObject(BigDecimal bigDecimalVal,
return bigDecimalVal;
case FLOAT:
case DOUBLE:
return new Double(bigDecimalVal.doubleValue());
return bigDecimalVal.doubleValue();
case REAL:
return new Float(bigDecimalVal.floatValue());
return bigDecimalVal.floatValue();
case INTEGER:
return new Integer(bigDecimalVal.intValue());
return bigDecimalVal.intValue();
case SMALLINT: // small and tinyint returned as short
case TINYINT:
return new Short(bigDecimalVal.shortValue());
return bigDecimalVal.shortValue();
case BIT:
case BOOLEAN:
return new Boolean(0 != bigDecimalVal.compareTo(BigDecimal.valueOf(0)));
return 0 != bigDecimalVal.compareTo(BigDecimal.valueOf(0));
case BIGINT:
return new Long(bigDecimalVal.longValue());
return bigDecimalVal.longValue();
case BINARY:
return convertBigDecimalToBytes(bigDecimalVal, bigDecimalVal.scale());
default:
Expand Down Expand Up @@ -400,19 +400,19 @@ static final Object convertMoneyToObject(BigDecimal bigDecimalVal,
return bigDecimalVal;
case FLOAT:
case DOUBLE:
return new Double(bigDecimalVal.doubleValue());
return bigDecimalVal.doubleValue();
case REAL:
return new Float(bigDecimalVal.floatValue());
return bigDecimalVal.floatValue();
case INTEGER:
return new Integer(bigDecimalVal.intValue());
return bigDecimalVal.intValue();
case SMALLINT: // small and tinyint returned as short
case TINYINT:
return new Short(bigDecimalVal.shortValue());
return bigDecimalVal.shortValue();
case BIT:
case BOOLEAN:
return new Boolean(0 != bigDecimalVal.compareTo(BigDecimal.valueOf(0)));
return 0 != bigDecimalVal.compareTo(BigDecimal.valueOf(0));
case BIGINT:
return new Long(bigDecimalVal.longValue());
return bigDecimalVal.longValue();
case BINARY:
return convertToBytes(bigDecimalVal, bigDecimalVal.scale(), numberOfBytes);
default:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static TDSType valueOf(int intValue) throws IllegalArgumentException {

if (!(0 <= intValue && intValue < valuesTypes.length) || null == (tdsType = valuesTypes[intValue])) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_unknownSSType"));
Object[] msgArgs = {new Integer(intValue)};
Object[] msgArgs = {intValue};
throw new IllegalArgumentException(form.format(msgArgs));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void setupInfo(SQLServerConnection con) throws SQLServerException {
instancePort = con.getInstancePort(failoverPartner, instanceValue);

try {
portNumber = (new Integer(instancePort)).intValue();
portNumber = new Integer(instancePort);
}
catch (NumberFormatException e) {
// Should not get here as the server should give a proper port number anyway.
Expand Down
Loading