01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: TestUtilLogReader.java,v 1.6.2.2 2008/01/07 15:14:29 cwl Exp $
07: */
08:
09: package com.sleepycat.je.log;
10:
11: import java.io.IOException;
12: import java.nio.ByteBuffer;
13:
14: import com.sleepycat.je.DatabaseException;
15: import com.sleepycat.je.dbi.EnvironmentImpl;
16: import com.sleepycat.je.log.entry.LogEntry;
17: import com.sleepycat.je.utilint.DbLsn;
18:
19: /**
20: * Instantiates all log entries using the shared log entry instances.
21: */
22: public class TestUtilLogReader extends FileReader {
23:
24: private LogEntryType entryType;
25: private LogEntry entry;
26:
27: public TestUtilLogReader(EnvironmentImpl env) throws IOException,
28: DatabaseException {
29:
30: super (env, 4096, true, DbLsn.NULL_LSN, null, DbLsn.NULL_LSN,
31: DbLsn.NULL_LSN);
32: }
33:
34: public TestUtilLogReader(EnvironmentImpl env, int readBufferSize,
35: boolean forward, long startLsn, Long singleFileNumber,
36: long endOfFileLsn, long finishLsn) throws IOException,
37: DatabaseException {
38:
39: super (env, readBufferSize, forward, startLsn, singleFileNumber,
40: endOfFileLsn, finishLsn);
41: }
42:
43: public LogEntryType getEntryType() {
44: return entryType;
45: }
46:
47: public LogEntry getEntry() {
48: return entry;
49: }
50:
51: protected boolean isTargetEntry(byte logEntryTypeNumber,
52: byte logEntryTypeVersion) {
53: return true;
54: }
55:
56: protected boolean processEntry(ByteBuffer entryBuffer)
57: throws DatabaseException {
58:
59: entryType = LogEntryType.findType(currentEntryHeader.getType(),
60: currentEntryHeader.getVersion());
61: entry = entryType.getSharedLogEntry();
62: entry.readEntry(currentEntryHeader, entryBuffer, true); // readFullItem
63: return true;
64: }
65: }
|