提交 9ab420f0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use Utils.parseBoolean() in more places with user-supplied strings

上级 469a69ea
...@@ -345,8 +345,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -345,8 +345,7 @@ public class ConnectionInfo implements Cloneable {
* @return the value * @return the value
*/ */
public boolean removeProperty(String key, boolean defaultValue) { public boolean removeProperty(String key, boolean defaultValue) {
String x = removeProperty(key, null); return Utils.parseBoolean(removeProperty(key, null), defaultValue, false);
return x == null ? defaultValue : Boolean.parseBoolean(x);
} }
/** /**
......
...@@ -351,12 +351,10 @@ public class WebApp { ...@@ -351,12 +351,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.parseBoolean( boolean allowOthers = Utils.parseBoolean((String) attributes.get("allowOthers"), false, false);
(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.parseBoolean( boolean ssl = Utils.parseBoolean((String) attributes.get("ssl"), false, false);
(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);
......
...@@ -32,6 +32,7 @@ import org.h2.util.IOUtils; ...@@ -32,6 +32,7 @@ import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.New; import org.h2.util.New;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils;
/** /**
* A facility to read from and write to CSV (comma separated values) files. When * A facility to read from and write to CSV (comma separated values) files. When
...@@ -857,11 +858,11 @@ public class Csv implements SimpleRowSource { ...@@ -857,11 +858,11 @@ public class Csv implements SimpleRowSource {
} else if (isParam(key, "charset", "characterSet")) { } else if (isParam(key, "charset", "characterSet")) {
charset = value; charset = value;
} else if (isParam(key, "preserveWhitespace")) { } else if (isParam(key, "preserveWhitespace")) {
setPreserveWhitespace(Boolean.parseBoolean(value)); setPreserveWhitespace(Utils.parseBoolean(value, false, false));
} else if (isParam(key, "writeColumnHeader")) { } else if (isParam(key, "writeColumnHeader")) {
setWriteColumnHeader(Boolean.parseBoolean(value)); setWriteColumnHeader(Utils.parseBoolean(value, true, false));
} else if (isParam(key, "caseSensitiveColumnNames")) { } else if (isParam(key, "caseSensitiveColumnNames")) {
setCaseSensitiveColumnNames(Boolean.parseBoolean(value)); setCaseSensitiveColumnNames(Utils.parseBoolean(value, false, false));
} else { } else {
throw DbException.getUnsupportedException(key); throw DbException.getUnsupportedException(key);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论