Skip to content

Commit

Permalink
style: code cleanup and Java 5' features
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexElin authored and vlsi committed Jul 6, 2016
1 parent af50d0b commit 8e8dbab
Show file tree
Hide file tree
Showing 27 changed files with 179 additions and 203 deletions.
10 changes: 3 additions & 7 deletions pgjdbc/src/main/java/org/postgresql/Driver.java
Expand Up @@ -417,10 +417,7 @@ private static Connection makeConnection(String url, Properties props) throws SQ
* @see java.sql.Driver#acceptsURL * @see java.sql.Driver#acceptsURL
*/ */
public boolean acceptsURL(String url) { public boolean acceptsURL(String url) {
if (parseURL(url, null) == null) { return parseURL(url, null) != null;
return false;
}
return true;
} }


/** /**
Expand Down Expand Up @@ -567,9 +564,8 @@ public static Properties parseURL(String url, Properties defaults) {


// parse the args part of the url // parse the args part of the url
String[] args = l_urlArgs.split("&"); String[] args = l_urlArgs.split("&");
for (int i = 0; i < args.length; ++i) { for (String token : args) {
String token = args[i]; if (token.isEmpty()) {
if (token.length() == 0) {
continue; continue;
} }
int l_pos = token.indexOf('='); int l_pos = token.indexOf('=');
Expand Down
26 changes: 13 additions & 13 deletions pgjdbc/src/main/java/org/postgresql/PGConnection.java
Expand Up @@ -29,7 +29,7 @@ public interface PGConnection {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 7.3 * @since 7.3
*/ */
public PGNotification[] getNotifications() throws SQLException; PGNotification[] getNotifications() throws SQLException;


/** /**
* This returns the COPY API for the current connection. * This returns the COPY API for the current connection.
Expand All @@ -38,7 +38,7 @@ public interface PGConnection {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 8.4 * @since 8.4
*/ */
public CopyManager getCopyAPI() throws SQLException; CopyManager getCopyAPI() throws SQLException;


/** /**
* This returns the LargeObject API for the current connection. * This returns the LargeObject API for the current connection.
Expand All @@ -47,7 +47,7 @@ public interface PGConnection {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 7.3 * @since 7.3
*/ */
public LargeObjectManager getLargeObjectAPI() throws SQLException; LargeObjectManager getLargeObjectAPI() throws SQLException;


/** /**
* This returns the Fastpath API for the current connection. * This returns the Fastpath API for the current connection.
Expand All @@ -56,7 +56,7 @@ public interface PGConnection {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 7.3 * @since 7.3
*/ */
public Fastpath getFastpathAPI() throws SQLException; Fastpath getFastpathAPI() throws SQLException;


/** /**
* This allows client code to add a handler for one of org.postgresql's more unique data types. It * This allows client code to add a handler for one of org.postgresql's more unique data types. It
Expand All @@ -69,7 +69,7 @@ public interface PGConnection {
* does not work correctly for registering classes that cannot be directly loaded by * does not work correctly for registering classes that cannot be directly loaded by
* the JDBC driver's classloader. * the JDBC driver's classloader.
*/ */
public void addDataType(String type, String className); void addDataType(String type, String className);


/** /**
* This allows client code to add a handler for one of org.postgresql's more unique data types. * This allows client code to add a handler for one of org.postgresql's more unique data types.
Expand Down Expand Up @@ -100,7 +100,7 @@ public interface PGConnection {
* @see org.postgresql.util.PGobject * @see org.postgresql.util.PGobject
* @since 8.0 * @since 8.0
*/ */
public void addDataType(String type, Class<? extends PGobject> klass) throws SQLException; void addDataType(String type, Class<? extends PGobject> klass) throws SQLException;


/** /**
* Set the default statement reuse threshold before enabling server-side prepare. See * Set the default statement reuse threshold before enabling server-side prepare. See
Expand All @@ -109,7 +109,7 @@ public interface PGConnection {
* @param threshold the new threshold * @param threshold the new threshold
* @since build 302 * @since build 302
*/ */
public void setPrepareThreshold(int threshold); void setPrepareThreshold(int threshold);


/** /**
* Get the default server-side prepare reuse threshold for statements created from this * Get the default server-side prepare reuse threshold for statements created from this
Expand All @@ -118,7 +118,7 @@ public interface PGConnection {
* @return the current threshold * @return the current threshold
* @since build 302 * @since build 302
*/ */
public int getPrepareThreshold(); int getPrepareThreshold();


