提交 792e08c8 authored 作者: Noel Grandin's avatar Noel Grandin

reduce indentatin in the getName() method, making it easier to read

上级 5f05037a
...@@ -382,42 +382,42 @@ public class ConnectionInfo implements Cloneable { ...@@ -382,42 +382,42 @@ public class ConnectionInfo implements Cloneable {
* @return the database name * @return the database name
*/ */
public String getName() { public String getName() {
if (persistent) { if (!persistent) {
if (nameNormalized == null) { return name;
if (!SysProperties.IMPLICIT_RELATIVE_PATH) { }
if (!FileUtils.isAbsolute(name)) { if (nameNormalized == null) {
if (name.indexOf("./") < 0 && if (!SysProperties.IMPLICIT_RELATIVE_PATH) {
name.indexOf(".\\") < 0 && if (!FileUtils.isAbsolute(name)) {
name.indexOf(":/") < 0 && if (name.indexOf("./") < 0 &&
name.indexOf(":\\") < 0) { name.indexOf(".\\") < 0 &&
// the name could start with "./", or name.indexOf(":/") < 0 &&
// it could start with a prefix such as "nio:./" name.indexOf(":\\") < 0) {
// for Windows, the path "\test" is not considered // the name could start with "./", or
// absolute as the drive letter is missing, // it could start with a prefix such as "nio:./"
// but we consider it absolute // for Windows, the path "\test" is not considered
throw DbException.get( // absolute as the drive letter is missing,
ErrorCode.URL_RELATIVE_TO_CWD, // but we consider it absolute
originalURL); throw DbException.get(
} ErrorCode.URL_RELATIVE_TO_CWD,
originalURL);
} }
} }
String suffix = Constants.SUFFIX_PAGE_FILE;
String n;
if (FileUtils.exists(name + suffix)) {
n = FileUtils.toRealPath(name + suffix);
} else {
suffix = Constants.SUFFIX_MV_FILE;
n = FileUtils.toRealPath(name + suffix);
}
String fileName = FileUtils.getName(n);
if (fileName.length() < suffix.length() + 1) {
throw DbException.get(ErrorCode.INVALID_DATABASE_NAME_1, name);
}
nameNormalized = n.substring(0, n.length() - suffix.length());
} }
return nameNormalized; String suffix = Constants.SUFFIX_PAGE_FILE;
String n;
if (FileUtils.exists(name + suffix)) {
n = FileUtils.toRealPath(name + suffix);
} else {
suffix = Constants.SUFFIX_MV_FILE;
n = FileUtils.toRealPath(name + suffix);
}
String fileName = FileUtils.getName(n);
if (fileName.length() < suffix.length() + 1) {
throw DbException.get(ErrorCode.INVALID_DATABASE_NAME_1, name);
}
nameNormalized = n.substring(0, n.length() - suffix.length());
} }
return name; return nameNormalized;
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论