org.placelab.mapper
Class JDBMMapper

java.lang.Object
  extended byorg.placelab.mapper.AbstractMapper
      extended byorg.placelab.mapper.JDBMMapper
All Implemented Interfaces:
Mapper

public class JDBMMapper
extends AbstractMapper

This class uses a persistent cache of known beacons to fill in the beacon fields of BeaconMeasurements.


Field Summary
 
Fields inherited from class org.placelab.mapper.AbstractMapper
UNKNOWN_BEACON_CLASS
 
Constructor Summary
JDBMMapper()
          Create a JDBMMapper using the default database name
JDBMMapper(boolean shouldCache)
           
JDBMMapper(java.lang.String dbName)
           
JDBMMapper(java.lang.String dbName, boolean shouldCache)
           
 
Method Summary
 boolean close()
          Closes the Mapper.
 boolean deleteAll()
          Use this with caution, it wipes out the persistent map.
 void endBulkPuts()
           
protected  java.util.Vector findBeaconsImpl(java.lang.String uniqueId)
          Look to see if the reading's measurement is for a known AP.
 java.lang.String getDbName()
           
 boolean isOpened()
           
 java.util.Enumeration iterator()
           
 boolean open()
          Opens the Mapper.
protected  boolean putBeaconsImpl(java.lang.String id, java.util.Vector beacons)
          add a new Vector of beacons to the map.
 java.util.Enumeration query(Coordinate c1, Coordinate c2)
          c1 and c2 define opposing corners of a rectangular area in which you wish to get an Iterator over all Beacons in that area.
 int size()
          returns the number of Beacons in the map
 void startBulkPuts()
          makes addition go much faster, use this for bulk loading
 
Methods inherited from class org.placelab.mapper.AbstractMapper
addBeaconClass, addBeaconClass, createBeacon, findBeacon, findBeacons, getBeaconsFromStorageString, overrideOnPut, putBeacon, putBeacons
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBMMapper

public JDBMMapper()
           throws java.io.IOException
Create a JDBMMapper using the default database name


JDBMMapper

public JDBMMapper(boolean shouldCache)
           throws java.io.IOException

JDBMMapper

public JDBMMapper(java.lang.String dbName)
           throws java.io.IOException

JDBMMapper

public JDBMMapper(java.lang.String dbName,
                  boolean shouldCache)
           throws java.io.IOException
Method Detail

isOpened

public boolean isOpened()

open

public boolean open()
Description copied from interface: Mapper
Opens the Mapper. You must call this method before querying the mapper.

Returns:
whether or not the Mapper was successfully opened.

close

public boolean close()
Description copied from interface: Mapper
Closes the Mapper. Closed Mappers can no longer be queried.

Returns:
whether or not the Mapper was successfully closed.

findBeaconsImpl

protected java.util.Vector findBeaconsImpl(java.lang.String uniqueId)
Look to see if the reading's measurement is for a known AP. If so return it, otherwise it returns UNKNOWN_BEACON

Specified by:
findBeaconsImpl in class AbstractMapper

startBulkPuts

public void startBulkPuts()
makes addition go much faster, use this for bulk loading

See Also:
Mapper.endBulkPuts()

endBulkPuts

public void endBulkPuts()

size

public int size()
returns the number of Beacons in the map


deleteAll

public boolean deleteAll()
Use this with caution, it wipes out the persistent map.

Returns:
whether or not the Mapper was successfully emptied.

putBeaconsImpl

protected boolean putBeaconsImpl(java.lang.String id,
                                 java.util.Vector beacons)
add a new Vector of beacons to the map. Returns true on success

Specified by:
putBeaconsImpl in class AbstractMapper

iterator

public java.util.Enumeration iterator()

query

public java.util.Enumeration query(Coordinate c1,
                                   Coordinate c2)
Description copied from interface: Mapper
c1 and c2 define opposing corners of a rectangular area in which you wish to get an Iterator over all Beacons in that area.

Specified by:
query in interface Mapper
Specified by:
query in class AbstractMapper

getDbName

public java.lang.String getDbName()