/** /**
* Set the default fetch size for statements created from this connection * Set the default fetch size for statements created from this connection
Expand All @@ -127,7 +127,7 @@ public interface PGConnection {
* @throws SQLException if specified negative <code>fetchSize</code> parameter * @throws SQLException if specified negative <code>fetchSize</code> parameter
* @see Statement#setFetchSize(int) * @see Statement#setFetchSize(int)
*/ */
public void setDefaultFetchSize(int fetchSize) throws SQLException; void setDefaultFetchSize(int fetchSize) throws SQLException;




/** /**
Expand All @@ -137,14 +137,14 @@ public interface PGConnection {
* @see PGProperty#DEFAULT_ROW_FETCH_SIZE * @see PGProperty#DEFAULT_ROW_FETCH_SIZE
* @see Statement#getFetchSize() * @see Statement#getFetchSize()
*/ */
public int getDefaultFetchSize(); int getDefaultFetchSize();


/** /**
* Return the process ID (PID) of the backend server process handling this connection. * Return the process ID (PID) of the backend server process handling this connection.
* *
* @return PID of backend server process. * @return PID of backend server process.
*/ */
public int getBackendPID(); int getBackendPID();


/** /**
* Return the given string suitably quoted to be used as an identifier in an SQL statement string. * Return the given string suitably quoted to be used as an identifier in an SQL statement string.
Expand All @@ -155,7 +155,7 @@ public interface PGConnection {
* @return the escaped identifier * @return the escaped identifier
* @throws SQLException if something goes wrong * @throws SQLException if something goes wrong
*/ */
public String escapeIdentifier(String identifier) throws SQLException; String escapeIdentifier(String identifier) throws SQLException;


