Permalink
Browse files

style: use java generics instead of raw types

Since the source is now Java 1.6 or later we can replace raw types with
generics. The code base already uses generics but very sparsingly.

Due to the design of Java generics and type erasure this should all be
backwards compatible.

closes #463
  • Loading branch information...
marschall authored and vlsi committed Dec 25, 2015
1 parent 9c43d27 commit c10acf00e4d54de99bef21c947cbad1e686175f6
Showing with 395 additions and 398 deletions.
  1. +8 −8 pgjdbc/src/main/java/org/postgresql/Driver.java
  2. +2 −1 pgjdbc/src/main/java/org/postgresql/PGConnection.java
  3. +2 −2 pgjdbc/src/main/java/org/postgresql/core/BaseStatement.java
  4. +2 −2 pgjdbc/src/main/java/org/postgresql/core/Encoding.java
  5. +1 −1 pgjdbc/src/main/java/org/postgresql/core/ResultHandler.java
  6. +5 −5 pgjdbc/src/main/java/org/postgresql/core/SetupQueryRunner.java
  7. +5 −3 pgjdbc/src/main/java/org/postgresql/core/TypeInfo.java
  8. +2 −2 pgjdbc/src/main/java/org/postgresql/core/v2/ProtocolConnectionImpl.java
  9. +7 −7 pgjdbc/src/main/java/org/postgresql/core/v2/QueryExecutorImpl.java
  10. +2 −2 pgjdbc/src/main/java/org/postgresql/core/v3/Portal.java
  11. +3 −3 pgjdbc/src/main/java/org/postgresql/core/v3/ProtocolConnectionImpl.java
  12. +23 −23 pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
  13. +2 −2 pgjdbc/src/main/java/org/postgresql/core/v3/SimpleQuery.java
  14. +8 −8 pgjdbc/src/main/java/org/postgresql/ds/PGPoolingDataSource.java
  15. +1 −1 pgjdbc/src/main/java/org/postgresql/ds/common/PGObjectFactory.java
  16. +2 −2 pgjdbc/src/main/java/org/postgresql/fastpath/Fastpath.java
  17. +5 −5 pgjdbc/src/main/java/org/postgresql/gss/MakeGSS.java
  18. +4 −4 pgjdbc/src/main/java/org/postgresql/jdbc/AbstractBlobClob.java
  19. +43 −43 pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions.java
  20. +13 −13 pgjdbc/src/main/java/org/postgresql/jdbc/PgArray.java
  21. +2 −2 pgjdbc/src/main/java/org/postgresql/jdbc/PgCallableStatement.java
  22. +14 −14 pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java
  23. +76 −80 pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
  24. +32 −32 pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
  25. +11 −11 pgjdbc/src/main/java/org/postgresql/jdbc/PgStatement.java
  26. +29 −32 pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java
  27. +1 −1 pgjdbc/src/main/java/org/postgresql/jdbc/UUIDArrayAssistant.java
  28. +1 −1 pgjdbc/src/main/java/org/postgresql/jdbc2/ArrayAssistant.java
  29. +2 −2 pgjdbc/src/main/java/org/postgresql/jdbc2/ArrayAssistantRegistry.java
  30. +1 −1 pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java
  31. +2 −2 pgjdbc/src/main/java/org/postgresql/ssl/MakeSSL.java
  32. +3 −2 pgjdbc/src/main/java/org/postgresql/ssl/jdbc4/LazyKeyManager.java
  33. +2 −2 pgjdbc/src/main/java/org/postgresql/ssl/jdbc4/LibPQFactory.java
  34. +8 −10 pgjdbc/src/main/java/org/postgresql/util/HStoreConverter.java
  35. +4 −4 pgjdbc/src/main/java/org/postgresql/util/PGtokenizer.java
  36. +28 −28 pgjdbc/src/main/java/org/postgresql/util/ServerErrorMessage.java
  37. +2 −2 pgjdbc/src/main/java/org/postgresql/xa/PGXAConnection.java
  38. +1 −1 pgjdbc/src/main/java/org/postgresql/xa/PGXADataSourceFactory.java
  39. +4 −4 pgjdbc/src/test/java/org/postgresql/test/extensions/HStoreTest.java
  40. +4 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/ConnectionTest.java
  41. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
  42. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/GetXXXTest.java
  43. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
  44. +3 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
  45. +12 −12 pgjdbc/src/test/java/org/postgresql/test/ssl/SslTest.java
  46. +9 −9 pgjdbc/src/test/java/org/postgresql/test/util/MiniJndiContext.java
  47. +1 −1 pgjdbc/src/test/java/org/postgresql/test/util/MiniJndiContextFactory.java
