net.sf.mybatchfwk.history
Class KeysFileIndexer

java.lang.Object
  extended by net.sf.mybatchfwk.history.KeysFileIndexer

public class KeysFileIndexer
extends java.lang.Object

The KeysFileIndexer classe is used in order to index keys contained into a file (one line = one key).
This indexer (based on the HashMap class) store into the memory only the hash key and the line number of each key (so it can be used to work with a large number of keys).

Author:
Jérôme Bertèche (cyberteche@users.sourceforge.net)

Constructor Summary
KeysFileIndexer(java.io.File keysFile, java.lang.String mode)
          Constructs an empty KeysFileIndexer with the default initial capacity (16) and the default load factor (0.75).
 
Method Summary
 void addKey(java.lang.String key)
          Add a new key to the end of the file
protected  void buildIndex()
          Index the keys of the file
 void closeReader()
          Close the keys reader
 boolean containsKey(java.lang.String key)
          Returns true if this map contains a mapping for the specified key.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
protected  void putKey(long pointer, java.lang.String key)
          Add a new entry from the given key
 int size()
          Returns the number of key-value mappings in this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeysFileIndexer

public KeysFileIndexer(java.io.File keysFile,
                       java.lang.String mode)
                throws java.io.IOException
Constructs an empty KeysFileIndexer with the default initial capacity (16) and the default load factor (0.75).

Throws:
java.io.IOException
Method Detail

buildIndex

protected void buildIndex()
                   throws java.io.IOException
Index the keys of the file

Throws:
java.io.IOException

closeReader

public void closeReader()
                 throws java.io.IOException
Close the keys reader

Throws:
java.io.IOException

size

public int size()
Returns the number of key-value mappings in this map.

Returns:
the number of key-value mappings in this map.

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.

Returns:
true if this map contains no key-value mappings.

addKey

public void addKey(java.lang.String key)
            throws java.io.IOException
Add a new key to the end of the file

Parameters:
key -
Throws:
java.io.IOException

putKey

protected void putKey(long pointer,
                      java.lang.String key)
Add a new entry from the given key

Parameters:
pointer -
key -

containsKey

public boolean containsKey(java.lang.String key)
                    throws java.io.IOException
Returns true if this map contains a mapping for the specified key.

Parameters:
key - The key whose presence in this map is to be tested
Returns:
true if this map contains a mapping for the specified key.
Throws:
java.io.IOException


Copyright © 2006 null. All Rights Reserved.