votorola.a
Class Geocode

java.lang.Object
  extended by Geocode

public final class Geocode
extends Object

The cached geocoding of a residential address, backed by a row of the subserver's * geocode table. Caching is employed to lighten the load on the geocoding service.


Nested Class Summary
static class Geocode.GeocodingException
          Thrown when a geocoding-specific IO exception occurs.
static class Geocode.GoogleGeocoding
          An account with the geocoding service of the Google Maps API.
static class Geocode.Table
          The geocode table of an electoral subserver, caching geocode data in relational form.
 
Constructor Summary
Geocode(String address, Geocode.Table table)
          Constructs a Geocode, reading its initial state from the geocode table, or leaving it at default values if it does not exist in the table.
 
Method Summary
 String address()
          The residential address that is geocoded.
 void commit(Geocode.Table table)
          Stores this geocode in the table.
 boolean exists()
          Returns true if this geocode has been stored in the table; false otherwise.
 double latitude()
          The latitude of the address, in radians.
 double longitude()
          The longitude of the address, in radians.
 void setCoordinates(Double newLatitude, Double newLongitude)
          Sets the latitude and longitude.
 long timestamp()
          The time at which this geocode was last stored to the table, in milliseconds since the 'epoch'; or zero, if it was never stored.
 String toString()
          Returns a descripion of this geocode, including the address and its geographic coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Geocode

public Geocode(String address,
               Geocode.Table table)
        throws SQLException
Constructs a Geocode, reading its initial state from the geocode table, or leaving it at default values if it does not exist in the table.

Parameters:
address - per address()
table - the subserver's geocode table
Throws:
SQLException
See Also:
exists()
Method Detail

address

public String address()
The residential address that is geocoded. The exact format depends on the geocoding service.


commit

public void commit(Geocode.Table table)
            throws SQLException
Stores this geocode in the table.

Parameters:
table - the subserver's geocode table
Throws:
SQLException

exists

public boolean exists()
Returns true if this geocode has been stored in the table; false otherwise.


latitude

public double latitude()
The latitude of the address, in radians.

See Also:
setCoordinates(Double,Double)

longitude

public double longitude()
The longitude of the address, in radians.

See Also:
setCoordinates(Double,Double)

setCoordinates

public void setCoordinates(Double newLatitude,
                           Double newLongitude)
Sets the latitude and longitude.

See Also:
latitude(), longitude()

timestamp

public final long timestamp()
The time at which this geocode was last stored to the table, in milliseconds since the 'epoch'; or zero, if it was never stored. This is intended to implement a rolling turn-over of the cache, keeping it refeshed with relatively recent values (say no older than five years) from the geocoding service - but that has not been implemented yet.

See Also:
System.currentTimeMillis()

toString

public String toString()
Returns a descripion of this geocode, including the address and its geographic coordinates.

Overrides:
toString in class Object