org.ahmadsoft.postal
Class InMemoryStrategy

java.lang.Object
  extended by org.ahmadsoft.postal.InMemoryStrategy
All Implemented Interfaces:
PostalRetrievalStrategy

public class InMemoryStrategy
extends java.lang.Object
implements PostalRetrievalStrategy

A retrieval strategy that loads the entire file into memory. This strategy may be acceptable if you are running this library as a service (e.g. a servlet-based HTTP service). It occupies roughly 23 megabytes of RAM under Windows XP running Java 5.

Author:
Amin Ahmad

Constructor Summary
InMemoryStrategy()
           
 
Method Summary
 void dispose()
           
 java.util.List getCandidates(int postalCode)
          Retrieves a list of candidate cities for a specified postal code.
 void initialize(java.io.File indexFile, java.io.File dataFile)
          Initializes the retrieval strategy with the postal code index and data files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InMemoryStrategy

public InMemoryStrategy()
Method Detail

initialize

public void initialize(java.io.File indexFile,
                       java.io.File dataFile)
                throws java.lang.Exception
Description copied from interface: PostalRetrievalStrategy
Initializes the retrieval strategy with the postal code index and data files.

Specified by:
initialize in interface PostalRetrievalStrategy
Throws:
java.lang.Exception

getCandidates

public java.util.List getCandidates(int postalCode)
Description copied from interface: PostalRetrievalStrategy
Retrieves a list of candidate cities for a specified postal code.

Specified by:
getCandidates in interface PostalRetrievalStrategy
Parameters:
postalCode - the postal code.
Returns:
a list of candidate cities.

dispose

public void dispose()
             throws java.lang.Exception
Specified by:
dispose in interface PostalRetrievalStrategy
Throws:
java.lang.Exception


Copyright © 2006-2009 Ahmadsoft. All Rights Reserved.