fr.ifremer.isisfish.logging.io
Class MemoryOffsetReader

java.lang.Object
  extended by fr.ifremer.isisfish.logging.io.OffsetReader
      extended by fr.ifremer.isisfish.logging.io.MemoryOffsetReader

public class MemoryOffsetReader
extends OffsetReader

This class is a Offset Reader using a memory cache.

All offsets are saved in memory.

Author:
chemit

Field Summary
protected  int capacity
          capacity of cache
protected static org.apache.commons.logging.Log log
           
protected  java.util.Map<java.lang.Long,java.lang.Long> offsetCache
          cache of offsets
 
Fields inherited from class fr.ifremer.isisfish.logging.io.OffsetReader
nbLines
 
Constructor Summary
MemoryOffsetReader(int capacity)
           
 
Method Summary
 void close()
          Close the reader
 long getOffset(long position)
          Obtain an offset for a position
protected  boolean needCreate()
           
protected  void storeOffset(long position, long offset)
          Save the offset of the line for a given position
 java.lang.String toString()
           
 
Methods inherited from class fr.ifremer.isisfish.logging.io.OffsetReader
createOffsets, createOffsets, createOffsetsForLog, deleteOffsetFile, getNbLines, isLogEntry, open, readLine, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log

offsetCache

protected java.util.Map<java.lang.Long,java.lang.Long> offsetCache
cache of offsets


capacity

protected int capacity
capacity of cache

Constructor Detail

MemoryOffsetReader

public MemoryOffsetReader(int capacity)
Method Detail

close

public void close()
           throws java.io.IOException
Description copied from class: OffsetReader
Close the reader

Overrides:
close in class OffsetReader
Throws:
java.io.IOException - if any problem while closing

getOffset

public long getOffset(long position)
Description copied from class: OffsetReader
Obtain an offset for a position

Specified by:
getOffset in class OffsetReader
Parameters:
position - position of the line
Returns:
the offset of the first car of the given line

storeOffset

protected void storeOffset(long position,
                           long offset)
Description copied from class: OffsetReader
Save the offset of the line for a given position

Specified by:
storeOffset in class OffsetReader
Parameters:
position - current line position
offset - current offset of line

needCreate

protected boolean needCreate()
Specified by:
needCreate in class OffsetReader
Returns:
true if the reader need to create his internal datas.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 1999-2010 CodeLutin. All Rights Reserved.