org.placelab.mapper
Class AbstractMapper

java.lang.Object
  extended byorg.placelab.mapper.AbstractMapper
All Implemented Interfaces:
Mapper
Direct Known Subclasses:
JDBCMapper, JDBMMapper, RMSMapper, TempMapper, WigleMapper

public abstract class AbstractMapper
extends java.lang.Object
implements Mapper

Provides convenience methods for packing and unpacking Beacons in a Mapper, for caching Beacons in memory when they are used, and for storing Beacons of multiple types. Only Mapper implementers should be concerned with this class.


Field Summary
static java.lang.Class UNKNOWN_BEACON_CLASS
           
 
Constructor Summary
AbstractMapper(boolean shouldCache)
           
 
Method Summary
 void addBeaconClass(Beacon beacon)
           
 void addBeaconClass(java.lang.String type, java.lang.String className)
           
 Beacon createBeacon(java.lang.String storageString)
          Implementation dependent method to unpack a Beacon from the Mapper
 Beacon findBeacon(java.lang.String id)
          Returns the first Beacon found that has a matching id, or null if no Beacon is returned.
 java.util.Vector findBeacons(java.lang.String id)
          Find all Beacons in the Mapper that match the given id.
protected abstract  java.util.Vector findBeaconsImpl(java.lang.String id)
           
protected  java.util.Vector getBeaconsFromStorageString(java.lang.String storage)
          Unpacks a Vector of Beacons using Mapper.createBeacon(String) stored separated by newlines.
 boolean overrideOnPut()
           
 boolean putBeacon(java.lang.String id, Beacon beacon)
          Load a new single Beacon into the Mapper
 boolean putBeacons(java.lang.String id, java.util.Vector beacons)
          Put a Vector of Beacons for one unique id into the Mapper
protected abstract  boolean putBeaconsImpl(java.lang.String id, java.util.Vector beacons)
           
abstract  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.placelab.mapper.Mapper
close, deleteAll, endBulkPuts, isOpened, open, startBulkPuts
 

Field Detail

UNKNOWN_BEACON_CLASS

public static java.lang.Class UNKNOWN_BEACON_CLASS
Constructor Detail

AbstractMapper

public AbstractMapper(boolean shouldCache)
Method Detail

addBeaconClass

public void addBeaconClass(java.lang.String type,
                           java.lang.String className)

addBeaconClass

public void addBeaconClass(Beacon beacon)

findBeacon

public Beacon findBeacon(java.lang.String id)
Description copied from interface: Mapper
Returns the first Beacon found that has a matching id, or null if no Beacon is returned.

Specified by:
findBeacon in interface Mapper
Parameters:
id - the unique identifier for the Beacon

findBeacons

public java.util.Vector findBeacons(java.lang.String id)
Description copied from interface: Mapper
Find all Beacons in the Mapper that match the given id.

Specified by:
findBeacons in interface Mapper
Parameters:
id - the unique identifier for the Beacon
Returns:
a Vector of all Beacons matching the id in the Mapper that may be empty if no Beacons match.

putBeacon

public boolean putBeacon(java.lang.String id,
                         Beacon beacon)
Description copied from interface: Mapper
Load a new single Beacon into the Mapper

Specified by:
putBeacon in interface Mapper
Parameters:
id - the unique id for the Beacon
beacon - a new Beacon to be put into the Mapper
Returns:
whether or not the Beacon was successfully added

putBeacons

public boolean putBeacons(java.lang.String id,
                          java.util.Vector beacons)
Description copied from interface: Mapper
Put a Vector of Beacons for one unique id into the Mapper

Specified by:
putBeacons in interface Mapper
Parameters:
id - the unique id to key the Beacons to
beacons - the Beacons to add
Returns:
whether or not the put succeeded

createBeacon

public Beacon createBeacon(java.lang.String storageString)
Description copied from interface: Mapper
Implementation dependent method to unpack a Beacon from the Mapper

Specified by:
createBeacon in interface Mapper

getBeaconsFromStorageString

protected java.util.Vector getBeaconsFromStorageString(java.lang.String storage)
Unpacks a Vector of Beacons using Mapper.createBeacon(String) stored separated by newlines.


query

public abstract 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

findBeaconsImpl

protected abstract java.util.Vector findBeaconsImpl(java.lang.String id)

putBeaconsImpl

protected abstract boolean putBeaconsImpl(java.lang.String id,
                                          java.util.Vector beacons)

overrideOnPut

public boolean overrideOnPut()
Specified by:
overrideOnPut in interface Mapper