提交 92de547e 编写于 作者: L lancea

6988993: Address Findbugs warnings for the use of String Constructor

Reviewed-by: ohair
上级 fcd7809a
......@@ -4042,7 +4042,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
case java.sql.Types.CHAR:
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
return new String(srcObj.toString());
return srcObj.toString();
default:
throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()+ trgType);
}
......@@ -4139,7 +4139,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
case java.sql.Types.CHAR:
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
return new String(srcObj.toString());
return srcObj.toString();
default:
throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
}
......@@ -6434,7 +6434,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
if (tabName == null)
throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.tablename").toString());
else
tableName = new String(tabName);
tableName = tabName;
}
/**
......
......@@ -1106,7 +1106,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
public void updateBytes(int columnIndex , byte []x) throws SQLException {
boolean bool;
String val = new String();
String val = "";
Byte [] obj_arr = new Byte[x.length];
......
......@@ -876,8 +876,8 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
String strWhereClause = "Select ";
String whereClause;
String tabName= null;
String strTabName = null;
String tabName= "";
String strTabName = "";
int sz,cols;
int j;
CachedRowSetImpl crs;
......@@ -891,8 +891,6 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
// tableNameX.(rowsetX.getMatchColumnName()) ==
// tableNameZ.(rowsetZ.getMatchColumnName()));
tabName = new String();
strTabName = new String();
sz = vecRowSetsInJOIN.size();
for(int i=0;i<sz; i++) {
crs = (CachedRowSetImpl)vecRowSetsInJOIN.get(i);
......
......@@ -541,7 +541,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// how many fields need to be updated
int colsNotChanged = 0;
Vector cols = new Vector();
String updateExec = new String(updateCmd);
String updateExec = updateCmd;
Object orig;
Object curr;
Object rsval;
......@@ -1184,7 +1184,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// trim all the leading and trailing whitespaces,
// white spaces can never be catalog, schema or a table name.
String cmd = new String();
String cmd = "";
catalog = catalog.trim();
schema = schema.trim();
......
......@@ -641,7 +641,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
return null;
}
char []charStr = s.toCharArray();
String specialStr = new String();
String specialStr = "";
for(int i = 0; i < charStr.length; i++) {
if(charStr[i] == '&') {
......
......@@ -441,9 +441,9 @@ public class XmlReaderContentHandler extends DefaultHandler {
updates = new Vector();
// start out with the empty string
columnValue = new String("");
propertyValue = new String("");
metaDataValue = new String("");
columnValue = "";
propertyValue = "";
metaDataValue = "";
nullVal = false;
idx = 0;
......@@ -686,7 +686,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
}
// propertyValue need to be reset to an empty string
propertyValue = new String("");
propertyValue = "";
setTag(-1);
break;
case METADATA:
......@@ -710,7 +710,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
}
// metaDataValue needs to be reset to an empty string
metaDataValue = new String("");
metaDataValue = "";
}
setTag(-1);
break;
......@@ -736,7 +736,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
insertValue(tempStr);
}
// columnValue now need to be reset to the empty string
columnValue = new String("");
columnValue = "";
} catch (SQLException ex) {
throw new SAXException(MessageFormat.format(resBundle.handleGetObject("xmlrch.errinsert").toString(), ex.getMessage()));
}
......
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010, 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
......@@ -734,7 +734,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw new SQLException("Set initParams() before setCommand");
}
params.clear();
command = new String(cmd);
command = cmd;
}
}
......@@ -797,7 +797,7 @@ public static final int ASCII_STREAM_PARAM = 2;
throw new SQLException("Invalid url string detected. " +
"Cannot be of length less than 1");
} else {
URL = new String(url);
URL = url;
}
dataSource = null;
......@@ -854,7 +854,7 @@ public static final int ASCII_STREAM_PARAM = 2;
} else if (name.equals("")) {
throw new SQLException("DataSource name cannot be empty string");
} else {
dataSource = new String(name);
dataSource = name;
}
URL = null;
......@@ -889,7 +889,7 @@ public static final int ASCII_STREAM_PARAM = 2;
{
username = null;
} else {
username = new String(name);
username = name;
}
}
......@@ -924,7 +924,7 @@ public static final int ASCII_STREAM_PARAM = 2;
{
password = null;
} else {
password = new String(pass);
password = pass;
}
}
......@@ -1645,7 +1645,7 @@ public static final int ASCII_STREAM_PARAM = 2;
nullVal = new Object[3];
nullVal[0] = null;
nullVal[1] = new Integer(sqlType);
nullVal[2] = new String(typeName);
nullVal[2] = typeName;
if(params == null){
throw new SQLException("Set initParams() before setNull");
......
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010, 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
......@@ -306,9 +306,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public void setColumnLabel(int columnIndex, String label) throws SQLException {
checkColRange(columnIndex);
if (label != null) {
colInfo[columnIndex].columnLabel = new String(label);
colInfo[columnIndex].columnLabel = label;
} else {
colInfo[columnIndex].columnLabel = new String("");
colInfo[columnIndex].columnLabel = "";
}
}
......@@ -326,9 +326,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public void setColumnName(int columnIndex, String columnName) throws SQLException {
checkColRange(columnIndex);
if (columnName != null) {
colInfo[columnIndex].columnName = new String(columnName);
colInfo[columnIndex].columnName = columnName;
} else {
colInfo[columnIndex].columnName = new String("");
colInfo[columnIndex].columnName = "";
}
}
......@@ -348,9 +348,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public void setSchemaName(int columnIndex, String schemaName) throws SQLException {
checkColRange(columnIndex);
if (schemaName != null ) {
colInfo[columnIndex].schemaName = new String(schemaName);
colInfo[columnIndex].schemaName = schemaName;
} else {
colInfo[columnIndex].schemaName = new String("");
colInfo[columnIndex].schemaName = "";
}
}
......@@ -411,9 +411,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public void setTableName(int columnIndex, String tableName) throws SQLException {
checkColRange(columnIndex);
if (tableName != null) {
colInfo[columnIndex].tableName = new String(tableName);
colInfo[columnIndex].tableName = tableName;
} else {
colInfo[columnIndex].tableName = new String("");
colInfo[columnIndex].tableName = "";
}
}
......@@ -432,9 +432,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
public void setCatalogName(int columnIndex, String catalogName) throws SQLException {
checkColRange(columnIndex);
if (catalogName != null)
colInfo[columnIndex].catName = new String(catalogName);
colInfo[columnIndex].catName = catalogName;
else
colInfo[columnIndex].catName = new String("");
colInfo[columnIndex].catName = "";
}
/**
......@@ -474,9 +474,9 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
throws SQLException {
checkColRange(columnIndex);
if (typeName != null) {
colInfo[columnIndex].colTypeName = new String(typeName);
colInfo[columnIndex].colTypeName = typeName;
} else {
colInfo[columnIndex].colTypeName = new String("");
colInfo[columnIndex].colTypeName = "";
}
}
......@@ -827,7 +827,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
* or the given column number is out of bounds
*/
public String getColumnClassName(int columnIndex) throws SQLException {
String className = (new String()).getClass().getName();
String className = String.class.getName();
int sqlType = getColumnType(columnIndex);
......@@ -835,65 +835,62 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable {
case Types.NUMERIC:
case Types.DECIMAL:
className = (new java.math.BigDecimal(0)).getClass().getName ();
className = java.math.BigDecimal.class.getName();
break;
case Types.BIT:
className = (new Boolean(false)).getClass().getName ();
className = java.lang.Boolean.class.getName();
break;
case Types.TINYINT:
className = (new Byte("0")).getClass().getName ();
className = java.lang.Byte.class.getName();
break;
case Types.SMALLINT:
className = (new Short("0")).getClass().getName ();
className = java.lang.Short.class.getName();
break;
case Types.INTEGER:
className = (new Integer(0)).getClass().getName ();
className = java.lang.Integer.class.getName();
break;
case Types.BIGINT:
className = (new Long(0)).getClass().getName ();
className = java.lang.Long.class.getName();
break;
case Types.REAL:
className = (new Float(0)).getClass().getName ();
className = java.lang.Float.class.getName();
break;
case Types.FLOAT:
case Types.DOUBLE:
className = (new Double(0)).getClass().getName();
className = java.lang.Double.class.getName();
break;
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
byte[] b = {};
className = (b.getClass()).getName();
className = "byte[]";
break;
case Types.DATE:
className = (new java.sql.Date(123456)).getClass().getName ();
className = java.sql.Date.class.getName();
break;
case Types.TIME:
className = (new java.sql.Time(123456)).getClass().getName ();
className = java.sql.Time.class.getName();
break;
case Types.TIMESTAMP:
className = (new java.sql.Timestamp(123456)).getClass().getName ();
className = java.sql.Timestamp.class.getName();
break;
case Types.BLOB:
byte[] blob = {};
className = (blob.getClass()).getName();
className = java.sql.Blob.class.getName();
break;
case Types.CLOB:
char[] c = {};
className = (c.getClass()).getName();
className = java.sql.Clob.class.getName();
break;
}
......
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010, 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
......@@ -77,7 +77,7 @@ public class SerialRef implements Ref, Serializable, Cloneable {
throw new SQLException("Cannot instantiate a SerialRef object " +
"that returns a null base type name");
} else {
baseTypeName = new String(ref.getBaseTypeName());
baseTypeName = ref.getBaseTypeName();
}
}
......
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2010, 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
......@@ -94,7 +94,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
try {
// get the type name
SQLTypeName = new String(in.getSQLTypeName());
SQLTypeName = in.getSQLTypeName();
System.out.println("SQLTypeName: " + SQLTypeName);
// get the attributes of the struct
......@@ -137,7 +137,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
try {
//set the type name
SQLTypeName = new String(in.getSQLTypeName());
SQLTypeName = in.getSQLTypeName();
Vector tmp = new Vector();
in.writeSQL(new SQLOutputImpl(tmp, map));
......@@ -247,7 +247,7 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
}
/**
* The identifier that assists in the serialization of this
* The identifier that assists in the serialization of this
* <code>SerialStruct</code> object.
*/
static final long serialVersionUID = -8322445504027483372L;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册