package ws.gazebo.util.region.state;

import java.util.ArrayList;
import java.util.HashMap;

public class StateInfoTable {
	/**
	 * 
	 */
	@SuppressWarnings("unused")
	private static final long serialVersionUID = -1L;

	// 57 entries in the Census ANSI state info table
	ArrayList<StateInfo> table = new ArrayList<StateInfo>(57);
	HashMap<Byte, StateInfo> fips52map = new HashMap<Byte, StateInfo>(57);

	/**
	 * Method for initializing a StateInfo instance based on <a
	 * href="http://www.census.gov/geo/reference/ansi_statetables.html">ANSI
	 * state table data</a> from the US Department of Census. This method
	 * ensures that the instance will be added to all internal indices in the
	 * table.
	 * 
	 * @return new StateInfo instance
	 */
	public StateInfo addStateInfo(String[] fields) {
		StateInfo info = new StateInfo(fields);
		table.add(info);
		byte fips52code = info.getStateNumericANSICode();
		fips52map.put(fips52code, info);
		return info;
	}

	/**
	 * Return the {@link StateInfo} instance denoted uniquely with the
	 * {@code fips52code} as per INCITS 38:200x (previously FIPS 5-2)
	 * 
	 * @param fips52code
	 * @return StateInfo instance
	 */
	public StateInfo getStateInfo(byte fips52code) {
		return fips52map.get(fips52code);
	}
	
}

@@ -217,80 +217,378 @@
 ;%0A%0A%09
-// 57 entries in the Census ANSI state info t
+ArrayList%3CStateInfo%3E table;%0A%09HashMap%3CByte, StateInfo%3E fips52map;%0A%0A%09/**%0A%09 * Initialize table for 57 expected entries.%0A%09 * %0A%09 * @see %3Ca%0A%09 *      href=%22http://www.census.gov/geo/reference/ansi_statetables.html%22%3EANSI%0A%09 *      state table data%3C/a%3E, US Department of Census.%0A%09 */%0A%09public StateInfoT
 able
-%0A%09ArrayList%3CStateInfo%3E 
+() %7B%0A%09%09this(57);%0A%09%7D%0A%0A%09public StateInfoTable(int expectedEntriesCount) %7B%0A%09%09
 tabl
@@ -620,39 +620,33 @@
 fo%3E(
-57);%0A%09HashMap%3CByte, StateInfo%3E 
+expectedEntriesCount);%0A%09%09
 fips
@@ -682,20 +682,41 @@
 teInfo%3E(
-57);
+expectedEntriesCount);%0A%09%7D
 %0A%0A%09/**%0A%09
@@ -967,16 +967,30 @@
 dded to 
+the table and 
 all inte
@@ -993,16 +993,20 @@
 internal
+%0A%09 *
  indices
@@ -1012,20 +1012,16 @@
 s in the
-%0A%09 *
  table.%0A
@@ -1377,16 +1377,22 @@
 s52code%7D
+ value
  as per 
@@ -1455,16 +1455,72 @@
 s52code%0A
+%09 *            the INCITS 38:200x code for the instance%0A
 %09 * @ret
@@ -1523,16 +1523,23 @@
 @return 
+%7B@link 
 StateInf
@@ -1531,32 +1531,33 @@
 %7B@link StateInfo
+%7D
  instance%0A%09 */%0A%09
@@ -1644,12 +1644,11 @@
 de);%0A%09%7D%0A
-%09
 %0A%7D%0A

add constructors; prettify comments