提交 7410fb81 authored 作者: noelgrandin's avatar noelgrandin

Use Boolean.parseBoolean(x) instead of Boolean.valueOf(x).booleanValue() to…

Use Boolean.parseBoolean(x) instead of Boolean.valueOf(x).booleanValue() to avoid unnecessary temporary object creation
上级 231a81de
...@@ -331,7 +331,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -331,7 +331,7 @@ public class ConnectionInfo implements Cloneable {
if (x.length() == 1 && Character.isDigit(x.charAt(0))) { if (x.length() == 1 && Character.isDigit(x.charAt(0))) {
return Integer.parseInt(x) != 0; return Integer.parseInt(x) != 0;
} }
return Boolean.valueOf(x).booleanValue(); return Boolean.parseBoolean(x);
} }
/** /**
...@@ -343,7 +343,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -343,7 +343,7 @@ public class ConnectionInfo implements Cloneable {
*/ */
public boolean removeProperty(String key, boolean defaultValue) { public boolean removeProperty(String key, boolean defaultValue) {
String x = removeProperty(key, null); String x = removeProperty(key, null);
return x == null ? defaultValue : Boolean.valueOf(x).booleanValue(); return x == null ? defaultValue : Boolean.parseBoolean(x);
} }
/** /**
......
...@@ -289,7 +289,7 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -289,7 +289,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
} }
// create the session using reflection, // create the session using reflection,
// so that the JDBC layer can be compiled without it // so that the JDBC layer can be compiled without it
boolean autoServerMode = Boolean.valueOf(ci.getProperty("AUTO_SERVER", "false")).booleanValue(); boolean autoServerMode = Boolean.parseBoolean(ci.getProperty("AUTO_SERVER", "false"));
ConnectionInfo backup = null; ConnectionInfo backup = null;
try { try {
if (autoServerMode) { if (autoServerMode) {
...@@ -360,9 +360,9 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -360,9 +360,9 @@ public class SessionRemote extends SessionWithState implements DataHandler {
serverList = StringUtils.quoteStringSQL(server); serverList = StringUtils.quoteStringSQL(server);
ci.setProperty("CLUSTER", Constants.CLUSTERING_ENABLED); ci.setProperty("CLUSTER", Constants.CLUSTERING_ENABLED);
} }
autoReconnect = Boolean.valueOf(ci.getProperty("AUTO_RECONNECT", "false")).booleanValue(); autoReconnect = Boolean.parseBoolean(ci.getProperty("AUTO_RECONNECT", "false"));
// AUTO_SERVER implies AUTO_RECONNECT // AUTO_SERVER implies AUTO_RECONNECT
boolean autoServer = Boolean.valueOf(ci.getProperty("AUTO_SERVER", "false")).booleanValue(); boolean autoServer = Boolean.parseBoolean(ci.getProperty("AUTO_SERVER", "false"));
if (autoServer && serverList != null) { if (autoServer && serverList != null) {
throw DbException.getUnsupportedException("autoServer && serverList != null"); throw DbException.getUnsupportedException("autoServer && serverList != null");
} }
......
...@@ -32,7 +32,7 @@ public class SettingsBase { ...@@ -32,7 +32,7 @@ public class SettingsBase {
protected boolean get(String key, boolean defaultValue) { protected boolean get(String key, boolean defaultValue) {
String s = get(key, "" + defaultValue); String s = get(key, "" + defaultValue);
try { try {
return Boolean.valueOf(s).booleanValue(); return Boolean.parseBoolean(s);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, e, "key:" + key + " value:" + s); throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, e, "key:" + key + " value:" + s);
} }
......
...@@ -1623,7 +1623,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1623,7 +1623,7 @@ public class Function extends Expression implements FunctionCall {
s.append('9'); s.append('9');
s.append('9'); s.append('9');
} }
return Double.valueOf(s.toString()).doubleValue(); return Double.parseDouble(s.toString());
} }
private static String getSoundex(String s) { private static String getSoundex(String s) {
......
...@@ -342,10 +342,10 @@ public class WebApp { ...@@ -342,10 +342,10 @@ public class WebApp {
int port = Integer.decode((String) attributes.get("port")); int port = Integer.decode((String) attributes.get("port"));
prop.setProperty("webPort", String.valueOf(port)); prop.setProperty("webPort", String.valueOf(port));
server.setPort(port); server.setPort(port);
boolean allowOthers = Boolean.valueOf((String) attributes.get("allowOthers")).booleanValue(); boolean allowOthers = Boolean.parseBoolean((String) attributes.get("allowOthers"));
prop.setProperty("webAllowOthers", String.valueOf(allowOthers)); prop.setProperty("webAllowOthers", String.valueOf(allowOthers));
server.setAllowOthers(allowOthers); server.setAllowOthers(allowOthers);
boolean ssl = Boolean.valueOf((String) attributes.get("ssl")).booleanValue(); boolean ssl = Boolean.parseBoolean((String) attributes.get("ssl"));
prop.setProperty("webSSL", String.valueOf(ssl)); prop.setProperty("webSSL", String.valueOf(ssl));
server.setSSL(ssl); server.setSSL(ssl);
server.saveProperties(prop); server.saveProperties(prop);
...@@ -1045,7 +1045,7 @@ public class WebApp { ...@@ -1045,7 +1045,7 @@ public class WebApp {
if (isBuiltIn(sql, "@best_row_identifier")) { if (isBuiltIn(sql, "@best_row_identifier")) {
String[] p = split(sql); String[] p = split(sql);
int scale = p[4] == null ? 0 : Integer.parseInt(p[4]); int scale = p[4] == null ? 0 : Integer.parseInt(p[4]);
boolean nullable = p[5] == null ? false : Boolean.valueOf(p[5]).booleanValue(); boolean nullable = p[5] == null ? false : Boolean.parseBoolean(p[5]);
return meta.getBestRowIdentifier(p[1], p[2], p[3], scale, nullable); return meta.getBestRowIdentifier(p[1], p[2], p[3], scale, nullable);
} else if (isBuiltIn(sql, "@catalogs")) { } else if (isBuiltIn(sql, "@catalogs")) {
return meta.getCatalogs(); return meta.getCatalogs();
...@@ -1066,8 +1066,8 @@ public class WebApp { ...@@ -1066,8 +1066,8 @@ public class WebApp {
return meta.getImportedKeys(p[1], p[2], p[3]); return meta.getImportedKeys(p[1], p[2], p[3]);
} else if (isBuiltIn(sql, "@index_info")) { } else if (isBuiltIn(sql, "@index_info")) {
String[] p = split(sql); String[] p = split(sql);
boolean unique = p[4] == null ? false : Boolean.valueOf(p[4]).booleanValue(); boolean unique = p[4] == null ? false : Boolean.parseBoolean(p[4]);
boolean approx = p[5] == null ? false : Boolean.valueOf(p[5]).booleanValue(); boolean approx = p[5] == null ? false : Boolean.parseBoolean(p[5]);
return meta.getIndexInfo(p[1], p[2], p[3], unique, approx); return meta.getIndexInfo(p[1], p[2], p[3], unique, approx);
} else if (isBuiltIn(sql, "@primary_keys")) { } else if (isBuiltIn(sql, "@primary_keys")) {
String[] p = split(sql); String[] p = split(sql);
......
...@@ -54,7 +54,7 @@ public class SortedProperties extends Properties { ...@@ -54,7 +54,7 @@ public class SortedProperties extends Properties {
public static boolean getBooleanProperty(Properties prop, String key, boolean def) { public static boolean getBooleanProperty(Properties prop, String key, boolean def) {
String value = prop.getProperty(key, "" + def); String value = prop.getProperty(key, "" + def);
try { try {
return Boolean.valueOf(value).booleanValue(); return Boolean.parseBoolean(value);
} catch (Exception e) { } catch (Exception e) {
TraceSystem.traceThrowable(e); TraceSystem.traceThrowable(e);
return def; return def;
......
...@@ -770,7 +770,7 @@ public class Utils { ...@@ -770,7 +770,7 @@ public class Utils {
String s = getProperty(key, null); String s = getProperty(key, null);
if (s != null) { if (s != null) {
try { try {
return Boolean.valueOf(s).booleanValue(); return Boolean.parseBoolean(s);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// ignore // ignore
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论