org.placelab.mapper
Interface Mapper

All Known Implementing Classes:
AbstractMapper, SimpleMapper

public interface Mapper

Mappers find the Beacon object associated with a given id. If a beacon is not known, the findBeacon() method will return null.

Mappers typically represent the on-disk cache of Beacons in keeping with the placelab philosophy of off-line location computation.

See Also:
BeaconTracker

Method Summary
 boolean close()
          Closes the Mapper.
 Beacon createBeacon(java.lang.String keyValuePairs)
          Implementation dependent method to unpack a Beacon from the Mapper
 boolean deleteAll()
          Deletes all Beacon records in the Mapper.
 void endBulkPuts()
           
 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.
 boolean isOpened()
           
 boolean open()
          Opens the Mapper.
 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
 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.
 void startBulkPuts()
          Signals to the Mapper that it is about to be loaded in bulk.
 

Method Detail

open

public boolean open()
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()
Closes the Mapper. Closed Mappers can no longer be queried.

Returns:
whether or not the Mapper was successfully closed.

deleteAll

public boolean deleteAll()
Deletes all Beacon records in the Mapper. This is typically used by MapLoaders prior to reloading the Mapper with data.

Returns:
whether or not the Mapper was successfully emptied.

isOpened

public boolean isOpened()

findBeacon

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

Parameters:
id - the unique identifier for the Beacon

findBeacons

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

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.

query

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


createBeacon

public Beacon createBeacon(java.lang.String keyValuePairs)
Implementation dependent method to unpack a Beacon from the Mapper


putBeacon

public boolean putBeacon(java.lang.String id,
                         Beacon beacon)
Load a new single Beacon into the 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)
Put a Vector of Beacons for one unique id into the Mapper

Parameters:
id - the unique id to key the Beacons to
beacons - the Beacons to add
Returns:
whether or not the put succeeded

startBulkPuts

public void startBulkPuts()
Signals to the Mapper that it is about to be loaded in bulk. Some implementations can use this to lock their underlying database and speed up loading. You should not query the Mapper while using bulk loading.

See Also:
endBulkPuts()

endBulkPuts

public void endBulkPuts()

overrideOnPut

public boolean overrideOnPut()