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

Limit line length to 80 characters

上级 06698d68
......@@ -37,7 +37,7 @@ public class Driver implements java.sql.Driver {
private static final Driver INSTANCE = new Driver();
private static final String DEFAULT_URL = "jdbc:default:connection";
private static final ThreadLocal<Connection> DEFAULT_CONNECTION =
private static final ThreadLocal<Connection> DEFAULT_CONNECTION =
new ThreadLocal<Connection>();
private static volatile boolean registered;
......
......@@ -22,10 +22,10 @@ public class RuleElement implements Rule {
public RuleElement(String name, String topic) {
this.name = name;
this.keyword = name.length() == 1 ||
this.keyword = name.length() == 1 ||
name.equals(StringUtils.toUpperEnglish(name));
topic = StringUtils.toLowerEnglish(topic);
this.type = topic.startsWith("function") ?
this.type = topic.startsWith("function") ?
Sentence.FUNCTION : Sentence.KEYWORD;
}
......
......@@ -148,7 +148,7 @@ public class DbContents {
schemas = new DbSchema[schemaNames.length];
for (int i = 0; i < schemaNames.length; i++) {
String schemaName = schemaNames[i];
boolean isDefault = defaultSchemaName == null ||
boolean isDefault = defaultSchemaName == null ||
defaultSchemaName.equals(schemaName);
DbSchema schema = new DbSchema(this, schemaName, isDefault);
if (isDefault) {
......@@ -170,8 +170,8 @@ public class DbContents {
defaultSchema = schema;
break;
}
if (defaultSchema == null ||
best == null ||
if (defaultSchema == null ||
best == null ||
schema.name.length() < best.length()) {
best = schema.name;
defaultSchema = schema;
......
......@@ -87,8 +87,8 @@ public class DbContextRule implements Rule {
} else if (s.length() == 0 || name.startsWith(up)) {
if (s.length() < name.length()) {
sentence.add(name, name.substring(s.length()), type);
sentence.add(schema.quotedName + ".",
schema.quotedName.substring(s.length()) + ".",
sentence.add(schema.quotedName + ".",
schema.quotedName.substring(s.length()) + ".",
Sentence.CONTEXT);
}
}
......@@ -121,8 +121,8 @@ public class DbContextRule implements Rule {
}
} else if (s.length() == 0 || name.startsWith(compare)) {
if (s.length() < name.length()) {
sentence.add(table.getQuotedName(),
table.getQuotedName().substring(s.length()),
sentence.add(table.getQuotedName(),
table.getQuotedName().substring(s.length()),
Sentence.CONTEXT);
}
}
......@@ -173,16 +173,16 @@ public class DbContextRule implements Rule {
name = column.getQuotedName();
compare = query;
}
if (compare.startsWith(name) &&
(columnType == null ||
if (compare.startsWith(name) &&
(columnType == null ||
column.getDataType().contains(columnType))) {
String b = s.substring(name.length());
if (best == null || b.length() < best.length()) {
best = b;
} else if (s.length() == 0 || name.startsWith(compare)) {
if (s.length() < name.length()) {
sentence.add(column.getName(),
column.getName().substring(s.length()),
sentence.add(column.getName(),
column.getName().substring(s.length()),
Sentence.CONTEXT);
}
}
......@@ -209,8 +209,8 @@ public class DbContextRule implements Rule {
}
} else if (s.length() == 0 || name.startsWith(up)) {
if (s.length() < name.length()) {
sentence.add(column.getName(),
column.getName().substring(s.length()),
sentence.add(column.getName(),
column.getName().substring(s.length()),
Sentence.CONTEXT);
}
}
......@@ -246,7 +246,7 @@ public class DbContextRule implements Rule {
String incompleteSentence = sentence.getQueryUpper();
String incompleteFunctionName = incompleteSentence;
if (incompleteSentence.contains("(")) {
incompleteFunctionName = incompleteSentence.substring(0,
incompleteFunctionName = incompleteSentence.substring(0,
incompleteSentence.indexOf('(')).trim();
}
......@@ -309,7 +309,7 @@ public class DbContextRule implements Rule {
sentence.addAlias(alias, sentence.getLastTable());
}
HashMap<String, DbTableOrView> map = sentence.getAliases();
if ((map != null && map.containsKey(alias)) ||
if ((map != null && map.containsKey(alias)) ||
(sentence.getLastTable() == null)) {
if (newAlias && s.length() == alias.length()) {
return s;
......@@ -324,15 +324,15 @@ public class DbContextRule implements Rule {
if (tables != null) {
String best = null;
for (DbTableOrView table : tables) {
String tableName =
String tableName =
StringUtils.toUpperEnglish(table.getName());
if (alias.startsWith(tableName) &&
if (alias.startsWith(tableName) &&
(best == null || tableName.length() > best.length())) {
sentence.setLastMatchedTable(table);
best = tableName;
} else if (s.length() == 0 || tableName.startsWith(alias)) {
sentence.add(tableName + ".",
tableName.substring(s.length()) + ".",
sentence.add(tableName + ".",
tableName.substring(s.length()) + ".",
Sentence.CONTEXT);
}
}
......
......@@ -28,7 +28,7 @@ public class DbProcedure {
public DbProcedure(DbSchema schema, ResultSet rs) throws SQLException {
this.schema = schema;
name = rs.getString("PROCEDURE_NAME");
returnsResult = rs.getShort("PROCEDURE_TYPE") ==
returnsResult = rs.getShort("PROCEDURE_TYPE") ==
DatabaseMetaData.procedureReturnsResult;
quotedName = schema.getContents().quoteIdentifier(name);
}
......
......@@ -79,10 +79,10 @@ public class DbSchema {
isSystem = true;
} else if ("INFORMATION_SCHEMA".equals(name)) {
isSystem = true;
} else if (!contents.isH2() &&
} else if (!contents.isH2() &&
StringUtils.toUpperEnglish(name).startsWith("INFO")) {
isSystem = true;
} else if (contents.isPostgreSQL() &&
} else if (contents.isPostgreSQL() &&
StringUtils.toUpperEnglish(name).startsWith("PG_")) {
isSystem = true;
} else if (contents.isDerby() && name.startsWith("SYS")) {
......
......@@ -123,7 +123,7 @@ public class CommandRemote implements CommandInterface {
writeInt(id).writeInt(objectId);
session.done(transfer);
int columnCount = transfer.readInt();
result = new ResultRemote(session, transfer, objectId,
result = new ResultRemote(session, transfer, objectId,
columnCount, Integer.MAX_VALUE);
break;
} catch (IOException e) {
......
......@@ -239,7 +239,7 @@ public class Constants {
* The default result set concurrency for statements created with
* Connection.createStatement() or prepareStatement(String sql).
*/
public static final int DEFAULT_RESULT_SET_CONCURRENCY =
public static final int DEFAULT_RESULT_SET_CONCURRENCY =
ResultSet.CONCUR_READ_ONLY;
/**
......@@ -311,13 +311,13 @@ public class Constants {
/**
* The memory needed by an object of class PageBtree.
*/
public static final int MEMORY_PAGE_BTREE =
public static final int MEMORY_PAGE_BTREE =
112 + MEMORY_DATA + 2 * MEMORY_OBJECT;
/**
* The memory needed by an object of class PageData.
*/
public static final int MEMORY_PAGE_DATA =
public static final int MEMORY_PAGE_DATA =
144 + MEMORY_DATA + 3 * MEMORY_OBJECT;
/**
......@@ -460,7 +460,7 @@ public class Constants {
* The database URL format in simplified Backus-Naur form.
*/
public static final String URL_FORMAT = START_URL +
"{ {.|mem:}[name] | [file:]fileName | " +
"{ {.|mem:}[name] | [file:]fileName | " +
"{tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
/**
......
......@@ -105,7 +105,7 @@ public class Database implements DataHandler {
private final HashMap<String, UserAggregate> aggregates = New.hashMap();
private final HashMap<String, Comment> comments = New.hashMap();
private final Set<Session> userSessions =
private final Set<Session> userSessions =
Collections.synchronizedSet(new HashSet<Session>());
private Session exclusiveSession;
private final BitField objectIds = new BitField();
......@@ -155,7 +155,7 @@ public class Database implements DataHandler {
private DatabaseCloser closeOnExit;
private Mode mode = Mode.getInstance(Mode.REGULAR);
private boolean multiThreaded;
private int maxOperationMemory =
private int maxOperationMemory =
Constants.DEFAULT_MAX_OPERATION_MEMORY;
private SmallLRUCache<String, String[]> lobFileListCache;
private final boolean autoServerMode;
......@@ -230,19 +230,19 @@ public class Database implements DataHandler {
if (modeName != null) {
this.mode = Mode.getInstance(modeName);
}
this.multiVersion =
this.multiVersion =
ci.getProperty("MVCC", false);
this.logMode =
this.logMode =
ci.getProperty("LOG", PageStore.LOG_MODE_SYNC);
this.javaObjectSerializerName =
this.javaObjectSerializerName =
ci.getProperty("JAVA_OBJECT_SERIALIZER", null);
boolean closeAtVmShutdown =
boolean closeAtVmShutdown =
dbSettings.dbCloseOnExit;
int traceLevelFile =
ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE,
int traceLevelFile =
ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE,
TraceSystem.DEFAULT_TRACE_LEVEL_FILE);
int traceLevelSystemOut =
int traceLevelSystemOut =
ci.getIntProperty(SetTypes.TRACE_LEVEL_SYSTEM_OUT,
TraceSystem.DEFAULT_TRACE_LEVEL_SYSTEM_OUT);
this.cacheType = StringUtils.toUpperEnglish(
......@@ -686,7 +686,7 @@ public class Database implements DataHandler {
data.session = systemSession;
meta = mainSchema.createTable(data);
IndexColumn[] pkCols = IndexColumn.wrap(new Column[] { columnId });
metaIdIndex = meta.addIndex(systemSession, "SYS_ID",
metaIdIndex = meta.addIndex(systemSession, "SYS_ID",
0, pkCols, IndexType.createPrimaryKey(
false, false), true, null);
objectIds.set(0);
......
......@@ -30,7 +30,7 @@ public class Engine implements SessionFactory {
private static final Engine INSTANCE = new Engine();
private static final HashMap<String, Database> DATABASES = New.hashMap();
private volatile long wrongPasswordDelay =
private volatile long wrongPasswordDelay =
SysProperties.DELAY_WRONG_PASSWORD_MIN;
private boolean jmx;
......@@ -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);
......@@ -59,7 +60,7 @@ public class Engine implements SessionFactory {
if (database.getAllUsers().size() == 0) {
// users is the last thing we add, so if no user is around,
// the database is new (or not initialized correctly)
user = new User(database, database.allocateObjectId(),
user = new User(database, database.allocateObjectId(),
ci.getUserName(), false);
user.setAdmin(true);
user.setUserPasswordHash(ci.getUserPasswordHash());
......@@ -188,7 +189,7 @@ public class Engine implements SessionFactory {
String value = ci.getProperty(setting);
try {
CommandInterface command = session.prepareCommand(
"SET " + Parser.quoteIdentifier(setting) + " " + value,
"SET " + Parser.quoteIdentifier(setting) + " " + value,
Integer.MAX_VALUE);
command.executeUpdate();
} catch (DbException e) {
......@@ -200,7 +201,7 @@ public class Engine implements SessionFactory {
}
if (init != null) {
try {
CommandInterface command = session.prepareCommand(init,
CommandInterface command = session.prepareCommand(init,
Integer.MAX_VALUE);
command.executeUpdate();
} catch (DbException e) {
......@@ -231,7 +232,7 @@ public class Engine implements SessionFactory {
ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_ALONE);
}
throw DbException.get(
ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_CLUSTERED_1,
ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_CLUSTERED_1,
clusterDb);
}
}
......
......@@ -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;
}
......
......@@ -173,7 +173,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
public Cursor find(Session session, SearchRow first, SearchRow last) {
return find(session, first, last, null);
}
@Override
public Cursor findByGeometry(TableFilter filter, SearchRow intersection) {
return find(filter.getSession(), null, null, intersection);
......
......@@ -723,7 +723,7 @@ public class DataUtils {
* @param message the message
* @return the exception
*/
public static ConcurrentModificationException
public static ConcurrentModificationException
newConcurrentModificationException(String message) {
return new ConcurrentModificationException(formatMessage(0, message));
}
......
......@@ -39,7 +39,7 @@ public class FileStore {
* The free spaces between the chunks. The first block to use is block 2
* (the first two blocks are the store header).
*/
protected final FreeSpaceBitSet freeSpace =
protected final FreeSpaceBitSet freeSpace =
new FreeSpaceBitSet(2, MVStore.BLOCK_SIZE);
/**
......
......@@ -156,7 +156,7 @@ public class MVStore {
/**
* The map of chunks.
*/
private final ConcurrentHashMap<Integer, Chunk> chunks =
private final ConcurrentHashMap<Integer, Chunk> chunks =
new ConcurrentHashMap<Integer, Chunk>();
/**
......@@ -173,7 +173,7 @@ public class MVStore {
*/
private MVMapConcurrent<String, String> meta;
private final ConcurrentHashMap<Integer, MVMap<?, ?>> maps =
private final ConcurrentHashMap<Integer, MVMap<?, ?>> maps =
new ConcurrentHashMap<Integer, MVMap<?, ?>>();
private HashMap<String, Object> fileHeader = New.hashMap();
......@@ -1911,7 +1911,7 @@ public class MVStore {
c = chunks.get(c.id - 1);
}
Chunk last = lastChunk;
if (removeChunksNewerThan != null &&
if (removeChunksNewerThan != null &&
last.version > removeChunksNewerThan.version) {
revertTemp(version);
loadFromFile = true;
......@@ -2158,8 +2158,8 @@ public class MVStore {
// start the background thread if needed
if (millis > 0) {
int sleep = Math.max(1, millis / 10);
BackgroundWriterThread t =
new BackgroundWriterThread(this, sleep,
BackgroundWriterThread t =
new BackgroundWriterThread(this, sleep,
fileStore.toString());
t.start();
backgroundWriterThread = t;
......
......@@ -17,7 +17,7 @@ import java.util.TreeMap;
*/
public class OffHeapStore extends FileStore {
private final TreeMap<Long, ByteBuffer> memory =
private final TreeMap<Long, ByteBuffer> memory =
new TreeMap<Long, ByteBuffer>();
@Override
......
......@@ -30,7 +30,7 @@ import org.h2.mvstore.type.DataType;
*/
public class Page {
private static final int SHARED_KEYS = 1, SHARED_VALUES = 2,
private static final int SHARED_KEYS = 1, SHARED_VALUES = 2,
SHARED_CHILDREN = 4, SHARED_COUNTS = 8;
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
......
......@@ -41,7 +41,7 @@ public class StreamStore {
private int minBlockSize = 256;
private int maxBlockSize = 256 * 1024;
private final AtomicLong nextKey = new AtomicLong();
private final AtomicReference<byte[]> nextBuffer =
private final AtomicReference<byte[]> nextBuffer =
new AtomicReference<byte[]>();
/**
......
......@@ -627,7 +627,7 @@ public class CacheLongKeyLIRS<V> {
}
if (e.isHot()) {
if (e != stack.stackNext) {
if (stackMoveDistance == 0 ||
if (stackMoveDistance == 0 ||
stackMoveCounter - e.topMove > stackMoveDistance) {
access(key, hash);
}
......@@ -651,7 +651,7 @@ public class CacheLongKeyLIRS<V> {
}
if (e.isHot()) {
if (e != stack.stackNext) {
if (stackMoveDistance == 0 ||
if (stackMoveDistance == 0 ||
stackMoveCounter - e.topMove > stackMoveDistance) {
// move a hot entry to the top of the stack
// unless it is already there
......
......@@ -67,11 +67,11 @@ public class MVDelegateIndex extends BaseIndex implements MVIndex {
@Override
public Cursor find(Session session, SearchRow first, SearchRow last) {
ValueLong min = mainIndex.getKey(first,
ValueLong min = mainIndex.getKey(first,
MVPrimaryIndex.MIN, MVPrimaryIndex.MIN);
// ifNull is MIN_VALUE as well, because the column is never NULL
// so avoid returning all rows (returning one row is OK)
ValueLong max = mainIndex.getKey(last,
ValueLong max = mainIndex.getKey(last,
MVPrimaryIndex.MAX, MVPrimaryIndex.MIN);
return mainIndex.find(session, min, max);
}
......
......@@ -281,7 +281,7 @@ public class MVPrimaryIndex extends BaseIndex {
/**
* The maximum number of rows, including uncommitted rows of any session.
*
*
* @return the maximum number of rows
*/
public long getRowCountMax() {
......@@ -314,7 +314,7 @@ public class MVPrimaryIndex extends BaseIndex {
/**
* Get the key from the row.
*
*
* @param row the row
* @param ifEmpty the value to use if the row is empty
* @param ifNull the value to use if the column is NULL
......@@ -335,7 +335,7 @@ public class MVPrimaryIndex extends BaseIndex {
/**
* Search for a specific row or a set of rows.
*
*
* @param session the session
* @param first the key of the first row
* @param last the key of the last row
......@@ -353,7 +353,7 @@ public class MVPrimaryIndex extends BaseIndex {
/**
* Get the map to store the data.
*
*
* @param session the session
* @return the map
*/
......
......@@ -308,7 +308,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
public double getCost(Session session, int[] masks, TableFilter filter,
SortOrder sortOrder) {
try {
return 10 * getCostRangeIndex(masks,
return 10 * getCostRangeIndex(masks,
dataMap.sizeAsLongMax(), filter, sortOrder);
} catch (IllegalStateException e) {
throw DbException.get(ErrorCode.OBJECT_CLOSED);
......@@ -341,7 +341,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
Value key = first ? map.firstKey() : map.lastKey();
while (true) {
if (key == null) {
return new MVStoreCursor(session,
return new MVStoreCursor(session,
Collections.<Value>emptyList().iterator(), null);
}
if (((ValueArray) key).getList()[0] != ValueNull.INSTANCE) {
......
......@@ -212,7 +212,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
if (intersection == null) {
return find(session);
}
Iterator<SpatialKey> cursor =
Iterator<SpatialKey> cursor =
spatialMap.findIntersectingKeys(getEnvelope(intersection));
TransactionMap<SpatialKey, Value> map = getMap(session);
Iterator<SpatialKey> it = map.wrapIterator(cursor, false);
......
......@@ -135,7 +135,7 @@ public class MVTableEngine implements TableEngine {
* The map of open tables.
* Key: the map name, value: the table.
*/
final ConcurrentHashMap<String, MVTable> tableMap =
final ConcurrentHashMap<String, MVTable> tableMap =
new ConcurrentHashMap<String, MVTable>();
/**
......
......@@ -866,7 +866,7 @@ public class TransactionStore {
*/
public TransactionMap<K, V> getInstance(Transaction transaction,
long savepoint) {
TransactionMap<K, V> m =
TransactionMap<K, V> m =
new TransactionMap<K, V>(transaction, map, mapId);
m.setSavepoint(savepoint);
return m;
......
......@@ -183,7 +183,7 @@ public class ValueDataType implements DataType {
int type = v.getType();
switch (type) {
case Value.BOOLEAN:
buff.put((byte) (v.getBoolean().booleanValue() ?
buff.put((byte) (v.getBoolean().booleanValue() ?
BOOLEAN_TRUE : BOOLEAN_FALSE));
break;
case Value.BYTE:
......@@ -518,11 +518,11 @@ public class ValueDataType implements DataType {
int tableId = readVarInt(buff);
long lobId = readVarLong(buff);
long precision = readVarLong(buff);
ValueLobDb lob = ValueLobDb.create(type,
ValueLobDb lob = ValueLobDb.create(type,
handler, tableId, lobId, null, precision);
return lob;
} else {
throw DbException.get(ErrorCode.FILE_CORRUPTED_1,
throw DbException.get(ErrorCode.FILE_CORRUPTED_1,
"lob type: " + smallLen);
}
}
......@@ -538,9 +538,9 @@ public class ValueDataType implements DataType {
SimpleResultSet rs = new SimpleResultSet();
int columns = readVarInt(buff);
for (int i = 0; i < columns; i++) {
rs.addColumn(readString(buff),
readVarInt(buff),
readVarInt(buff),
rs.addColumn(readString(buff),
readVarInt(buff),
readVarInt(buff),
readVarInt(buff));
}
while (true) {
......
......@@ -43,16 +43,16 @@ public class CipherFactory {
/**
* The default password to use for the .h2.keystore file
*/
public static final String KEYSTORE_PASSWORD =
public static final String KEYSTORE_PASSWORD =
"h2pass";
private static final String KEYSTORE =
private static final String KEYSTORE =
"~/.h2.keystore";
private static final String KEYSTORE_KEY =
private static final String KEYSTORE_KEY =
"javax.net.ssl.keyStore";
private static final String KEYSTORE_PASSWORD_KEY =
private static final String KEYSTORE_PASSWORD_KEY =
"javax.net.ssl.keyStorePassword";
private static final String ANONYMOUS_CIPHER_SUITE =
private static final String ANONYMOUS_CIPHER_SUITE =
"SSL_DH_anon_WITH_RC4_128_MD5";
private CipherFactory() {
......
......@@ -32,13 +32,13 @@ public class Fog implements BlockCipher {
}
private void encryptBlock(byte[] in, byte[] out, int off) {
int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) |
int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) |
((in[off+2] & 255) << 8) | (in[off+3] & 255);
int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) |
int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) |
((in[off+6] & 255) << 8) | (in[off+7] & 255);
int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) |
int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) |
((in[off+10] & 255) << 8) | (in[off+11] & 255);
int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) |
int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) |
((in[off+14] & 255) << 8) | (in[off+15] & 255);
int k = key;
int s = x1 & 31;
......@@ -62,13 +62,13 @@ public class Fog implements BlockCipher {
}
private void decryptBlock(byte[] in, byte[] out, int off) {
int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) |
int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) |
((in[off+2] & 255) << 8) | (in[off+3] & 255);
int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) |
int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) |
((in[off+6] & 255) << 8) | (in[off+7] & 255);
int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) |
int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) |
((in[off+10] & 255) << 8) | (in[off+11] & 255);
int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) |
int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) |
((in[off+14] & 255) << 8) | (in[off+15] & 255);
int k = key;
int s = 32 - (x0 & 31);
......
......@@ -209,7 +209,7 @@ public class SHA256 {
Arrays.fill(hh, 0);
}
private void calculateHash(byte[] data, int len,
private void calculateHash(byte[] data, int len,
byte[] byteBuff, int[] intBuff) {
int[] w = this.w;
int[] hh = this.hh;
......
......@@ -83,10 +83,10 @@ public class TcpServerThread implements Runnable {
}
int minClientVersion = transfer.readInt();
if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6);
} else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_14) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_14);
}
int maxClientVersion = transfer.readInt();
......
......@@ -33,7 +33,7 @@ public class FileStore {
/**
* The magic file header.
*/
private static final String HEADER =
private static final String HEADER =
"-- H2 0.5/B -- ".substring(0, Constants.FILE_BLOCK_SIZE - 1) + "\n";
/**
......@@ -125,7 +125,7 @@ public class FileStore {
if (cipher == null) {
store = new FileStore(handler, name, mode);
} else {
store = new SecureFileStore(handler, name, mode,
store = new SecureFileStore(handler, name, mode,
cipher, key, keyIterations);
}
return store;
......
......@@ -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;
......
......@@ -476,7 +476,7 @@ public class Csv implements SimpleRowSource {
break;
}
}
String s = new String(inputBuffer,
String s = new String(inputBuffer,
inputBufferStart, inputBufferPos - inputBufferStart - sep);
if (containsEscape) {
s = unEscape(s);
......@@ -528,7 +528,7 @@ public class Csv implements SimpleRowSource {
break;
}
}
String s = new String(inputBuffer,
String s = new String(inputBuffer,
inputBufferStart, inputBufferPos - inputBufferStart - 1);
if (!preserveWhitespace) {
s = s.trim();
......
......@@ -123,7 +123,7 @@ public class NetUtils {
SysProperties.SOCKET_CONNECT_TIMEOUT);
return socket;
} catch (IOException e) {
if (System.currentTimeMillis() - start >=
if (System.currentTimeMillis() - start >=
SysProperties.SOCKET_CONNECT_TIMEOUT) {
// either it was a connect timeout,
// or list of different exceptions
......
......@@ -30,7 +30,7 @@ import java.util.Map;
public class Profiler implements Runnable {
private static Instrumentation instrumentation;
private static final String LINE_SEPARATOR =
private static final String LINE_SEPARATOR =
System.getProperty("line.separator", "\n");
private static final int MAX_ELEMENTS = 1000;
......@@ -73,14 +73,14 @@ public class Profiler implements Runnable {
).split(",");
private volatile boolean stop;
private final HashMap<String, Integer> counts =
private final HashMap<String, Integer> counts =
new HashMap<String, Integer>();
/**
* The summary (usually one entry per package, unless sumClasses is enabled,
* in which case it's one entry per class).
*/
private final HashMap<String, Integer> summary =
private final HashMap<String, Integer> summary =
new HashMap<String, Integer>();
private int minCount = 1;
private int total;
......@@ -122,7 +122,7 @@ public class Profiler implements Runnable {
private void run(String... args) {
if (args.length == 0) {
System.out.println("Show profiling data");
System.out.println("Usage: java " + getClass().getName() +
System.out.println("Usage: java " + getClass().getName() +
" <pid> | <stackTraceFileNames>");
System.out.println("Processes:");
String processes = exec("jps", "-l");
......@@ -409,7 +409,7 @@ public class Profiler implements Runnable {
map.put(trace, oldCount + 1);
}
while (map.size() > MAX_ELEMENTS) {
for (Iterator<Map.Entry<String, Integer>> ei =
for (Iterator<Map.Entry<String, Integer>> ei =
map.entrySet().iterator(); ei.hasNext();) {
Map.Entry<String, Integer> e = ei.next();
if (e.getValue() <= minCount) {
......
......@@ -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).
......
......@@ -20,7 +20,7 @@ import org.h2.message.DbException;
*/
public class StringUtils {
private static SoftReference<String[]> softCache =
private static SoftReference<String[]> softCache =
new SoftReference<String[]>(null);
private static long softCacheCreated;
private static final char[] HEX = "0123456789abcdef".toCharArray();
......
......@@ -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;
}
......
......@@ -67,7 +67,7 @@ public class Utils {
/**
* In order to manage more than one class loader
*/
private static ArrayList<ClassFactory> userClassFactories =
private static ArrayList<ClassFactory> userClassFactories =
new ArrayList<ClassFactory>();
private static String[] allowedClassNamePrefixes;
......@@ -115,9 +115,9 @@ public class Utils {
}
private static int readInt(byte[] buff, int pos) {
return (buff[pos++] << 24) +
((buff[pos++] & 0xff) << 16) +
((buff[pos++] & 0xff) << 8) +
return (buff[pos++] << 24) +
((buff[pos++] & 0xff) << 16) +
((buff[pos++] & 0xff) << 8) +
(buff[pos] & 0xff);
}
......@@ -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);
}
/**
......@@ -401,7 +402,7 @@ public class Utils {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
is = new ObjectInputStream(in) {
@Override
protected Class<?> resolveClass(ObjectStreamClass desc)
protected Class<?> resolveClass(ObjectStreamClass desc)
throws IOException, ClassNotFoundException {
try {
return Class.forName(desc.getName(), true, loader);
......@@ -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);
}
/**
......@@ -664,7 +666,7 @@ public class Utils {
} catch (ClassNotFoundException e) {
try {
return Class.forName(
className, true,
className, true,
Thread.currentThread().getContextClassLoader());
} catch (Exception e2) {
throw DbException.get(
......@@ -775,7 +777,7 @@ public class Utils {
int bestMatch = 0;
boolean isStatic = instance == null;
for (Method m : clazz.getMethods()) {
if (Modifier.isStatic(m.getModifiers()) == isStatic &&
if (Modifier.isStatic(m.getModifiers()) == isStatic &&
m.getName().equals(methodName)) {
int p = match(m.getParameterTypes(), params);
if (p > bestMatch) {
......
......@@ -162,7 +162,7 @@ public class CompareMode {
*/
public static String getName(Locale l) {
Locale english = Locale.ENGLISH;
String name = l.getDisplayLanguage(english) + ' ' +
String name = l.getDisplayLanguage(english) + ' ' +
l.getDisplayCountry(english) + ' ' + l.getVariant();
name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_'));
return name;
......@@ -177,7 +177,7 @@ public class CompareMode {
* @return true if they match
*/
static boolean compareLocaleNames(Locale locale, String name) {
return name.equalsIgnoreCase(locale.toString()) ||
return name.equalsIgnoreCase(locale.toString()) ||
name.equalsIgnoreCase(getName(locale));
}
......
......@@ -54,7 +54,7 @@ public class DataType {
*/
public static final Class<?> GEOMETRY_CLASS;
private static final String GEOMETRY_CLASS_NAME =
private static final String GEOMETRY_CLASS_NAME =
"com.vividsolutions.jts.geom.Geometry";
/**
......@@ -194,7 +194,7 @@ public class DataType {
);
add(Value.STRING, Types.VARCHAR, "String",
createString(true),
new String[]{"VARCHAR", "VARCHAR2", "NVARCHAR", "NVARCHAR2",
new String[]{"VARCHAR", "VARCHAR2", "NVARCHAR", "NVARCHAR2",
"VARCHAR_CASESENSITIVE", "CHARACTER VARYING", "TID"},
// 24 for ValueString, 24 for String
48
......@@ -308,7 +308,7 @@ public class DataType {
56
);
add(Value.TIMESTAMP, Types.TIMESTAMP, "Timestamp",
createDate(ValueTimestamp.PRECISION, "TIMESTAMP",
createDate(ValueTimestamp.PRECISION, "TIMESTAMP",
ValueTimestamp.DEFAULT_SCALE, ValueTimestamp.DISPLAY_SIZE),
new String[]{"TIMESTAMP", "DATETIME", "SMALLDATETIME"},
// 24 for ValueTimestamp, 32 for java.sql.Timestamp
......@@ -341,14 +341,14 @@ public class DataType {
);
add(Value.BLOB, Types.BLOB, "Blob",
createLob(),
new String[]{"BLOB", "TINYBLOB", "MEDIUMBLOB",
new String[]{"BLOB", "TINYBLOB", "MEDIUMBLOB",
"LONGBLOB", "IMAGE", "OID"},
// 80 for ValueLob, 24 for String
104
);
add(Value.CLOB, Types.CLOB, "Clob",
createLob(),
new String[]{"CLOB", "TINYTEXT", "TEXT", "MEDIUMTEXT",
new String[]{"CLOB", "TINYTEXT", "TEXT", "MEDIUMTEXT",
"LONGTEXT", "NTEXT", "NCLOB"},
// 80 for ValueLob, 24 for String
104
......@@ -498,97 +498,97 @@ public class DataType {
}
case Value.BYTES: {
byte[] buff = rs.getBytes(columnIndex);
v = buff == null ? (Value) ValueNull.INSTANCE :
v = buff == null ? (Value) ValueNull.INSTANCE :
ValueBytes.getNoCopy(buff);
break;
}
case Value.UUID: {
byte[] buff = rs.getBytes(columnIndex);
v = buff == null ? (Value) ValueNull.INSTANCE :
v = buff == null ? (Value) ValueNull.INSTANCE :
ValueUuid.get(buff);
break;
}
case Value.BOOLEAN: {
boolean value = rs.getBoolean(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueBoolean.get(value);
break;
}
case Value.BYTE: {
byte value = rs.getByte(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueByte.get(value);
break;
}
case Value.DATE: {
Date value = rs.getDate(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE :
v = value == null ? (Value) ValueNull.INSTANCE :
ValueDate.get(value);
break;
}
case Value.TIME: {
Time value = rs.getTime(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE :
v = value == null ? (Value) ValueNull.INSTANCE :
ValueTime.get(value);
break;
}
case Value.TIMESTAMP: {
Timestamp value = rs.getTimestamp(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE :
v = value == null ? (Value) ValueNull.INSTANCE :
ValueTimestamp.get(value);
break;
}
case Value.DECIMAL: {
BigDecimal value = rs.getBigDecimal(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE :
v = value == null ? (Value) ValueNull.INSTANCE :
ValueDecimal.get(value);
break;
}
case Value.DOUBLE: {
double value = rs.getDouble(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueDouble.get(value);
break;
}
case Value.FLOAT: {
float value = rs.getFloat(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueFloat.get(value);
break;
}
case Value.INT: {
int value = rs.getInt(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueInt.get(value);
break;
}
case Value.LONG: {
long value = rs.getLong(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueLong.get(value);
break;
}
case Value.SHORT: {
short value = rs.getShort(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueShort.get(value);
break;
}
case Value.STRING_IGNORECASE: {
String s = rs.getString(columnIndex);
v = (s == null) ? (Value) ValueNull.INSTANCE :
v = (s == null) ? (Value) ValueNull.INSTANCE :
ValueStringIgnoreCase.get(s);
break;
}
case Value.STRING_FIXED: {
String s = rs.getString(columnIndex);
v = (s == null) ? (Value) ValueNull.INSTANCE :
v = (s == null) ? (Value) ValueNull.INSTANCE :
ValueStringFixed.get(s);
break;
}
case Value.STRING: {
String s = rs.getString(columnIndex);
v = (s == null) ? (Value) ValueNull.INSTANCE :
v = (s == null) ? (Value) ValueNull.INSTANCE :
ValueString.get(s);
break;
}
......@@ -613,7 +613,7 @@ public class DataType {
Value.BLOB, rs.getBytes(columnIndex));
} else {
InputStream in = rs.getBinaryStream(columnIndex);
v = (in == null) ? (Value) ValueNull.INSTANCE :
v = (in == null) ? (Value) ValueNull.INSTANCE :
session.getDataHandler().getLobStorage().createBlob(in, -1);
}
break;
......@@ -621,11 +621,11 @@ public class DataType {
case Value.JAVA_OBJECT: {
if (SysProperties.serializeJavaObject) {
byte[] buff = rs.getBytes(columnIndex);
v = buff == null ? ValueNull.INSTANCE :
v = buff == null ? ValueNull.INSTANCE :
ValueJavaObject.getNoCopy(null, buff, session.getDataHandler());
} else {
Object o = rs.getObject(columnIndex);
v = o == null ? ValueNull.INSTANCE :
v = o == null ? ValueNull.INSTANCE :
ValueJavaObject.getNoCopy(o, null, session.getDataHandler());
}
break;
......
......@@ -164,11 +164,11 @@ public abstract class Value {
*/
public static final int TYPE_COUNT = GEOMETRY + 1;
private static SoftReference<Value[]> softCache =
private static SoftReference<Value[]> softCache =
new SoftReference<Value[]>(null);
private static final BigDecimal MAX_LONG_DECIMAL =
private static final BigDecimal MAX_LONG_DECIMAL =
BigDecimal.valueOf(Long.MAX_VALUE);
private static final BigDecimal MIN_LONG_DECIMAL =
private static final BigDecimal MIN_LONG_DECIMAL =
BigDecimal.valueOf(Long.MIN_VALUE);
/**
......@@ -376,7 +376,7 @@ public abstract class Value {
}
// cacheMiss++;
// cache[cacheCleaner] = null;
// cacheCleaner = (cacheCleaner + 1) &
// cacheCleaner = (cacheCleaner + 1) &
// (Constants.OBJECT_CACHE_SIZE - 1);
cache[index] = v;
}
......@@ -863,7 +863,7 @@ public abstract class Value {
return ValueBytes.getNoCopy(
StringUtils.convertHexToBytes(s.trim()));
case JAVA_OBJECT:
return ValueJavaObject.getNoCopy(null,
return ValueJavaObject.getNoCopy(null,
StringUtils.convertHexToBytes(s.trim()), getDataHandler());
case STRING:
return ValueString.get(s);
......@@ -1010,7 +1010,7 @@ public abstract class Value {
}
private static long convertToLong(BigDecimal x) {
if (x.compareTo(MAX_LONG_DECIMAL) > 0 ||
if (x.compareTo(MAX_LONG_DECIMAL) > 0 ||
x.compareTo(Value.MIN_LONG_DECIMAL) < 0) {
throw DbException.get(
ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, x.toString());
......
......@@ -93,8 +93,8 @@ public class ValueDecimal extends Value {
if (dec.value.signum() == 0) {
throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getSQL());
}
BigDecimal bd = value.divide(dec.value,
value.scale() + DIVIDE_SCALE_ADD,
BigDecimal bd = value.divide(dec.value,
value.scale() + DIVIDE_SCALE_ADD,
BigDecimal.ROUND_HALF_DOWN);
if (bd.signum() == 0) {
bd = BigDecimal.ZERO;
......@@ -254,7 +254,7 @@ public class ValueDecimal extends Value {
// value and scale (thus 2.0 is not equal to 2.00 when using equals;
// however -0.0 and 0.0 are). Can not use compareTo because 2.0 and 2.00
// have different hash codes
return other instanceof ValueDecimal &&
return other instanceof ValueDecimal &&
value.equals(((ValueDecimal) other).value);
}
......
......@@ -35,7 +35,7 @@ public class ValueGeometry extends Value {
/**
* As conversion from/to WKB cost a significant amount of CPU cycles, WKB
* are kept in ValueGeometry instance.
*
*
* We always calculate the WKB, because not all WKT values can be
* represented in WKB, but since we persist it in WKB format, it has to be
* valid in WKB
......@@ -43,7 +43,7 @@ public class ValueGeometry extends Value {
private final byte[] bytes;
private final int hashCode;
/**
* The value. Converted from WKB only on request as conversion from/to WKB
* cost a significant amount of CPU cycles.
......@@ -52,7 +52,7 @@ public class ValueGeometry extends Value {
/**
* Create a new geometry objects.
*
*
* @param bytes the bytes (always known)
* @param geometry the geometry object (may be null)
*/
......@@ -76,20 +76,20 @@ public class ValueGeometry extends Value {
byte[] bytes = convertToWKB(g);
return (ValueGeometry) Value.cache(new ValueGeometry(bytes, g));
}
private static byte[] convertToWKB(Geometry g) {
boolean includeSRID = g.getSRID() != 0;
int dimensionCount = getDimensionCount(g);
WKBWriter writer = new WKBWriter(dimensionCount, includeSRID);
return writer.write(g);
return writer.write(g);
}
private static int getDimensionCount(Geometry geometry) {
ZVisitor finder = new ZVisitor();
geometry.apply(finder);
return finder.isFoundZ() ? 3 : 2;
}
/**
* Get or create a geometry value for the given geometry.
*
......@@ -125,7 +125,7 @@ public class ValueGeometry extends Value {
}
return geometry;
}
/**
* Test if this geometry envelope intersects with the other geometry
* envelope.
......@@ -241,7 +241,7 @@ public class ValueGeometry extends Value {
public boolean equals(Object other) {
// The JTS library only does half-way support for 3D coordinates, so
// their equals method only checks the first two coordinates.
return other instanceof ValueGeometry &&
return other instanceof ValueGeometry &&
Arrays.equals(getWKB(), ((ValueGeometry) other).getWKB());
}
......
......@@ -19,7 +19,7 @@ import org.h2.util.Utils;
*/
public class ValueJavaObject extends ValueBytes {
private static final ValueJavaObject EMPTY =
private static final ValueJavaObject EMPTY =
new ValueJavaObject(Utils.EMPTY_BYTES, null);
private final DataHandler dataHandler;
......
......@@ -115,7 +115,7 @@ public class ValueLob extends Value {
DbException.throwInternalError("0 LOB");
}
String table = tableId < 0 ? ".temp" : ".t" + tableId;
return getFileNamePrefix(handler.getDatabasePath(), objectId) +
return getFileNamePrefix(handler.getDatabasePath(), objectId) +
table + Constants.SUFFIX_LOB_FILE;
}
......@@ -204,7 +204,7 @@ public class ValueLob extends Value {
remaining = Integer.MAX_VALUE;
}
int inplace = handler.getMaxLengthInplaceLob();
long m = compress ?
long m = compress ?
Constants.IO_BUFFER_SIZE_COMPRESS : Constants.IO_BUFFER_SIZE;
if (m < remaining && m <= inplace) {
// using "1L" to force long arithmetic
......@@ -256,11 +256,11 @@ public class ValueLob extends Value {
objectId /= SysProperties.LOB_FILES_PER_DIRECTORY;
while (objectId > 0) {
f = objectId % SysProperties.LOB_FILES_PER_DIRECTORY;
name = SysProperties.FILE_SEPARATOR + f +
name = SysProperties.FILE_SEPARATOR + f +
Constants.SUFFIX_LOBS_DIRECTORY + name;
objectId /= SysProperties.LOB_FILES_PER_DIRECTORY;
}
name = FileUtils.toRealPath(path +
name = FileUtils.toRealPath(path +
Constants.SUFFIX_LOBS_DIRECTORY + name);
return name;
}
......@@ -268,7 +268,7 @@ public class ValueLob extends Value {
private static int getNewObjectId(DataHandler h) {
String path = h.getDatabasePath();
if ((path != null) && (path.length() == 0)) {
path = new File(Utils.getProperty("java.io.tmpdir", "."),
path = new File(Utils.getProperty("java.io.tmpdir", "."),
SysProperties.PREFIX_TEMP_FILE).getAbsolutePath();
}
int newId = 0;
......@@ -406,7 +406,7 @@ public class ValueLob extends Value {
synchronized (h) {
String path = h.getDatabasePath();
if ((path != null) && (path.length() == 0)) {
path = new File(Utils.getProperty("java.io.tmpdir", "."),
path = new File(Utils.getProperty("java.io.tmpdir", "."),
SysProperties.PREFIX_TEMP_FILE).getAbsolutePath();
}
objectId = getNewObjectId(h);
......@@ -568,7 +568,7 @@ public class ValueLob extends Value {
@Override
public String getString() {
int len = precision > Integer.MAX_VALUE || precision == 0 ?
int len = precision > Integer.MAX_VALUE || precision == 0 ?
Integer.MAX_VALUE : (int) precision;
try {
if (type == Value.CLOB) {
......
......@@ -204,7 +204,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override
public boolean isLinked() {
return tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE &&
return tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE &&
small == null;
}
......@@ -231,7 +231,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override
public void unlink(DataHandler database) {
if (small == null &&
if (small == null &&
tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE) {
database.getLobStorage().setTable(this,
LobStorageFrontend.TABLE_ID_SESSION_VARIABLE);
......@@ -283,7 +283,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override
public String getString() {
int len = precision > Integer.MAX_VALUE || precision == 0 ?
int len = precision > Integer.MAX_VALUE || precision == 0 ?
Integer.MAX_VALUE : (int) precision;
try {
if (type == Value.CLOB) {
......
......@@ -14,7 +14,7 @@ import org.h2.util.StringUtils;
*/
public class ValueStringIgnoreCase extends ValueString {
private static final ValueStringIgnoreCase EMPTY =
private static final ValueStringIgnoreCase EMPTY =
new ValueStringIgnoreCase("");
private int hash;
......
......@@ -152,7 +152,7 @@ public class ValueTimestamp extends Value {
long millis = DateTimeUtils.getMillis(
tz, year, month, day, hour, minute, (int) second, (int) ms);
ms = DateTimeUtils.convertToLocal(
new Date(millis),
new Date(millis),
Calendar.getInstance(TimeZone.getTimeZone("UTC")));
long md = DateTimeUtils.MILLIS_PER_DAY;
long absoluteDay = (ms >= 0 ? ms : ms - md + 1) / md;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论