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
|
getNbLines, isLogEntry, readLine
protected 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
OffsetReader
getOffset
in class OffsetReader
position
- position of the lineIOException
- todopublic void open(LineReader reader) throws IOException
OffsetReader
open
in class OffsetReader
reader
- LineReader linked with this readerIOException
- if any problem while openingpublic void close() throws IOException
OffsetReader
close
in class OffsetReader
IOException
- if any problem while closingpublic void update(LineReader lineReader) throws IOException
OffsetReader
update
in class OffsetReader
lineReader
- lineReader linked with this readerIOException
- if any problem while updatingpublic void deleteOffsetFile()
OffsetReader
deleteOffsetFile
in class OffsetReader
protected void storeOffset(long position, long offset) throws IOException
OffsetReader
storeOffset
in class OffsetReader
position
- current line positionoffset
- current offset of lineIOException
- if any problem while storingprotected boolean needCreate() throws IOException
needCreate
in class OffsetReader
true
if the reader need to create his internal
datas.IOException
- if any problme while creatingprotected long createOffsets(LineReader lineReader) throws IOException
createOffsets
in class OffsetReader
IOException
protected long createOffsets(LineReader lineReader, LineReader parent) throws IOException
createOffsets
in class OffsetReader
IOException
Copyright © 1999–2020 CodeLutin. All rights reserved.