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