提交 16c09993 authored 作者: Thomas Mueller's avatar Thomas Mueller

Removed unused code and reduce visibility where possible.

上级 32e1650a
...@@ -28,14 +28,14 @@ public abstract class Command implements CommandInterface { ...@@ -28,14 +28,14 @@ public abstract class Command implements CommandInterface {
protected final Session session; protected final Session session;
/** /**
* The trace module. * The last start time.
*/ */
protected final Trace trace; protected long startTime;
/** /**
* The last start time. * The trace module.
*/ */
protected long startTime; private final Trace trace;
/** /**
* If this query was canceled. * If this query was canceled.
...@@ -46,7 +46,7 @@ public abstract class Command implements CommandInterface { ...@@ -46,7 +46,7 @@ public abstract class Command implements CommandInterface {
private boolean canReuse; private boolean canReuse;
public Command(Parser parser, String sql) { Command(Parser parser, String sql) {
this.session = parser.getSession(); this.session = parser.getSession();
this.sql = sql; this.sql = sql;
trace = session.getDatabase().getTrace(Trace.COMMAND); trace = session.getDatabase().getTrace(Trace.COMMAND);
...@@ -127,7 +127,7 @@ public abstract class Command implements CommandInterface { ...@@ -127,7 +127,7 @@ public abstract class Command implements CommandInterface {
* *
* @throws SQLException if the statement has been canceled * @throws SQLException if the statement has been canceled
*/ */
public void checkCanceled() { protected void checkCanceled() {
if (cancel) { if (cancel) {
cancel = false; cancel = false;
throw DbException.get(ErrorCode.STATEMENT_WAS_CANCELED); throw DbException.get(ErrorCode.STATEMENT_WAS_CANCELED);
......
...@@ -16,7 +16,7 @@ import org.h2.value.Value; ...@@ -16,7 +16,7 @@ import org.h2.value.Value;
* Represents a single SQL statements. * Represents a single SQL statements.
* It wraps a prepared statement. * It wraps a prepared statement.
*/ */
public class CommandContainer extends Command { class CommandContainer extends Command {
private Prepared prepared; private Prepared prepared;
......
...@@ -13,12 +13,12 @@ import org.h2.result.ResultInterface; ...@@ -13,12 +13,12 @@ import org.h2.result.ResultInterface;
/** /**
* Represents a list of SQL statements. * Represents a list of SQL statements.
*/ */
public class CommandList extends Command { class CommandList extends Command {
private final Command command; private final Command command;
private final String remaining; private final String remaining;
public CommandList(Parser parser, String sql, Command c, String remaining) { CommandList(Parser parser, String sql, Command c, String remaining) {
super(parser, sql); super(parser, sql);
this.command = c; this.command = c;
this.remaining = remaining; this.remaining = remaining;
......
...@@ -94,7 +94,7 @@ public class Comment extends DbObjectBase { ...@@ -94,7 +94,7 @@ public class Comment extends DbObjectBase {
* @param obj the object * @param obj the object
* @return the key name * @return the key name
*/ */
public static String getKey(DbObject obj) { static String getKey(DbObject obj) {
return getTypeName(obj.getType()) + " " + obj.getSQL(); return getTypeName(obj.getType()) + " " + obj.getSQL();
} }
......
...@@ -284,7 +284,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -284,7 +284,7 @@ public class ConnectionInfo implements Cloneable {
* @param defaultValue the default value * @param defaultValue the default value
* @return the value * @return the value
*/ */
public boolean getProperty(String key, boolean defaultValue) { boolean getProperty(String key, boolean defaultValue) {
String x = getProperty(key, null); String x = getProperty(key, null);
if (x == null) { if (x == null) {
return defaultValue; return defaultValue;
...@@ -403,7 +403,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -403,7 +403,7 @@ public class ConnectionInfo implements Cloneable {
* @param defaultValue the default value * @param defaultValue the default value
* @return the value as a String * @return the value as a String
*/ */
public int getProperty(String key, int defaultValue) { int getProperty(String key, int defaultValue) {
if (SysProperties.CHECK && !isKnownSetting(key)) { if (SysProperties.CHECK && !isKnownSetting(key)) {
DbException.throwInternalError(key); DbException.throwInternalError(key);
} }
......
...@@ -309,7 +309,7 @@ public class Database implements DataHandler { ...@@ -309,7 +309,7 @@ public class Database implements DataHandler {
* @return true if the call was successful, * @return true if the call was successful,
* false if another connection was faster * false if another connection was faster
*/ */
synchronized boolean reconnectModified(boolean pending) { private synchronized boolean reconnectModified(boolean pending) {
if (readOnly || lock == null || fileLockMethod != FileLock.LOCK_SERIALIZED) { if (readOnly || lock == null || fileLockMethod != FileLock.LOCK_SERIALIZED) {
return true; return true;
} }
...@@ -435,7 +435,7 @@ public class Database implements DataHandler { ...@@ -435,7 +435,7 @@ public class Database implements DataHandler {
* @param name the name of the database (including path) * @param name the name of the database (including path)
* @return true if one exists * @return true if one exists
*/ */
public static boolean exists(String name) { static boolean exists(String name) {
return IOUtils.exists(name + Constants.SUFFIX_PAGE_FILE); return IOUtils.exists(name + Constants.SUFFIX_PAGE_FILE);
} }
...@@ -470,7 +470,7 @@ public class Database implements DataHandler { ...@@ -470,7 +470,7 @@ public class Database implements DataHandler {
* @param testHash the hash code * @param testHash the hash code
* @return true if the cipher algorithm and the password match * @return true if the cipher algorithm and the password match
*/ */
public boolean validateFilePasswordHash(String testCipher, byte[] testHash) { boolean validateFilePasswordHash(String testCipher, byte[] testHash) {
if (!StringUtils.equals(testCipher, this.cipher)) { if (!StringUtils.equals(testCipher, this.cipher)) {
return false; return false;
} }
...@@ -919,7 +919,7 @@ public class Database implements DataHandler { ...@@ -919,7 +919,7 @@ public class Database implements DataHandler {
* @return the session * @return the session
* @throws SQLException if the database is in exclusive mode * @throws SQLException if the database is in exclusive mode
*/ */
public synchronized Session createSession(User user) { synchronized Session createSession(User user) {
if (exclusiveSession != null) { if (exclusiveSession != null) {
throw DbException.get(ErrorCode.DATABASE_IS_IN_EXCLUSIVE_MODE); throw DbException.get(ErrorCode.DATABASE_IS_IN_EXCLUSIVE_MODE);
} }
...@@ -1662,7 +1662,7 @@ public class Database implements DataHandler { ...@@ -1662,7 +1662,7 @@ public class Database implements DataHandler {
* @param session the session * @param session the session
* @param transaction the name of the transaction * @param transaction the name of the transaction
*/ */
public void prepareCommit(Session session, String transaction) { void prepareCommit(Session session, String transaction) {
if (readOnly) { if (readOnly) {
return; return;
} }
...@@ -1676,7 +1676,7 @@ public class Database implements DataHandler { ...@@ -1676,7 +1676,7 @@ public class Database implements DataHandler {
* *
* @param session the session * @param session the session
*/ */
public void commit(Session session) { void commit(Session session) {
if (readOnly) { if (readOnly) {
return; return;
} }
...@@ -1921,7 +1921,7 @@ public class Database implements DataHandler { ...@@ -1921,7 +1921,7 @@ public class Database implements DataHandler {
* Called after the database has been opened and initialized. This method * Called after the database has been opened and initialized. This method
* notifies the event listener if one has been set. * notifies the event listener if one has been set.
*/ */
public void opened() { void opened() {
if (eventListener != null) { if (eventListener != null) {
eventListener.opened(); eventListener.opened();
} }
......
...@@ -15,7 +15,7 @@ import org.h2.message.Trace; ...@@ -15,7 +15,7 @@ import org.h2.message.Trace;
* close a connection. A database closer object only exists if there is no user * close a connection. A database closer object only exists if there is no user
* connected to the database. * connected to the database.
*/ */
public class DatabaseCloser extends Thread { class DatabaseCloser extends Thread {
private final boolean shutdownHook; private final boolean shutdownHook;
private final Trace trace; private final Trace trace;
...@@ -34,7 +34,7 @@ public class DatabaseCloser extends Thread { ...@@ -34,7 +34,7 @@ public class DatabaseCloser extends Thread {
* Stop and disable the database closer. This method is called after the * Stop and disable the database closer. This method is called after the
* database has been closed, or after a session has been created. * database has been closed, or after a session has been created.
*/ */
public void reset() { void reset() {
synchronized (this) { synchronized (this) {
databaseRef = null; databaseRef = null;
} }
......
...@@ -229,7 +229,7 @@ public class Engine implements SessionFactory { ...@@ -229,7 +229,7 @@ public class Engine implements SessionFactory {
* *
* @param name the database name * @param name the database name
*/ */
public void close(String name) { void close(String name) {
if (jmx) { if (jmx) {
try { try {
Utils.callStaticMethod("org.h2.jmx.DatabaseInfo.unregisterMBean", name); Utils.callStaticMethod("org.h2.jmx.DatabaseInfo.unregisterMBean", name);
......
...@@ -19,7 +19,7 @@ public class Mode { ...@@ -19,7 +19,7 @@ public class Mode {
/** /**
* The name of the default mode. * The name of the default mode.
*/ */
public static final String REGULAR = "REGULAR"; static final String REGULAR = "REGULAR";
private static final HashMap<String, Mode> MODES = New.hashMap(); private static final HashMap<String, Mode> MODES = New.hashMap();
......
...@@ -100,7 +100,7 @@ public abstract class RightOwner extends DbObjectBase { ...@@ -100,7 +100,7 @@ public abstract class RightOwner extends DbObjectBase {
* *
* @param table the table * @param table the table
*/ */
public void revokeRight(Table table) { void revokeRight(Table table) {
if (grantedRights == null) { if (grantedRights == null) {
return; return;
} }
...@@ -129,7 +129,7 @@ public abstract class RightOwner extends DbObjectBase { ...@@ -129,7 +129,7 @@ public abstract class RightOwner extends DbObjectBase {
* @param role the role to revoke * @param role the role to revoke
* @throws SQLException if the right has not been granted * @throws SQLException if the right has not been granted
*/ */
public void revokeRole(Role role) { void revokeRole(Role role) {
if (grantedRoles == null) { if (grantedRoles == null) {
return; return;
} }
......
...@@ -331,7 +331,7 @@ public class Session extends SessionWithState { ...@@ -331,7 +331,7 @@ public class Session extends SessionWithState {
* *
* @param constraint the constraint * @param constraint the constraint
*/ */
public void removeLocalTempTableConstraint(Constraint constraint) { void removeLocalTempTableConstraint(Constraint constraint) {
if (localTempTableConstraints != null) { if (localTempTableConstraints != null) {
localTempTableConstraints.remove(constraint.getName()); localTempTableConstraints.remove(constraint.getName());
synchronized (database) { synchronized (database) {
...@@ -653,7 +653,7 @@ public class Session extends SessionWithState { ...@@ -653,7 +653,7 @@ public class Session extends SessionWithState {
* *
* @param t the table to unlock * @param t the table to unlock
*/ */
public void unlock(Table t) { void unlock(Table t) {
locks.remove(t); locks.remove(t);
} }
...@@ -746,7 +746,7 @@ public class Session extends SessionWithState { ...@@ -746,7 +746,7 @@ public class Session extends SessionWithState {
* This method is called after the transaction log has written the commit * This method is called after the transaction log has written the commit
* entry for this session. * entry for this session.
*/ */
public void setAllCommitted() { void setAllCommitted() {
firstUncommittedLog = Session.LOG_WRITTEN; firstUncommittedLog = Session.LOG_WRITTEN;
firstUncommittedPos = Session.LOG_WRITTEN; firstUncommittedPos = Session.LOG_WRITTEN;
} }
......
...@@ -11,7 +11,7 @@ import java.sql.SQLException; ...@@ -11,7 +11,7 @@ import java.sql.SQLException;
/** /**
* A class that implements this interface can create new database sessions. * A class that implements this interface can create new database sessions.
*/ */
public interface SessionFactory { interface SessionFactory {
/** /**
* Create a new session. * Create a new session.
......
...@@ -424,7 +424,7 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -424,7 +424,7 @@ public class SessionRemote extends SessionWithState implements DataHandler {
* @param count the retry count index * @param count the retry count index
* @return true if reconnected * @return true if reconnected
*/ */
public boolean autoReconnect(int count) { private boolean autoReconnect(int count) {
if (!isClosed()) { if (!isClosed()) {
return false; return false;
} }
......
...@@ -15,7 +15,7 @@ import org.h2.value.Value; ...@@ -15,7 +15,7 @@ import org.h2.value.Value;
/** /**
* The base class for both remote and embedded sessions. * The base class for both remote and embedded sessions.
*/ */
public abstract class SessionWithState implements SessionInterface { abstract class SessionWithState implements SessionInterface {
protected ArrayList<String> sessionState; protected ArrayList<String> sessionState;
protected boolean sessionStateChanged; protected boolean sessionStateChanged;
......
...@@ -87,7 +87,7 @@ public class SettingsBase { ...@@ -87,7 +87,7 @@ public class SettingsBase {
* @param k the key * @param k the key
* @return true if they do * @return true if they do
*/ */
public boolean containsKey(String k) { protected boolean containsKey(String k) {
return settings.containsKey(k); return settings.containsKey(k);
} }
......
...@@ -35,7 +35,7 @@ public class UndoLog { ...@@ -35,7 +35,7 @@ public class UndoLog {
* *
* @param session the session * @param session the session
*/ */
public UndoLog(Session session) { UndoLog(Session session) {
this.database = session.getDatabase(); this.database = session.getDatabase();
largeTransactions = database.getSettings().largeTransactions; largeTransactions = database.getSettings().largeTransactions;
} }
...@@ -45,7 +45,7 @@ public class UndoLog { ...@@ -45,7 +45,7 @@ public class UndoLog {
* *
* @return the number of rows * @return the number of rows
*/ */
public int size() { int size() {
if (largeTransactions) { if (largeTransactions) {
return storedEntries + records.size(); return storedEntries + records.size();
} }
...@@ -59,7 +59,7 @@ public class UndoLog { ...@@ -59,7 +59,7 @@ public class UndoLog {
* Clear the undo log. This method is called after the transaction is * Clear the undo log. This method is called after the transaction is
* committed. * committed.
*/ */
public void clear() { void clear() {
records.clear(); records.clear();
storedEntries = 0; storedEntries = 0;
storedEntriesPos.clear(); storedEntriesPos.clear();
...@@ -136,7 +136,7 @@ public class UndoLog { ...@@ -136,7 +136,7 @@ public class UndoLog {
* *
* @param trimToSize if the undo array should shrink to conserve memory * @param trimToSize if the undo array should shrink to conserve memory
*/ */
public void removeLast(boolean trimToSize) { void removeLast(boolean trimToSize) {
int i = records.size() - 1; int i = records.size() - 1;
UndoLogRecord r = records.remove(i); UndoLogRecord r = records.remove(i);
if (!r.isStored()) { if (!r.isStored()) {
...@@ -152,7 +152,7 @@ public class UndoLog { ...@@ -152,7 +152,7 @@ public class UndoLog {
* *
* @param entry the entry * @param entry the entry
*/ */
public void add(UndoLogRecord entry) { void add(UndoLogRecord entry) {
records.add(entry); records.add(entry);
if (largeTransactions) { if (largeTransactions) {
memoryUndo++; memoryUndo++;
......
...@@ -44,7 +44,7 @@ public class UndoLogRecord { ...@@ -44,7 +44,7 @@ public class UndoLogRecord {
* @param op the operation type * @param op the operation type
* @param row the row that was deleted or inserted * @param row the row that was deleted or inserted
*/ */
public UndoLogRecord(Table table, short op, Row row) { UndoLogRecord(Table table, short op, Row row) {
this.table = table; this.table = table;
this.row = row; this.row = row;
this.operation = op; this.operation = op;
...@@ -80,7 +80,7 @@ public class UndoLogRecord { ...@@ -80,7 +80,7 @@ public class UndoLogRecord {
* *
* @param session the session * @param session the session
*/ */
public void undo(Session session) { void undo(Session session) {
Database db = session.getDatabase(); Database db = session.getDatabase();
switch (operation) { switch (operation) {
case INSERT: case INSERT:
...@@ -252,7 +252,7 @@ public class UndoLogRecord { ...@@ -252,7 +252,7 @@ public class UndoLogRecord {
* This method is called after the operation was committed. * This method is called after the operation was committed.
* It commits the change to the indexes. * It commits the change to the indexes.
*/ */
public void commit() { void commit() {
table.commit(operation, row); table.commit(operation, row);
} }
......
...@@ -177,7 +177,7 @@ public class User extends RightOwner { ...@@ -177,7 +177,7 @@ public class User extends RightOwner {
* @param userPasswordHash the password data (the user password hash) * @param userPasswordHash the password data (the user password hash)
* @return true if the user password hash is correct * @return true if the user password hash is correct
*/ */
public boolean validateUserPasswordHash(byte[] userPasswordHash) { boolean validateUserPasswordHash(byte[] userPasswordHash) {
if (userPasswordHash.length == 0 && passwordHash.length == 0) { if (userPasswordHash.length == 0 && passwordHash.length == 0) {
return true; return true;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论