提交 b4c3fe93 authored 作者: Thomas Mueller's avatar Thomas Mueller

Limit line length to 80 characters

上级 06698d68
......@@ -38,7 +38,8 @@ public class Engine implements SessionFactory {
return INSTANCE;
}
private Session openSession(ConnectionInfo ci, boolean ifExists, String cipher) {
private Session openSession(ConnectionInfo ci, boolean ifExists,
String cipher) {
String name = ci.getName();
Database database;
ci.removeProperty("NO_UPGRADE", false);
......
......@@ -271,7 +271,8 @@ public abstract class Expression {
* @param outerJoin if the expression is part of an outer join
*/
public void addFilterConditions(TableFilter filter, boolean outerJoin) {
if (!addedToFilter && !outerJoin && isEverything(ExpressionVisitor.EVALUATABLE_VISITOR)) {
if (!addedToFilter && !outerJoin &&
isEverything(ExpressionVisitor.EVALUATABLE_VISITOR)) {
filter.addFilterCondition(this, false);
addedToFilter = true;
}
......
......@@ -213,12 +213,14 @@ public class LobStorageBackend implements LobStorageInterface {
assertNotHolds(conn.getSession());
synchronized (database) {
synchronized (conn.getSession()) {
String sql = "SELECT COMPRESSED, DATA FROM " + LOB_DATA + " WHERE BLOCK = ?";
String sql = "SELECT COMPRESSED, DATA FROM " +
LOB_DATA + " WHERE BLOCK = ?";
PreparedStatement prep = prepare(sql);
prep.setLong(1, block);
ResultSet rs = prep.executeQuery();
if (!rs.next()) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry, block: " + block)
throw DbException.get(ErrorCode.IO_EXCEPTION_1,
"Missing lob entry, block: " + block)
.getSQLException();
}
int compressed = rs.getInt(1);
......@@ -319,7 +321,8 @@ public class LobStorageBackend implements LobStorageInterface {
}
@Override
public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException {
public InputStream getInputStream(ValueLobDb lob, byte[] hmac,
long byteCount) throws IOException {
try {
init();
assertNotHolds(conn.getSession());
......@@ -335,7 +338,8 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
private ValueLobDb addLob(InputStream in, long maxLength, int type, CountingReaderInputStream countingReaderForClob) {
private ValueLobDb addLob(InputStream in, long maxLength, int type,
CountingReaderInputStream countingReaderForClob) {
try {
byte[] buff = new byte[BLOCK_LENGTH];
if (maxLength < 0) {
......@@ -385,13 +389,15 @@ public class LobStorageBackend implements LobStorageInterface {
if (small != null) {
// For a BLOB, precision is length in bytes.
// For a CLOB, precision is length in chars
long precision = countingReaderForClob == null ? small.length : countingReaderForClob.getLength();
long precision = countingReaderForClob == null ?
small.length : countingReaderForClob.getLength();
ValueLobDb v = ValueLobDb.createSmallLob(type, small, precision);
return v;
}
// For a BLOB, precision is length in bytes.
// For a CLOB, precision is length in chars
long precision = countingReaderForClob == null ? length : countingReaderForClob.getLength();
long precision = countingReaderForClob == null ?
length : countingReaderForClob.getLength();
return registerLob(type, lobId, LobStorageFrontend.TABLE_TEMP, length, precision);
} catch (IOException e) {
if (lobId != -1) {
......@@ -404,7 +410,8 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
private ValueLobDb registerLob(int type, long lobId, int tableId, long byteCount, long precision) throws SQLException {
private ValueLobDb registerLob(int type, long lobId, int tableId,
long byteCount, long precision) throws SQLException {
assertNotHolds(conn.getSession());
// see locking discussion at the top
synchronized (database) {
......@@ -495,7 +502,8 @@ public class LobStorageBackend implements LobStorageInterface {
* @param b the data
* @param compressAlgorithm the compression algorithm (may be null)
*/
void storeBlock(long lobId, int seq, long pos, byte[] b, String compressAlgorithm) throws SQLException {
void storeBlock(long lobId, int seq, long pos, byte[] b,
String compressAlgorithm) throws SQLException {
long block;
boolean blockExists = false;
if (compressAlgorithm != null) {
......@@ -523,7 +531,8 @@ public class LobStorageBackend implements LobStorageInterface {
if (!blockExists) {
block = nextBlock++;
setHashCacheBlock(hash, block);
String sql = "INSERT INTO " + LOB_DATA + "(BLOCK, COMPRESSED, DATA) VALUES(?, ?, ?)";
String sql = "INSERT INTO " + LOB_DATA +
"(BLOCK, COMPRESSED, DATA) VALUES(?, ?, ?)";
PreparedStatement prep = prepare(sql);
prep.setLong(1, block);
prep.setInt(2, compressAlgorithm == null ? 0 : 1);
......@@ -531,7 +540,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep.execute();
reuse(sql, prep);
}
String sql = "INSERT INTO " + LOB_MAP + "(LOB, SEQ, POS, HASH, BLOCK) VALUES(?, ?, ?, ?, ?)";
String sql = "INSERT INTO " + LOB_MAP +
"(LOB, SEQ, POS, HASH, BLOCK) VALUES(?, ?, ?, ?, ?)";
PreparedStatement prep = prepare(sql);
prep.setLong(1, lobId);
prep.setInt(2, seq);
......@@ -641,7 +651,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep.setLong(1, lobId);
ResultSet rs = prep.executeQuery();
if (!rs.next()) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry: " + lobId).getSQLException();
throw DbException.get(ErrorCode.IO_EXCEPTION_1,
"Missing lob entry: " + lobId).getSQLException();
}
byteCount = rs.getLong(1);
reuse(sql, prep);
......@@ -653,7 +664,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep.setLong(1, lobId);
ResultSet rs = prep.executeQuery();
if (!rs.next()) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry: " + lobId).getSQLException();
throw DbException.get(ErrorCode.IO_EXCEPTION_1,
"Missing lob entry: " + lobId).getSQLException();
}
int lobMapCount = rs.getInt(1);
reuse(sql, prep);
......
......@@ -49,11 +49,13 @@ public class LobStorageFrontend implements LobStorageInterface {
* @return the stream
*/
@Override
public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException {
public InputStream getInputStream(ValueLobDb lob, byte[] hmac,
long byteCount) throws IOException {
if (byteCount < 0) {
byteCount = Long.MAX_VALUE;
}
return new BufferedInputStream(new LobStorageRemoteInputStream(handler, lob, hmac, byteCount));
return new BufferedInputStream(new LobStorageRemoteInputStream(
handler, lob, hmac, byteCount));
}
@Override
......
......@@ -153,10 +153,12 @@ public class LobStorageMap implements LobStorageInterface {
b.reset();
reader = b;
}
CountingReaderInputStream in = new CountingReaderInputStream(reader, maxLength);
CountingReaderInputStream in =
new CountingReaderInputStream(reader, maxLength);
ValueLobDb lob = createLob(in, type);
// the length is not correct
lob = ValueLobDb.create(type, database, lob.getTableId(), lob.getLobId(), null, in.getLength());
lob = ValueLobDb.create(type, database,
lob.getTableId(), lob.getLobId(), null, in.getLength());
return lob;
} catch (IllegalStateException e) {
throw DbException.get(ErrorCode.OBJECT_CLOSED);
......@@ -179,7 +181,8 @@ public class LobStorageMap implements LobStorageInterface {
lobMap.put(lobId, value);
Object[] key = new Object[] { streamStoreId, lobId };
refMap.put(key, Boolean.TRUE);
ValueLobDb lob = ValueLobDb.create(type, database, tableId, lobId, null, length);
ValueLobDb lob = ValueLobDb.create(
type, database, tableId, lobId, null, length);
if (TRACE) {
trace("create " + tableId + "/" + lobId);
}
......@@ -208,9 +211,11 @@ public class LobStorageMap implements LobStorageInterface {
lobMap.put(lobId, value);
Object[] key = new Object[] { streamStoreId, lobId };
refMap.put(key, Boolean.TRUE);
ValueLobDb lob = ValueLobDb.create(type, database, tableId, lobId, null, length);
ValueLobDb lob = ValueLobDb.create(
type, database, tableId, lobId, null, length);
if (TRACE) {
trace("copy " + old.getTableId() + "/" + old.getLobId() + " > " + tableId + "/" + lobId);
trace("copy " + old.getTableId() + "/" + old.getLobId() +
" > " + tableId + "/" + lobId);
}
return lob;
}
......@@ -230,7 +235,8 @@ public class LobStorageMap implements LobStorageInterface {
long lobId = lob.getLobId();
Object[] value = lobMap.remove(lobId);
if (TRACE) {
trace("move " + lob.getTableId() + "/" + lob.getLobId() + " > " + tableId + "/" + lobId);
trace("move " + lob.getTableId() + "/" + lob.getLobId() +
" > " + tableId + "/" + lobId);
}
value[1] = tableId;
lobMap.put(lobId, value);
......
......@@ -39,7 +39,8 @@ class LobStorageRemoteInputStream extends InputStream {
*/
private long remainingBytes;
public LobStorageRemoteInputStream(DataHandler handler, ValueLobDb lob, byte[] hmac, long byteCount) {
public LobStorageRemoteInputStream(DataHandler handler, ValueLobDb lob,
byte[] hmac, long byteCount) {
this.handler = handler;
this.lob = lob.getLobId();
this.hmac = hmac;
......
......@@ -114,7 +114,8 @@ public class SourceCompiler {
* @param packageAndClassName the class name
* @return the class
*/
public Class<?> getClass(String packageAndClassName) throws ClassNotFoundException {
public Class<?> getClass(String packageAndClassName)
throws ClassNotFoundException {
Class<?> compiledClass = compiled.get(packageAndClassName);
if (compiledClass != null) {
......@@ -238,7 +239,8 @@ public class SourceCompiler {
* @param source the (possibly shortened) source code
* @return the full source code
*/
static String getCompleteSourceCode(String packageName, String className, String source) {
static String getCompleteSourceCode(String packageName, String className,
String source) {
if (source.startsWith("package ")) {
return source;
}
......@@ -410,15 +412,18 @@ public class SourceCompiler {
INIT_FAIL_EXCEPTION = initFailException;
}
public static Class<?> parseClass(String source, String packageAndClassName) {
public static Class<?> parseClass(String source,
String packageAndClassName) {
if (LOADER == null) {
throw new RuntimeException("Compile fail: no Groovy jar in the classpath", INIT_FAIL_EXCEPTION);
throw new RuntimeException(
"Compile fail: no Groovy jar in the classpath", INIT_FAIL_EXCEPTION);
}
try {
Object codeSource = Utils.newInstance("groovy.lang.GroovyCodeSource",
source, packageAndClassName + ".groovy", "UTF-8");
Utils.callMethod(codeSource, "setCachable", false);
Class<?> clazz = (Class<?>) Utils.callMethod(LOADER, "parseClass", codeSource);
Class<?> clazz = (Class<?>) Utils.callMethod(
LOADER, "parseClass", codeSource);
return clazz;
} catch (Exception e) {
throw new RuntimeException(e);
......@@ -471,7 +476,8 @@ public class SourceCompiler {
/**
* An in-memory class file manager.
*/
static class ClassFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
static class ClassFileManager extends
ForwardingJavaFileManager<StandardJavaFileManager> {
/**
* The class (only one class is kept).
......
......@@ -111,7 +111,8 @@ public class TempFileDeleter {
String f2 = refMap.remove(ref);
if (SysProperties.CHECK) {
if (f2 == null || !f2.equals(fileName)) {
DbException.throwInternalError("f2:" + f2 + " " + (f2 == null ? "" : f2) + " f:" + fileName);
DbException.throwInternalError("f2:" + f2 +
" " + (f2 == null ? "" : f2) + " f:" + fileName);
}
}
}
......
......@@ -120,7 +120,8 @@ public class ToChar {
* @param nlsParam the NLS parameter (if any)
* @return the formatted number
*/
public static String toChar(BigDecimal number, String format, String nlsParam) {
public static String toChar(BigDecimal number, String format,
String nlsParam) {
// short-circuit logic for formats that don't follow common logic below
String formatUp = format != null ? format.toUpperCase() : null;
......@@ -130,7 +131,8 @@ public class ToChar {
} else if (formatUp.equals("TME")) {
int pow = number.precision() - number.scale() - 1;
number = number.movePointLeft(pow);
return number.toPlainString() + "E" + (pow < 0 ? '-' : '+') + (abs(pow) < 10 ? "0" : "") + abs(pow);
return number.toPlainString() + "E" +
(pow < 0 ? '-' : '+') + (abs(pow) < 10 ? "0" : "") + abs(pow);
} else if (formatUp.equals("RN")) {
boolean lowercase = format.startsWith("r");
String rn = StringUtils.pad(toRomanNumeral(number.intValue()), 15, " ", false);
......@@ -256,7 +258,8 @@ public class ToChar {
String cs = currency.getSymbol();
output.insert(0, cs);
} else {
throw DbException.get(ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
throw DbException.get(
ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
}
}
......@@ -295,12 +298,14 @@ public class ToChar {
}
}
} else {
throw DbException.get(ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
throw DbException.get(
ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
}
}
}
addSign(output, number.signum(), leadingSign, trailingSign, trailingMinus, angleBrackets, fillMode);
addSign(output, number.signum(), leadingSign, trailingSign,
trailingMinus, angleBrackets, fillMode);
if (power != null) {
output.append('E');
......@@ -322,8 +327,9 @@ public class ToChar {
return output.toString();
}
private static void addSign(StringBuilder output, int signum, boolean leadingSign, boolean trailingSign,
boolean trailingMinus, boolean angleBrackets, boolean fillMode) {
private static void addSign(StringBuilder output, int signum,
boolean leadingSign, boolean trailingSign, boolean trailingMinus,
boolean angleBrackets, boolean fillMode) {
if (angleBrackets) {
if (signum < 0) {
output.insert(0, '<');
......@@ -381,8 +387,10 @@ public class ToChar {
}
private static String toRomanNumeral(int number) {
int[] values = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
String[] numerals = new String[] { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };
int[] values = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9,
5, 4, 1 };
String[] numerals = new String[] { "M", "CM", "D", "CD", "C", "XC",
"L", "XL", "X", "IX", "V", "IV", "I" };
StringBuilder result = new StringBuilder();
for (int i = 0; i < values.length; i++) {
int value = values[i];
......@@ -673,7 +681,8 @@ public class ToChar {
// Fractional seconds
} else if ((cap = containsAt(format, i, "FF1", "FF2", "FF3", "FF4", "FF5", "FF6", "FF7", "FF8", "FF9")) != null) {
} else if ((cap = containsAt(format, i, "FF1", "FF2",
"FF3", "FF4", "FF5", "FF6", "FF7", "FF8", "FF9")) != null) {
int x = Integer.parseInt(format.substring(i + 2, i + 3));
int ff = (int) (cal.get(Calendar.MILLISECOND) * Math.pow(10, x - 3));
output.append(ff);
......@@ -780,8 +789,12 @@ public class ToChar {
break;
}
}
} else if (format.charAt(i) == '-' || format.charAt(i) == '/' || format.charAt(i) == ','
|| format.charAt(i) == '.' || format.charAt(i) == ';' || format.charAt(i) == ':'
} else if (format.charAt(i) == '-'
|| format.charAt(i) == '/'
|| format.charAt(i) == ','
|| format.charAt(i) == '.'
|| format.charAt(i) == ';'
|| format.charAt(i) == ':'
|| format.charAt(i) == ' ') {
output.append(format.charAt(i));
i += 1;
......@@ -818,7 +831,8 @@ public class ToChar {
* the specified substrings at the specified index,
* <code>null</code> otherwise
*/
private static Capitalization containsAt(String s, int index, String... substrings) {
private static Capitalization containsAt(String s, int index,
String... substrings) {
for (String substring : substrings) {
if (index + substring.length() <= s.length()) {
boolean found = true;
......@@ -902,9 +916,11 @@ public class ToChar {
case LOWERCASE:
return s.toLowerCase();
case CAPITALIZE:
return Character.toUpperCase(s.charAt(0)) + (s.length() > 1 ? s.toLowerCase().substring(1) : "");
return Character.toUpperCase(s.charAt(0)) +
(s.length() > 1 ? s.toLowerCase().substring(1) : "");
default:
throw new IllegalArgumentException("Unknown capitalization strategy: " + this);
throw new IllegalArgumentException(
"Unknown capitalization strategy: " + this);
}
}
}
......
......@@ -51,7 +51,8 @@ public abstract class Tool {
* @param option the unsupported option
* @return this method never returns normally
*/
protected SQLException showUsageAndThrowUnsupportedOption(String option) throws SQLException {
protected SQLException showUsageAndThrowUnsupportedOption(String option)
throws SQLException {
showUsage();
throw throwUnsupportedOption(option);
}
......@@ -62,8 +63,10 @@ public abstract class Tool {
* @param option the unsupported option
* @return this method never returns normally
*/
protected SQLException throwUnsupportedOption(String option) throws SQLException {
throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, option).getSQLException();
protected SQLException throwUnsupportedOption(String option)
throws SQLException {
throw DbException.get(
ErrorCode.FEATURE_NOT_SUPPORTED_1, option).getSQLException();
}
/**
......@@ -109,7 +112,8 @@ public abstract class Tool {
out.println(resources.get(className));
out.println("Usage: java "+getClass().getName() + " <options>");
out.println(resources.get(className + ".main"));
out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html");
out.println("See also http://h2database.com/javadoc/" +
className.replace('.', '/') + ".html");
}
/**
......@@ -125,7 +129,8 @@ public abstract class Tool {
if (arg.equals(option)) {
return true;
} else if (arg.startsWith(option)) {
throw DbException.getUnsupportedException("expected: " + option + " got: " + arg);
throw DbException.getUnsupportedException(
"expected: " + option + " got: " + arg);
}
return false;
}
......
......@@ -150,7 +150,8 @@ public class Utils {
* @return the value
*/
public static long readLong(byte[] buff, int pos) {
return (((long) readInt(buff, pos)) << 32) + (readInt(buff, pos + 4) & 0xffffffffL);
return (((long) readInt(buff, pos)) << 32) +
(readInt(buff, pos + 4) & 0xffffffffL);
}
/**
......@@ -520,7 +521,8 @@ public class Utils {
public static <X> void sortTopN(X[] array, int offset, int limit,
Comparator<? super X> comp) {
partitionTopN(array, offset, limit, comp);
Arrays.sort(array, offset, (int) Math.min((long) offset + limit, array.length), comp);
Arrays.sort(array, offset,
(int) Math.min((long) offset + limit, array.length), comp);
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论