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

Limit line length to 80 characters

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