public class FileOffsetReader extends OffsetReader
OffsetReader using a file for
dealing with offsets.
The offset of lines are pre-computed in a file offsetFile, generated
by createOffsets(LineReader). or
createOffsets(LineReader , LineReader).| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.commons.logging.Log |
log |
protected File |
offsetFile
offset file to read
|
protected RandomAccessFile |
offsetReader
offset file reader
|
protected RandomAccessFile |
writer
writer used while creation or update
|
nbLines| Constructor and Description |
|---|
FileOffsetReader(File file) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the reader
|
protected long |
createOffsets(LineReader lineReader) |
protected long |
createOffsets(LineReader lineReader,
LineReader parent) |
void |
deleteOffsetFile()
delete offset resources
|
long |
getOffset(long position)
Obtain an offset for a position
|
protected boolean |
needCreate() |
void |
open(LineReader reader)
Open the reader
|
protected void |
storeOffset(long position,
long offset)
Save the offset of the line for a given position
|
String |
toString() |
void |
update(LineReader lineReader)
Update the reader
|
createOffsetsForLog, getNbLines, isLogEntry, readLineprotected static final org.apache.commons.logging.Log log
protected File offsetFile
protected RandomAccessFile offsetReader
protected RandomAccessFile writer
public FileOffsetReader(File file)
public long getOffset(long position)
throws IOException
OffsetReadergetOffset in class OffsetReaderposition - position of the lineIOException - todopublic void open(LineReader reader) throws IOException
OffsetReaderopen in class OffsetReaderreader - LineReader linked with this readerIOException - if any problem while openingpublic void close()
throws IOException
OffsetReaderclose in class OffsetReaderIOException - if any problem while closingpublic void update(LineReader lineReader) throws IOException
OffsetReaderupdate in class OffsetReaderlineReader - lineReader linked with this readerIOException - if any problem while updatingpublic void deleteOffsetFile()
OffsetReaderdeleteOffsetFile in class OffsetReaderprotected void storeOffset(long position,
long offset)
throws IOException
OffsetReaderstoreOffset in class OffsetReaderposition - current line positionoffset - current offset of lineIOException - if any problem while storingprotected boolean needCreate()
throws IOException
needCreate in class OffsetReadertrue if the reader need to create his internal
datas.IOException - if any problme while creatingprotected long createOffsets(LineReader lineReader) throws IOException
createOffsets in class OffsetReaderIOExceptionprotected long createOffsets(LineReader lineReader, LineReader parent) throws IOException
createOffsets in class OffsetReaderIOExceptionCopyright © 1999-2012 CodeLutin. All Rights Reserved.