ps6
Class StreetSegReader

java.lang.Object
  extended by ps6.StreetSegReader

public class StreetSegReader
extends Object

A StreetSegReader reads StreetSegments from a set of Tiger Databases.

Tiger Databases are produced and maintained by the U.S. Census Bureau.

Tiger Databases are distributed in zip-compressed files. To allow for the loading of an arbitrary number of these databases, one creates each StreetSegReader with a source directory argument, which will then be searched for Tiger Database files when streetSegments() is called. The subdirectories of the argument directory are not searched recursively for Tiger files as well; only the immediate contents of this.sourceDirectory will be considered as potential Tiger files.

StreetSegReader is only specified to operate correctly with directories that contain no .zip files besides the Tiger Databases. Files with other extensions (such as .pdf) will not affect the operation of StreetSegReader, but no other .zip files should be kept in the source directory for a StreetSegReader.

Specification Fields

Nested Class Summary
static class StreetSegReader.InvalidSourceException
          Exception indicating that the requested source for a tiger database is invalid
 
Constructor Summary
StreetSegReader(String sourceDirectory)
           
 
Method Summary
 Iterator<StreetSegment> iterator()
          Returns an Iterator over this.streetSegs.
 Iterator<StreetSegment> streetSegments()
          Returns an Iterator over this.streetSegs.
protected  StreetSegIterator streetSegmentsInternal()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreetSegReader

public StreetSegReader(String sourceDirectory)
                throws StreetSegReader.InvalidSourceException
Throws:
StreetSegReader.InvalidSourceException - if sourceDirectory is not valid database (most directories, even empty ones, count as valid).
Effects:
Constructs a StreetSegReader where sourceDirectory contains the Tiger Database files.
Method Detail

iterator

public Iterator<StreetSegment> iterator()
Returns an Iterator over this.streetSegs.

Throws:
Error - if IO error while reading the directory
Returns:
an iterator that produces the contents of this.streetSegs. Each element produced by the Iterator is a StreetSegment.

streetSegmentsInternal

protected StreetSegIterator streetSegmentsInternal()
Throws:
Error - if IO error while reading the directory

streetSegments

public Iterator<StreetSegment> streetSegments()
Returns an Iterator over this.streetSegs.

Throws:
Error - if IO error while reading the directory
Returns:
an iterator that produces the contents of this.streetSegs. Each element produced by the Iterator is a StreetSegment.