KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > log > TestUtilLogReader


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: TestUtilLogReader.java,v 1.5 2006/10/30 21:14:47 bostic Exp $
7  */

8
9 package com.sleepycat.je.log;
10
11 import java.io.IOException JavaDoc;
12 import java.nio.ByteBuffer JavaDoc;
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)
28     throws IOException JavaDoc, DatabaseException {
29
30         super(env,
31               4096,
32               true,
33               DbLsn.NULL_LSN,
34               null,
35               DbLsn.NULL_LSN,
36               DbLsn.NULL_LSN);
37     }
38
39     public TestUtilLogReader(EnvironmentImpl env,
40                              int readBufferSize,
41                              boolean forward,
42                              long startLsn,
43                              Long JavaDoc singleFileNumber,
44                              long endOfFileLsn,
45                              long finishLsn)
46     throws IOException JavaDoc, DatabaseException {
47
48         super(env,
49               readBufferSize,
50               forward,
51               startLsn,
52               singleFileNumber,
53               endOfFileLsn,
54               finishLsn);
55     }
56
57     public LogEntryType getEntryType() {
58         return entryType;
59     }
60
61     public LogEntry getEntry() {
62         return entry;
63     }
64
65     protected boolean isTargetEntry(byte logEntryTypeNumber,
66                                     byte logEntryTypeVersion) {
67         return true;
68     }
69
70     protected boolean processEntry(ByteBuffer JavaDoc entryBuffer)
71         throws DatabaseException {
72
73         entryType = LogEntryType.findType
74             (currentEntryTypeNum, currentEntryTypeVersion);
75     entry = entryType.getSharedLogEntry();
76         entry.readEntry
77             (entryBuffer, currentEntrySize, currentEntryTypeVersion, true);
78         return true;
79     }
80 }
81
Popular Tags