Skip to content

Commit

Permalink
[misc] checkstyle compatibility with java 6
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jul 24, 2017
1 parent 38b1280 commit 0736a5e
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 35 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<jna.version>4.2.1</jna.version>
<version.template.file>src/main/resources/Version.java.template</version.template.file>
<version.file>src/main/java/org/mariadb/jdbc/internal/util/constant/Version.java</version.file>
<checkstyleVersion>6.11.2</checkstyleVersion>
<checkstyle.plugin.version>2.16</checkstyle.plugin.version>
<checkstyleVersion>6.1.1</checkstyleVersion>
<checkstyle.plugin.version>2.15</checkstyle.plugin.version>
<driver.version.major>1</driver.version.major>
<driver.version.minor>6</driver.version.minor>
<driver.version.patch>3</driver.version.patch>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/mariadb/jdbc/MariaDbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ public PreparedStatement prepareStatement(final String sql,
* support precompilation. In this case, the statement may not be sent to the database until the <code>PreparedStatement</code> object is
* executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.</p>
* <p>Result sets created using the returned <code>PreparedStatement</code> object will by default be type <code>TYPE_FORWARD_ONLY</code> and
* have a concurrency level of <code>CONCUR_READ_ONLY</code>. The holdability of the created result sets can be determined by calling {@link
* #getHoldability}.</p>
* have a concurrency level of <code>CONCUR_READ_ONLY</code>. The holdability of the created result sets can be determined by calling
* {@link #getHoldability}.</p>
*
* @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
* @param autoGeneratedKeys a flag indicating whether auto-generated keys should be returned; one of
Expand Down Expand Up @@ -384,8 +384,8 @@ public PreparedStatement prepareStatement(final String sql, final int autoGenera
* executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.</p>
* <p>
* Result sets created using the returned <code>PreparedStatement</code> object will by default be type <code>TYPE_FORWARD_ONLY</code> and have a
* concurrency level of <code>CONCUR_READ_ONLY</code>. The holdability of the created result sets can be determined by calling {@link
* #getHoldability}.</p>
* concurrency level of <code>CONCUR_READ_ONLY</code>. The holdability of the created result sets can be determined by calling
* {@link #getHoldability}.</p>
*
* @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
* @param columnIndexes an array of column indexes indicating the columns that should be returned from the inserted row or rows
Expand All @@ -411,8 +411,8 @@ public PreparedStatement prepareStatement(final String sql, final int[] columnIn
* support precompilation. In this case, the statement may not be sent to the database until the <code>PreparedStatement</code> object is
* executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.</p>
* <p>Result sets created using the returned <code>PreparedStatement</code> object will by default be type <code>TYPE_FORWARD_ONLY</code> and
* have a concurrency level of <code>CONCUR_READ_ONLY</code>. The holdability of the created result sets can be determined by calling {@link
* #getHoldability}.</p>
* have a concurrency level of <code>CONCUR_READ_ONLY</code>. The holdability of the created result sets can be determined by calling
* {@link #getHoldability}.</p>
*
* @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
* @param columnNames an array of column names indicating the columns that should be returned from the inserted row or rows
Expand Down Expand Up @@ -931,8 +931,8 @@ public int getHoldability() throws SQLException {
/**
* Changes the default holdability of <code>ResultSet</code> objects created using this <code>Connection</code>
* object to the given holdability.
* The default holdability of <code>ResultSet</code> objects can be be determined by invoking {@link
* DatabaseMetaData#getResultSetHoldability}.
* The default holdability of <code>ResultSet</code> objects can be be determined by invoking
* {@link DatabaseMetaData#getResultSetHoldability}.
*
* @param holdability a <code>ResultSet</code> holdability constant; one of
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ public void close() throws SQLException {
}

//keep garbage easy
for (int i = 0; i < data.length; i++) data[i] = null;
for (int i = 0; i < data.length; i++) {
data[i] = null;
}

if (statement != null) {
statement.checkCloseOnCompletion(this);
Expand Down Expand Up @@ -3624,16 +3626,16 @@ private Date binaryDate(ColumnInformation columnInfo, Calendar cal) throws SQLEx

Date dt;
synchronized (calendar) {
calendar.clear();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
dt = new Date(calendar.getTimeInMillis());
}
calendar.clear();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
dt = new Date(calendar.getTimeInMillis());
}
return dt;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public static int sendRewriteCmd(final PacketOutputStream pos, final List<byte[]
pos.write(secondPart, 0, secondPart.length);

int staticLength = 1;
for (int i = 0; i < queryParts.size(); i++) staticLength += queryParts.get(i).length;
for (int i = 0; i < queryParts.size(); i++) {
staticLength += queryParts.get(i).length;
}

for (int i = 0; i < paramCount; i++) {
parameters[i].writeTo(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
public class AuroraListener extends MastersSlavesListener {

private final Logger log = Logger.getLogger(AuroraListener.class.getName());
private final Pattern auroraDNSPattern = Pattern.compile("(.+)\\.(cluster-)?([a-zA-Z0-9]+\\.[a-zA-Z0-9\\-]+\\.rds\\.amazonaws\\.com)",
private final Pattern auroraDnsPattern = Pattern.compile("(.+)\\.(cluster-)?([a-zA-Z0-9]+\\.[a-zA-Z0-9\\-]+\\.rds\\.amazonaws\\.com)",
Pattern.CASE_INSENSITIVE);
private final HostAddress clusterHostAddress;
private String clusterDnsSuffix = null;
Expand Down Expand Up @@ -105,7 +105,7 @@ private HostAddress findClusterHostAddress(UrlParser urlParser) throws SQLExcept
List<HostAddress> hostAddresses = urlParser.getHostAddresses();
Matcher matcher;
for (HostAddress hostAddress : hostAddresses) {
matcher = auroraDNSPattern.matcher(hostAddress.host);
matcher = auroraDnsPattern.matcher(hostAddress.host);
if (matcher.find()) {

if (clusterDnsSuffix != null) {
Expand Down Expand Up @@ -385,7 +385,7 @@ private HostAddress searchForMasterHostAddress(Protocol protocol, List<HostAddre
Matcher matcher;
if (masterHostName != null) {
for (HostAddress hostAddress : loopAddress) {
matcher = auroraDNSPattern.matcher(hostAddress.host);
matcher = auroraDnsPattern.matcher(hostAddress.host);
if (hostAddress.host.startsWith(masterHostName) && !matcher.find()) {
return hostAddress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ public void writeBytes(byte value, int len) throws IOException {
return;
}

for (int i = pos; i < pos + len; i++) buf[i] = value;
for (int i = pos; i < pos + len; i++) {
buf[i] = value;
}
pos += len;
}

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/mariadb/jdbc/internal/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,15 @@ public static void writeHex(byte[] bytes, int offset, int dataLength, StringBuil
int remaining = posHexa;
if (remaining > 0) {
if (remaining < 8) {
for (; remaining < 8; remaining++) outputBuilder.append(" ");
for (; remaining < 8; remaining++) {
outputBuilder.append(" ");
}
outputBuilder.append(" ");
}

for (; remaining < 16; remaining++) outputBuilder.append(" ");
for (; remaining < 16; remaining++) {
outputBuilder.append(" ");
}

outputBuilder.append(" ")
.append(hexaValue, 0, posHexa)
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/org/mariadb/jdbc/ExecuteBatchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public class ExecuteBatchTest extends BaseTest {

static {
char[] chars = new char[100];
for (int i = 27; i < 127; i++) chars[i - 27] = (char) i;
for (int i = 27; i < 127; i++) {
chars[i - 27] = (char) i;
}
oneHundredLengthString = new String(chars);
}

Expand Down
8 changes: 6 additions & 2 deletions src/test/java/org/mariadb/jdbc/ResultSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,9 @@ private void floatDoubleCheckResult(ResultSet rs) throws SQLException {
//getDouble
//supported JDBC type :
//TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, BOOLEAN, CHAR, VARCHAR, LONGVARCHAR
for (int i = 1; i < 11; i++) rs.getDouble(i);
for (int i = 1; i < 11; i++) {
rs.getDouble(i);
}
for (int i = 11; i < 16; i++) {
try {
rs.getDouble(i);
Expand All @@ -839,7 +841,9 @@ private void floatDoubleCheckResult(ResultSet rs) throws SQLException {
//getFloat
//supported JDBC type :
//TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, BOOLEAN, CHAR, VARCHAR, LONGVARCHAR
for (int i = 1; i < 11; i++) rs.getDouble(i);
for (int i = 1; i < 11; i++) {
rs.getDouble(i);
}
for (int i = 11; i < 16; i++) {
try {
rs.getFloat(i);
Expand Down
8 changes: 4 additions & 4 deletions src/test/resources/style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<property name="localeCountry" value="EN"/>
<property name="localeLanguage" value="en"/>

<property name="fileExtensions" value="java, properties, xml"/>
<!--<property name="fileExtensions" value="java, properties, xml"/>-->
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
Expand Down Expand Up @@ -90,9 +90,9 @@
<property name="option" value="TEXT"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces">
<property name="allowSingleLineStatement" value="true"/>
</module>
<!--<module name="NeedBraces">-->
<!--<property name="allowSingleLineStatement" value="true"/>-->
<!--</module>-->
<module name="LeftCurly">
<property name="maxLineLength" value="150"/>
</module>
Expand Down

0 comments on commit 0736a5e

Please sign in to comment.