提交 d32a566b authored 作者: Jacek Ławrynowicz's avatar Jacek Ławrynowicz

formatting - add braces to control statements

上级 b81fe715
...@@ -71,8 +71,9 @@ public class DbSchema { ...@@ -71,8 +71,9 @@ public class DbSchema {
} else if (contents.isPostgreSQL() && } else if (contents.isPostgreSQL() &&
StringUtils.toUpperEnglish(name).startsWith("PG_")) { StringUtils.toUpperEnglish(name).startsWith("PG_")) {
isSystem = true; isSystem = true;
} else } else {
isSystem = contents.isDerby() && name.startsWith("SYS"); isSystem = contents.isDerby() && name.startsWith("SYS");
}
} }
/** /**
......
...@@ -3569,8 +3569,9 @@ public class Parser { ...@@ -3569,8 +3569,9 @@ public class Parser {
return b == null; return b == null;
} else if (a.equals(b)) { } else if (a.equals(b)) {
return true; return true;
} else } else {
return !identifiersToUpper && a.equalsIgnoreCase(b); return !identifiersToUpper && a.equalsIgnoreCase(b);
}
} }
private static boolean equalsTokenIgnoreCase(String a, String b) { private static boolean equalsTokenIgnoreCase(String a, String b) {
...@@ -3578,8 +3579,9 @@ public class Parser { ...@@ -3578,8 +3579,9 @@ public class Parser {
return b == null; return b == null;
} else if (a.equals(b)) { } else if (a.equals(b)) {
return true; return true;
} else } else {
return a.equalsIgnoreCase(b); return a.equalsIgnoreCase(b);
}
} }
private boolean isTokenInList(Collection<String> upperCaseTokenList) { private boolean isTokenInList(Collection<String> upperCaseTokenList) {
......
...@@ -95,8 +95,9 @@ public class DropTable extends SchemaCommand { ...@@ -95,8 +95,9 @@ public class DropTable extends SchemaCommand {
} }
} }
} }
if (buff.length() > 0) if (buff.length() > 0) {
throw DbException.get(ErrorCode.CANNOT_DROP_2, tableName, buff.toString()); throw DbException.get(ErrorCode.CANNOT_DROP_2, tableName, buff.toString());
}
} }
table.lock(session, true, true); table.lock(session, true, true);
...@@ -142,4 +143,4 @@ public class DropTable extends SchemaCommand { ...@@ -142,4 +143,4 @@ public class DropTable extends SchemaCommand {
return CommandInterface.DROP_TABLE; return CommandInterface.DROP_TABLE;
} }
} }
\ No newline at end of file
...@@ -119,8 +119,9 @@ class AggregateDataMedian extends AggregateData { ...@@ -119,8 +119,9 @@ class AggregateDataMedian extends AggregateData {
count--; count--;
cursor.next(); cursor.next();
hasNulls = true; hasNulls = true;
} else } else {
break; break;
}
} }
if (count == 0) { if (count == 0) {
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
......
...@@ -1648,8 +1648,9 @@ public class Function extends Expression implements FunctionCall { ...@@ -1648,8 +1648,9 @@ public class Function extends Expression implements FunctionCall {
break; break;
case SIGNAL: { case SIGNAL: {
String sqlState = v0.getString(); String sqlState = v0.getString();
if (sqlState.startsWith("00") || !SIGNAL_PATTERN.matcher(sqlState).matches()) if (sqlState.startsWith("00") || !SIGNAL_PATTERN.matcher(sqlState).matches()) {
throw DbException.getInvalidValueException("SQLSTATE", sqlState); throw DbException.getInvalidValueException("SQLSTATE", sqlState);
}
String msgText = v1.getString(); String msgText = v1.getString();
throw DbException.fromUser(sqlState, msgText); throw DbException.fromUser(sqlState, msgText);
} }
......
...@@ -567,8 +567,9 @@ public final class MVStore { ...@@ -567,8 +567,9 @@ public final class MVStore {
// the following can fail for various reasons // the following can fail for various reasons
try { try {
HashMap<String, String> m = DataUtils.parseChecksummedMap(buff); HashMap<String, String> m = DataUtils.parseChecksummedMap(buff);
if (m == null) if (m == null) {
continue; continue;
}
int blockSize = DataUtils.readHexInt( int blockSize = DataUtils.readHexInt(
m, "blockSize", BLOCK_SIZE); m, "blockSize", BLOCK_SIZE);
if (blockSize != BLOCK_SIZE) { if (blockSize != BLOCK_SIZE) {
......
...@@ -653,8 +653,9 @@ public class PgServerThread implements Runnable { ...@@ -653,8 +653,9 @@ public class PgServerThread implements Runnable {
case PgServer.PG_TYPE_TIME: { case PgServer.PG_TYPE_TIME: {
// Strip timezone offset // Strip timezone offset
int idx = str.indexOf('+'); int idx = str.indexOf('+');
if (idx <= 0) if (idx <= 0) {
idx = str.indexOf('-'); idx = str.indexOf('-');
}
if (idx > 0) { if (idx > 0) {
str = str.substring(0, idx); str = str.substring(0, idx);
} }
......
...@@ -49,8 +49,9 @@ public final class RangeInputStream extends FilterInputStream { ...@@ -49,8 +49,9 @@ public final class RangeInputStream extends FilterInputStream {
@Override @Override
public int read(byte b[], int off, int len) throws IOException { public int read(byte b[], int off, int len) throws IOException {
if (limit <= 0) if (limit <= 0) {
return -1; return -1;
}
if (len > limit) { if (len > limit) {
len = (int) limit; len = (int) limit;
} }
......
...@@ -50,8 +50,9 @@ public final class RangeReader extends Reader { ...@@ -50,8 +50,9 @@ public final class RangeReader extends Reader {
@Override @Override
public int read(char cbuf[], int off, int len) throws IOException { public int read(char cbuf[], int off, int len) throws IOException {
if (limit <= 0) if (limit <= 0) {
return -1; return -1;
}
if (len > limit) { if (len > limit) {
len = (int) limit; len = (int) limit;
} }
......
...@@ -720,10 +720,11 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -720,10 +720,11 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
public static void startWebServer(Connection conn, boolean ignoreProperties) throws SQLException { public static void startWebServer(Connection conn, boolean ignoreProperties) throws SQLException {
WebServer webServer = new WebServer(); WebServer webServer = new WebServer();
String[] args; String[] args;
if (ignoreProperties) if (ignoreProperties) {
args = new String[] { "-webPort", "0", "-properties", "null"}; args = new String[] { "-webPort", "0", "-properties", "null"};
else } else {
args = new String[] { "-webPort", "0" }; args = new String[] { "-webPort", "0" };
}
Server web = new Server(webServer, args); Server web = new Server(webServer, args);
web.start(); web.start();
Server server = new Server(); Server server = new Server();
......
...@@ -422,8 +422,9 @@ public class DateTimeUtils { ...@@ -422,8 +422,9 @@ public class DateTimeUtils {
*/ */
private static int findNthIndexOf(String str, char chr, int n) { private static int findNthIndexOf(String str, char chr, int n) {
int pos = str.indexOf(chr); int pos = str.indexOf(chr);
while (--n > 0 && pos != -1) while (--n > 0 && pos != -1) {
pos = str.indexOf(chr, pos + 1); pos = str.indexOf(chr, pos + 1);
}
return pos; return pos;
} }
......
...@@ -57,10 +57,12 @@ public final class MergedResultSet { ...@@ -57,10 +57,12 @@ public final class MergedResultSet {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) {
return true; return true;
if (obj == null || getClass() != obj.getClass()) }
if (obj == null || getClass() != obj.getClass()) {
return false; return false;
}
ColumnInfo other = (ColumnInfo) obj; ColumnInfo other = (ColumnInfo) obj;
return name.equals(other.name); return name.equals(other.name);
} }
......
...@@ -209,12 +209,13 @@ public class SourceCompiler { ...@@ -209,12 +209,13 @@ public class SourceCompiler {
if (compiledScript == null) { if (compiledScript == null) {
String source = sources.get(packageAndClassName); String source = sources.get(packageAndClassName);
final String lang; final String lang;
if (isJavascriptSource(source)) if (isJavascriptSource(source)) {
lang = "javascript"; lang = "javascript";
else if (isRubySource(source)) } else if (isRubySource(source)) {
lang = "ruby"; lang = "ruby";
else } else {
throw new IllegalStateException("Unknown language for " + source); throw new IllegalStateException("Unknown language for " + source);
}
final Compilable jsEngine = (Compilable) new ScriptEngineManager().getEngineByName(lang); final Compilable jsEngine = (Compilable) new ScriptEngineManager().getEngineByName(lang);
compiledScript = jsEngine.compile(source); compiledScript = jsEngine.compile(source);
......
...@@ -534,18 +534,20 @@ public class DataType { ...@@ -534,18 +534,20 @@ public class DataType {
v = ValueBytes.getNoCopy((byte[]) o); v = ValueBytes.getNoCopy((byte[]) o);
} else if (o != null) { } else if (o != null) {
v = ValueUuid.get((UUID) o); v = ValueUuid.get((UUID) o);
} else } else {
v = ValueNull.INSTANCE; v = ValueNull.INSTANCE;
}
break; break;
} }
case Value.UUID: { case Value.UUID: {
Object o = rs.getObject(columnIndex); Object o = rs.getObject(columnIndex);
if (o instanceof UUID) { if (o instanceof UUID) {
v = ValueUuid.get((UUID) o); v = ValueUuid.get((UUID) o);
} else if (o != null) } else if (o != null) {
v = ValueUuid.get((byte[]) o); v = ValueUuid.get((byte[]) o);
else } else {
v = ValueNull.INSTANCE; v = ValueNull.INSTANCE;
}
break; break;
} }
case Value.BOOLEAN: { case Value.BOOLEAN: {
......
...@@ -78,8 +78,9 @@ public class ValueEnum extends ValueEnumBase { ...@@ -78,8 +78,9 @@ public class ValueEnum extends ValueEnumBase {
final String cleanLabel = sanitize(value); final String cleanLabel = sanitize(value);
for (int i = 0; i < enumerators.length; i++) { for (int i = 0; i < enumerators.length; i++) {
if (cleanLabel.equals(sanitize(enumerators[i]))) if (cleanLabel.equals(sanitize(enumerators[i]))) {
return new ValueEnum(enumerators, i); return new ValueEnum(enumerators, i);
}
} }
throw DbException.get(ErrorCode.GENERAL_ERROR_1, "Unexpected error"); throw DbException.get(ErrorCode.GENERAL_ERROR_1, "Unexpected error");
...@@ -106,7 +107,9 @@ public class ValueEnum extends ValueEnumBase { ...@@ -106,7 +107,9 @@ public class ValueEnum extends ValueEnumBase {
} }
private static String[] sanitize(final String[] enumerators) { private static String[] sanitize(final String[] enumerators) {
if (enumerators == null || enumerators.length == 0) return null; if (enumerators == null || enumerators.length == 0) {
return null;
}
final String[] clean = new String[enumerators.length]; final String[] clean = new String[enumerators.length];
......
...@@ -69,10 +69,11 @@ public class ValueLob extends Value { ...@@ -69,10 +69,11 @@ public class ValueLob extends Value {
* @return the smaller input stream * @return the smaller input stream
*/ */
static InputStream rangeInputStream(InputStream inputStream, long oneBasedOffset, long length, long dataSize) { static InputStream rangeInputStream(InputStream inputStream, long oneBasedOffset, long length, long dataSize) {
if (dataSize > 0) if (dataSize > 0) {
rangeCheck(oneBasedOffset - 1, length, dataSize); rangeCheck(oneBasedOffset - 1, length, dataSize);
else } else {
rangeCheckUnknown(oneBasedOffset - 1, length); rangeCheckUnknown(oneBasedOffset - 1, length);
}
try { try {
return new RangeInputStream(inputStream, oneBasedOffset - 1, length); return new RangeInputStream(inputStream, oneBasedOffset - 1, length);
} catch (IOException e) { } catch (IOException e) {
...@@ -90,10 +91,11 @@ public class ValueLob extends Value { ...@@ -90,10 +91,11 @@ public class ValueLob extends Value {
* @return the smaller input stream * @return the smaller input stream
*/ */
static Reader rangeReader(Reader reader, long oneBasedOffset, long length, long dataSize) { static Reader rangeReader(Reader reader, long oneBasedOffset, long length, long dataSize) {
if (dataSize > 0) if (dataSize > 0) {
rangeCheck(oneBasedOffset - 1, length, dataSize); rangeCheck(oneBasedOffset - 1, length, dataSize);
else } else {
rangeCheckUnknown(oneBasedOffset - 1, length); rangeCheckUnknown(oneBasedOffset - 1, length);
}
try { try {
return new RangeReader(reader, oneBasedOffset - 1, length); return new RangeReader(reader, oneBasedOffset - 1, length);
} catch (IOException e) { } catch (IOException e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论