@@ -86,9 +86,9 @@ private synchronized Properties getDefaultProperties() throws IOException {
// privileges.
try
{
defaultProperties = (Properties)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws IOException {
defaultProperties =
AccessController.doPrivileged(new PrivilegedExceptionAction<Properties>() {
public Properties run() throws IOException {
return loadDefaultProperties();
}
});
@@ -151,15 +151,15 @@ private Properties loadDefaultProperties() throws IOException {
// in later files in the classpath to override settings specified in
// earlier files. To do this we've got to read the returned
// Enumeration into temporary storage.
ArrayList urls = new ArrayList();
Enumeration urlEnum = cl.getResources("org/postgresql/driverconfig.properties");
ArrayList<URL> urls = new ArrayList<URL>();
Enumeration<URL> urlEnum = cl.getResources("org/postgresql/driverconfig.properties");
while (urlEnum.hasMoreElements())
{
urls.add(urlEnum.nextElement());
}
for (int i=urls.size()-1; i>=0; i--) {
URL url = (URL)urls.get(i);
URL url = urls.get(i);
logger.debug("Loading driver configuration from: " + url);
InputStream is = url.openStream();
merged.load(is);
@@ -249,7 +249,7 @@ private Properties loadDefaultProperties() throws IOException {
Properties props = new Properties(defaults);
if (info != null)
{
for (Enumeration e = info.propertyNames(); e.hasMoreElements(); )
for (Enumeration<?> e = info.propertyNames(); e.hasMoreElements(); )
{
String propName = (String)e.nextElement();
String propValue = info.getProperty(propName);
@@ -675,7 +675,7 @@ private static long timeout(Properties props)
* @return PSQLException with a localized message giving the complete
* description of the unimplemeted function
*/
public static SQLFeatureNotSupportedException notImplemented(Class callClass, String functionName)
public static SQLFeatureNotSupportedException notImplemented(Class<?> callClass, String functionName)
{
return new SQLFeatureNotSupportedException(GT.tr("Method {0} is not yet implemented.", callClass.getName() + "." + functionName),
PSQLState.NOT_IMPLEMENTED.getState());
@@ -11,6 +11,7 @@
import org.postgresql.copy.CopyManager;
import org.postgresql.fastpath.Fastpath;
import org.postgresql.largeobject.LargeObjectManager;
import org.postgresql.util.PGobject;
/**
* This interface defines the public PostgreSQL extensions to
@@ -98,7 +99,7 @@
*
* @see org.postgresql.util.PGobject
*/
public void addDataType(String type, Class klass)
public void addDataType(String type, Class<? extends PGobject> klass)
throws SQLException;
/**
@@ -25,7 +25,7 @@
* @return the new ResultSet
* @throws SQLException if something goes wrong
*/
public ResultSet createDriverResultSet(Field[] fields, List tuples) throws SQLException;
public ResultSet createDriverResultSet(Field[] fields, List<byte[][]> tuples) throws SQLException;
/**
* Create a resultset from data retrieved from the server.
@@ -37,7 +37,7 @@
* @return the new ResultSet
* @throws SQLException if something goes wrong
*/
public ResultSet createResultSet(Query originalQuery, Field[] fields, List tuples, ResultCursor cursor) throws SQLException;
public ResultSet createResultSet(Query originalQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) throws SQLException;
/**
* Execute a query, passing additional query flags.
@@ -26,7 +26,7 @@
/*
* Preferred JVM encodings for backend encodings.
*/
private static final HashMap encodings = new HashMap();
private static final HashMap<String, String[]> encodings = new HashMap<String, String[]>();
static {
//Note: this list should match the set of supported server
@@ -125,7 +125,7 @@ public static Encoding getDatabaseEncoding(String databaseEncoding)
// encoding in the JVM we use that. Otherwise we fall back
// to the default encoding of the JVM.
String[] candidates = (String[]) encodings.get(databaseEncoding);
String[] candidates = encodings.get(databaseEncoding);
if (candidates != null)
{
for (String candidate : candidates) {
@@ -40,7 +40,7 @@
* @param cursor a cursor to use to fetch additional data;
* <code>null</code> if no further results are present.
*/
void handleResultRows(Query fromQuery, Field[] fields, List tuples, ResultCursor cursor);
void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor);
/**
* Called when a query that did not return a resultset completes.
@@ -24,18 +24,18 @@
private static class SimpleResultHandler implements ResultHandler {
private SQLException error;
private List tuples;
private List<byte[][]> tuples;
private final ProtocolConnection protoConnection;
SimpleResultHandler(ProtocolConnection protoConnection) {
this.protoConnection = protoConnection;
}
List getResults() {
List<byte[][]> getResults() {
return tuples;
}
public void handleResultRows(Query fromQuery, Field[] fields, List tuples, ResultCursor cursor) {
public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) {
this.tuples = tuples;
}
@@ -81,11 +81,11 @@ public void handleCompletion() throws SQLException {
if (!wantResults)
return null;
List tuples = handler.getResults();
List<byte[][]> tuples = handler.getResults();
if (tuples == null || tuples.size() != 1)
throw new PSQLException(GT.tr("An unexpected result was returned by a query."), PSQLState.CONNECTION_UNABLE_TO_CONNECT);
return (byte[][]) tuples.get(0);
return tuples.get(0);
}
}
@@ -10,11 +10,13 @@
import java.sql.SQLException;
import java.util.Iterator;
import org.postgresql.util.PGobject;
public interface TypeInfo
{
public void addCoreType(String pgTypeName, Integer oid, Integer sqlType, String javaClass, Integer arrayOid);
public void addDataType(String type, Class klass) throws SQLException;
public void addDataType(String type, Class<? extends PGobject> klass) throws SQLException;
/**
* Look up the SQL typecode for a given type oid.
@@ -83,9 +85,9 @@
*/
public char getArrayDelimiter(int oid) throws SQLException;
public Iterator getPGTypeNamesWithSQLTypes();
public Iterator<String> getPGTypeNamesWithSQLTypes();
public Class getPGobject(String type);
public Class<? extends PGobject> getPGobject(String type);
public String getJavaClass(int oid) throws SQLException;
@@ -66,7 +66,7 @@ public synchronized int getTransactionState()
}
public synchronized PGNotification[] getNotifications() throws SQLException {
PGNotification[] array = (PGNotification[])notifications.toArray(new PGNotification[notifications.size()]);
PGNotification[] array = notifications.toArray(new PGNotification[notifications.size()]);
notifications.clear();
return array;
}
@@ -246,7 +246,7 @@ public void abort() {
private boolean closed = false;
private final ArrayList notifications = new ArrayList();
private final ArrayList<PGNotification> notifications = new ArrayList<PGNotification>();
private final PGStream pgStream;
private final String user;
@@ -62,7 +62,7 @@ public ParameterList createFastpathParameters(int count) {
private boolean sawBegin = false;
private SQLException sqle = null;
public void handleResultRows(Query fromQuery, Field[] fields, List tuples, ResultCursor cursor) {
public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) {
}
public void handleCommandStatus(String status, int updateCount, long insertOID) {
@@ -267,7 +267,7 @@ public synchronized void execute(Query[] queries,
{
final ResultHandler delegateHandler = handler;
handler = new ResultHandler() {
public void handleResultRows(Query fromQuery, Field[] fields, List tuples, ResultCursor cursor) {
public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) {
delegateHandler.handleResultRows(fromQuery, fields, tuples, cursor);
}
@@ -325,7 +325,7 @@ private void execute(V2Query query,
handler = new ResultHandler() {
private boolean sawBegin = false;
public void handleResultRows(Query fromQuery, Field[] fields, List tuples, ResultCursor cursor) {
public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) {
if (sawBegin)
delegateHandler.handleResultRows(fromQuery, fields, tuples, cursor);
}
@@ -413,7 +413,7 @@ protected void sendQuery(V2Query query, SimpleParameterList params, String query
protected void processResults(Query originalQuery, ResultHandler handler, int maxRows, int flags) throws IOException {
boolean bothRowsAndStatus = (flags & QueryExecutor.QUERY_BOTH_ROWS_AND_STATUS) != 0;
Field[] fields = null;
List tuples = null;
List<byte[][]> tuples = null;
boolean endQuery = false;
while (!endQuery)
@@ -434,7 +434,7 @@ protected void processResults(Query originalQuery, ResultHandler handler, int ma
if (logger.logDebug())
logger.debug(" <=BE BinaryRow");
Object tuple = null;
byte[][] tuple = null;
try {
tuple = pgStream.ReceiveTupleV2(fields.length, true);
} catch(OutOfMemoryError oome) {
@@ -480,7 +480,7 @@ protected void processResults(Query originalQuery, ResultHandler handler, int ma
if (logger.logDebug())
logger.debug(" <=BE DataRow");
Object tuple = null;
byte[][] tuple = null;
try {
tuple = pgStream.ReceiveTupleV2(fields.length, false);
} catch(OutOfMemoryError oome) {
@@ -518,7 +518,7 @@ protected void processResults(Query originalQuery, ResultHandler handler, int ma
case 'T': // MetaData Field Description
fields = receiveFields();
tuples = new ArrayList();
tuples = new ArrayList<byte[][]>();
break;
case 'Z':
@@ -46,7 +46,7 @@ SimpleQuery getQuery() {
return query;
}
void setCleanupRef(PhantomReference cleanupRef) {
void setCleanupRef(PhantomReference<?> cleanupRef) {
this.cleanupRef = cleanupRef;
}
@@ -63,5 +63,5 @@ public String toString() {
private final SimpleQuery query;
private final String portalName;
private final byte[] encodedName;
private PhantomReference cleanupRef;
private PhantomReference<?> cleanupRef;
}
@@ -71,7 +71,7 @@ public synchronized int getTransactionState()
}
public synchronized PGNotification[] getNotifications() throws SQLException {
PGNotification[] array = (PGNotification[])notifications.toArray(new PGNotification[notifications.size()]);
PGNotification[] array = notifications.toArray(new PGNotification[notifications.size()]);
notifications.clear();
return array;
}
@@ -219,7 +219,7 @@ public boolean useBinaryForReceive(int oid) {
return useBinaryForOids.contains(oid);
}
public void setBinaryReceiveOids(Set oids) {
public void setBinaryReceiveOids(Set<Integer> oids) {
useBinaryForOids.clear();
useBinaryForOids.addAll(oids);
}
@@ -266,7 +266,7 @@ public void abort() {
private boolean closed = false;
private final ArrayList notifications = new ArrayList();
private final ArrayList<PGNotification> notifications = new ArrayList<PGNotification>();
private final PGStream pgStream;
private final String user;
Oops, something went wrong.

0 comments on commit c10acf0

Please sign in to comment.