提交 f647f3ed 编写于 作者: L lancea

7035615: Address lint warnings for javax.sql.rowset & com.sun.rowset

Reviewed-by: alanb, darcy
上级 9e158684
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -111,13 +111,13 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
private String tableName;
/**
* A <code>Vector</code> object containing the <code>Row</code>
* objects that comprise this <code>CachedRowSetImpl</code> object.
* @serial
*/
private Vector rvh;
private Vector<Object> rvh;
/**
* The current postion of the cursor in this <code>CachedRowSetImpl</code>
* object.
......@@ -293,12 +293,12 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
/**
* The Vector holding the Match Columns
*/
private Vector iMatchColumns;
private Vector<Integer> iMatchColumns;
/**
* The Vector that will hold the Match Column names.
*/
private Vector strMatchColumns;
private Vector<String> strMatchColumns;
/**
* Trigger that indicates whether the active SyncProvider is exposes the
......@@ -484,7 +484,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
private void initContainer() {
rvh = new Vector(100);
rvh = new Vector<Object>(100);
cursorPos = 0;
absolutePos = 0;
numRows = 0;
......@@ -523,12 +523,12 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
//Instantiating the vector for MatchColumns
iMatchColumns = new Vector(10);
iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
strMatchColumns = new Vector(10);
strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
......@@ -622,7 +622,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
Row currentRow;
int numCols;
int i;
Map map = getTypeMap();
Map<String, Class<?>> map = getTypeMap();
Object obj;
int mRows;
......@@ -939,14 +939,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
public void acceptChanges(Connection con) throws SyncProviderException{
try{
setConnection(con);
acceptChanges();
} catch (SyncProviderException spe) {
throw spe;
} catch(SQLException sqle){
throw new SyncProviderException(sqle.getMessage());
}
setConnection(con);
acceptChanges();
}
/**
......@@ -1289,14 +1284,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
public Collection<?> toCollection() throws SQLException {
TreeMap tMap;
int count = 0;
Row origRow;
Vector newRow;
int colCount = ((RowSetMetaDataImpl)this.getMetaData()).getColumnCount();
tMap = new TreeMap();
TreeMap<Integer, Object> tMap = new TreeMap<>();
for (int i = 0; i<numRows; i++) {
tMap.put(Integer.valueOf(i), rvh.get(i));
......@@ -1325,10 +1313,8 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
public Collection<?> toCollection(int column) throws SQLException {
Vector vec;
Row origRow;
int nRows = numRows;
vec = new Vector(nRows);
Vector<Object> vec = new Vector<>(nRows);
// create a copy
CachedRowSetImpl crsTemp;
......@@ -2953,7 +2939,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
public Object getObject(int columnIndex) throws SQLException {
Object value;
java.util.Map map;
Map<String, Class<?>> map;
// sanity check.
checkIndex(columnIndex);
......@@ -7257,7 +7243,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
Row currentRow;
int numCols;
int i;
Map map = getTypeMap();
Map<String, Class<?>> map = getTypeMap();
Object obj;
int mRows;
......@@ -7304,11 +7290,11 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
resultSet.absolute(start -1);
}
if( pageSize == 0) {
rvh = new Vector(getMaxRows());
rvh = new Vector<Object>(getMaxRows());
}
else{
rvh = new Vector(getPageSize());
rvh = new Vector<Object>(getPageSize());
}
if (data == null) {
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -93,12 +93,12 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
/**
* The Vector holding the Match Columns
*/
private Vector iMatchColumns;
private Vector<Integer> iMatchColumns;
/**
* The Vector that will hold the Match Column names.
*/
private Vector strMatchColumns;
private Vector<String> strMatchColumns;
protected transient JdbcRowSetResourceBundle resBundle;
......@@ -213,12 +213,12 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
//Instantiating the vector for MatchColumns
iMatchColumns = new Vector(10);
iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
strMatchColumns = new Vector(10);
strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
......@@ -286,12 +286,12 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
//Instantiating the vector for MatchColumns
iMatchColumns = new Vector(10);
iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
strMatchColumns = new Vector(10);
strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
......@@ -373,12 +373,12 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
//Instantiating the vector for MatchColumns
iMatchColumns = new Vector(10);
iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
strMatchColumns = new Vector(10);
strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
......@@ -463,12 +463,12 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
//Instantiating the vector for MatchColumns
iMatchColumns = new Vector(10);
iMatchColumns = new Vector<Integer>(10);
for(int i = 0; i < 10 ; i++) {
iMatchColumns.add(i,Integer.valueOf(-1));
}
strMatchColumns = new Vector(10);
strMatchColumns = new Vector<String>(10);
for(int j = 0; j < 10; j++) {
strMatchColumns.add(j,null);
}
......@@ -675,7 +675,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
try {
Map aMap = getTypeMap();
Map<String, Class<?>> aMap = getTypeMap();
if( aMap != null) {
conn.setTypeMap(aMap);
}
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -59,8 +59,8 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
/**
* A <code>Vector</code> object that contains the <code>RowSet</code> objects
* that have been added to this <code>JoinRowSet</code> object.
*/
private Vector vecRowSetsInJOIN;
*/
private Vector<CachedRowSetImpl> vecRowSetsInJOIN;
/**
* The <code>CachedRowSet</code> object that encapsulates this
......@@ -78,13 +78,13 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
* for this <code>JoinRowSet</code> object.
* The last join type set forms the basis of succeeding joins.
*/
private Vector vecJoinType;
private Vector<Integer> vecJoinType;
/**
* A <code>Vector</code> object containing the names of all the tables entering
* the join.
*/
private Vector vecTableNames;
private Vector<String> vecTableNames;
/**
* An <code>int</code> that indicates the column index of the match column.
......@@ -121,10 +121,10 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
*/
public JoinRowSetImpl() throws SQLException {
vecRowSetsInJOIN = new Vector();
vecRowSetsInJOIN = new Vector<CachedRowSetImpl>();
crsInternal = new CachedRowSetImpl();
vecJoinType = new Vector();
vecTableNames = new Vector();
vecJoinType = new Vector<Integer>();
vecTableNames = new Vector<String>();
iMatchKey = -1;
strMatchKey = null;
supportedJOINs =
......@@ -222,7 +222,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
// either of the setter methods have been set.
if(boolColId){
//
ArrayList indices = new ArrayList();
ArrayList<Integer> indices = new ArrayList<>();
for(int i=0;i<cRowset.getMatchColumnNames().length;i++) {
if( (strMatchKey = (cRowset.getMatchColumnNames())[i]) != null) {
iMatchKey = cRowset.findColumn(strMatchKey);
......
......@@ -296,32 +296,32 @@ import javax.sql.rowset.serial.*;
public abstract class BaseRowSet implements Serializable, Cloneable {
/**
* A constant indicating to a <code>RowSetReaderImpl</code> object
* that a given parameter is a Unicode stream. This
* <code>RowSetReaderImpl</code> object is provided as an extension of the
* <code>SyncProvider</code> abstract class defined in the
* <code>SyncFactory</code> static factory SPI mechanism.
*/
public static final int UNICODE_STREAM_PARAM = 0;
/**
* A constant indicating to a <code>RowSetReaderImpl</code> object
* that a given parameter is a Unicode stream. This
* <code>RowSetReaderImpl</code> object is provided as an extension of the
* <code>SyncProvider</code> abstract class defined in the
* <code>SyncFactory</code> static factory SPI mechanism.
*/
public static final int UNICODE_STREAM_PARAM = 0;
/**
* A constant indicating to a <code>RowSetReaderImpl</code> object
* that a given parameter is a binary stream. A
* <code>RowSetReaderImpl</code> object is provided as an extension of the
* <code>SyncProvider</code> abstract class defined in the
* <code>SyncFactory</code> static factory SPI mechanism.
*/
public static final int BINARY_STREAM_PARAM = 1;
/**
* A constant indicating to a <code>RowSetReaderImpl</code> object
* that a given parameter is a binary stream. A
* <code>RowSetReaderImpl</code> object is provided as an extension of the
* <code>SyncProvider</code> abstract class defined in the
* <code>SyncFactory</code> static factory SPI mechanism.
*/
public static final int BINARY_STREAM_PARAM = 1;
/**
* A constant indicating to a <code>RowSetReaderImpl</code> object
* that a given parameter is an ASCII stream. A
* <code>RowSetReaderImpl</code> object is provided as an extension of the
* <code>SyncProvider</code> abstract class defined in the
* <code>SyncFactory</code> static factory SPI mechanism.
*/
public static final int ASCII_STREAM_PARAM = 2;
/**
* A constant indicating to a <code>RowSetReaderImpl</code> object
* that a given parameter is an ASCII stream. A
* <code>RowSetReaderImpl</code> object is provided as an extension of the
* <code>SyncProvider</code> abstract class defined in the
* <code>SyncFactory</code> static factory SPI mechanism.
*/
public static final int ASCII_STREAM_PARAM = 2;
/**
* The <code>InputStream</code> object that will be
......@@ -505,21 +505,21 @@ public static final int ASCII_STREAM_PARAM = 2;
* custom mapping of user-defined types.
* @serial
*/
private Map map;
private Map<String, Class<?>> map;
/**
* A <code>Vector</code> object that holds the list of listeners
* that have registered with this <code>RowSet</code> object.
* @serial
*/
private Vector listeners;
private Vector<RowSetListener> listeners;
/**
* A <code>Vector</code> object that holds the parameters set
* for this <code>RowSet</code> object's current command.
* @serial
*/
private Hashtable params; // could be transient?
private Hashtable<Integer, Object> params; // could be transient?
/**
* Constructs a new <code>BaseRowSet</code> object initialized with
......@@ -529,7 +529,7 @@ public static final int ASCII_STREAM_PARAM = 2;
*/
public BaseRowSet() {
// allocate the listeners collection
listeners = new Vector();
listeners = new Vector<RowSetListener>();
}
/**
......@@ -542,7 +542,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* a <code>RowSet</code> implementation extending this class.
*/
protected void initParams() {
params = new Hashtable();
params = new Hashtable<Integer, Object>();
}
//--------------------------------------------------------------------
......
......@@ -912,7 +912,12 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
* @since 1.6
*/
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException {
return (T)this;
if(isWrapperFor(iface)) {
return iface.cast(this);
} else {
throw new SQLException("unwrap failed for:"+ iface);
}
}
/**
......@@ -929,8 +934,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
* @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
* for an object with the given interface.
* @since 1.6
*/ public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
return false;
*/
public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
return interfaces.isInstance(this);
}
static final long serialVersionUID = 6893806403181801867L;
......
......@@ -204,9 +204,9 @@ public class RowSetProvider {
*
*/
static private ClassLoader getContextClassLoader() throws SecurityException {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public Object run() {
public ClassLoader run() {
ClassLoader cl = null;
cl = Thread.currentThread().getContextClassLoader();
......@@ -284,9 +284,9 @@ public class RowSetProvider {
static private String getSystemProperty(final String propName) {
String property = null;
try {
property = (String) AccessController.doPrivileged(new PrivilegedAction() {
property = AccessController.doPrivileged(new PrivilegedAction<String>() {
public Object run() {
public String run() {
return System.getProperty(propName);
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册