/** /**
* Return the given string suitably quoted to be used as a string literal in an SQL statement * Return the given string suitably quoted to be used as a string literal in an SQL statement
Expand All @@ -166,5 +166,5 @@ public interface PGConnection {
* @return the quoted literal * @return the quoted literal
* @throws SQLException if something goes wrong * @throws SQLException if something goes wrong
*/ */
public String escapeLiteral(String literal) throws SQLException; String escapeLiteral(String literal) throws SQLException;
} }
6 changes: 3 additions & 3 deletions pgjdbc/src/main/java/org/postgresql/PGNotification.java
Expand Up @@ -18,15 +18,15 @@ public interface PGNotification {
* @return name of this notification * @return name of this notification
* @since 7.3 * @since 7.3
*/ */
public String getName(); String getName();


/** /**
* Returns the process id of the backend process making this notification * Returns the process id of the backend process making this notification
* *
* @return process id of the backend process making this notification * @return process id of the backend process making this notification
* @since 7.3 * @since 7.3
*/ */
public int getPID(); int getPID();


/** /**
* Returns additional information from the notifying process. This feature has only been * Returns additional information from the notifying process. This feature has only been
Expand All @@ -36,5 +36,5 @@ public interface PGNotification {
* @return additional information from the notifying process * @return additional information from the notifying process
* @since 8.0 * @since 8.0
*/ */
public String getParameter(); String getParameter();
} }
Expand Up @@ -22,5 +22,5 @@ public interface PGRefCursorResultSet {
* @deprecated As of 8.0, replaced with calling getString() on the ResultSet that this ResultSet * @deprecated As of 8.0, replaced with calling getString() on the ResultSet that this ResultSet
* was obtained from. * was obtained from.
*/ */
public String getRefCursor(); String getRefCursor();
} }
8 changes: 4 additions & 4 deletions pgjdbc/src/main/java/org/postgresql/PGResultSetMetaData.java
Expand Up @@ -22,7 +22,7 @@ public interface PGResultSetMetaData {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 8.0 * @since 8.0
*/ */
public String getBaseColumnName(int column) throws SQLException; String getBaseColumnName(int column) throws SQLException;


/** /**
* Returns the underlying table name of query result, or "" if it is unable to be determined. * Returns the underlying table name of query result, or "" if it is unable to be determined.
Expand All @@ -32,7 +32,7 @@ public interface PGResultSetMetaData {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 8.0 * @since 8.0
*/ */
public String getBaseTableName(int column) throws SQLException; String getBaseTableName(int column) throws SQLException;


/** /**
* Returns the underlying schema name of query result, or "" if it is unable to be determined. * Returns the underlying schema name of query result, or "" if it is unable to be determined.
Expand All @@ -42,7 +42,7 @@ public interface PGResultSetMetaData {
* @throws SQLException if something wrong happens * @throws SQLException if something wrong happens
* @since 8.0 * @since 8.0
*/ */
public String getBaseSchemaName(int column) throws SQLException; String getBaseSchemaName(int column) throws SQLException;


/** /**
* Is a column Text or Binary? * Is a column Text or Binary?
Expand All @@ -54,5 +54,5 @@ public interface PGResultSetMetaData {
* @see Field#TEXT_FORMAT * @see Field#TEXT_FORMAT
* @since 9.4 * @since 9.4
*/ */
public int getFormat(int column) throws SQLException; int getFormat(int column) throws SQLException;
} }
18 changes: 9 additions & 9 deletions pgjdbc/src/main/java/org/postgresql/PGStatement.java
Expand Up @@ -21,10 +21,10 @@ public interface PGStatement {
// The follow values are the nearest MAX/MIN values with hour, // The follow values are the nearest MAX/MIN values with hour,
// minute, second, millisecond set to 0 - this is used for // minute, second, millisecond set to 0 - this is used for
// -infinity / infinity representation in Java // -infinity / infinity representation in Java
public static final long DATE_POSITIVE_INFINITY = 9223372036825200000L; long DATE_POSITIVE_INFINITY = 9223372036825200000L;
public static final long DATE_NEGATIVE_INFINITY = -9223372036832400000L; long DATE_NEGATIVE_INFINITY = -9223372036832400000L;
public static final long DATE_POSITIVE_SMALLER_INFINITY = 185543533774800000L; long DATE_POSITIVE_SMALLER_INFINITY = 185543533774800000L;
public static final long DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000L; long DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000L;




/** /**
Expand All @@ -34,7 +34,7 @@ public interface PGStatement {
* @throws SQLException if something goes wrong * @throws SQLException if something goes wrong
* @since 7.3 * @since 7.3
*/ */
public long getLastOID() throws SQLException; long getLastOID() throws SQLException;


/** /**
* Turn on the use of prepared statements in the server (server side prepared statements are * Turn on the use of prepared statements in the server (server side prepared statements are
Expand All @@ -46,7 +46,7 @@ public interface PGStatement {
* @since 7.3 * @since 7.3
* @deprecated As of build 302, replaced by {@link #setPrepareThreshold(int)} * @deprecated As of build 302, replaced by {@link #setPrepareThreshold(int)}
*/ */
public void setUseServerPrepare(boolean flag) throws SQLException; void setUseServerPrepare(boolean flag) throws SQLException;


/** /**
* Checks if this statement will be executed as a server-prepared statement. A return value of * Checks if this statement will be executed as a server-prepared statement. A return value of
Expand All @@ -55,7 +55,7 @@ public interface PGStatement {
* *
* @return true if the next reuse of this statement will use a server-prepared statement * @return true if the next reuse of this statement will use a server-prepared statement
*/ */
public boolean isUseServerPrepare(); boolean isUseServerPrepare();


/** /**
* Sets the reuse threshold for using server-prepared statements. * Sets the reuse threshold for using server-prepared statements.
Expand All @@ -72,7 +72,7 @@ public interface PGStatement {
* @throws SQLException if an exception occurs while changing the threshold * @throws SQLException if an exception occurs while changing the threshold
* @since build 302 * @since build 302
*/ */
public void setPrepareThreshold(int threshold) throws SQLException; void setPrepareThreshold(int threshold) throws SQLException;


/** /**
* Gets the server-side prepare reuse threshold in use for this statement. * Gets the server-side prepare reuse threshold in use for this statement.
Expand All @@ -81,5 +81,5 @@ public interface PGStatement {
* @see #setPrepareThreshold(int) * @see #setPrepareThreshold(int)
* @since build 302 * @since build 302
*/ */
public int getPrepareThreshold(); int getPrepareThreshold();
} }
2 changes: 1 addition & 1 deletion pgjdbc/src/main/java/org/postgresql/copy/CopyIn.java
Expand Up @@ -41,5 +41,5 @@ public interface CopyIn extends CopyOperation {
* @return number of updated rows for server 8.2 or newer (see getHandledRowCount()) * @return number of updated rows for server 8.2 or newer (see getHandledRowCount())
* @throws SQLException if the operation fails. * @throws SQLException if the operation fails.
*/ */
public long endCopy() throws SQLException; long endCopy() throws SQLException;
} }
Expand Up @@ -50,5 +50,5 @@ public interface CopyOperation {
* *
* @return number of handled rows or -1 * @return number of handled rows or -1
*/ */
public long getHandledRowCount(); long getHandledRowCount();
} }

0 comments on commit 8e8dbab

Please sign in to comment.