import java.util.*;
import java.io.*;

public class Batch
{
    public static char DELIMITER = ':';
    public static char SPACE = ' ';

    public static Vector<Passwport> loadData (String inputFile, boolean debug)
    {
        /*
         * Open the data file and read it in.
         */

        BufferedReader reader = null;
        Vector<Passport> results = new Vector<Passport>();

        try
        {
            String line = null;

            reader = new BufferedReader(new FileReader(inputFile));

            while ((line = reader.readLine()) != null)
            {
                if (line.length() > 0) // blank?
                {
                    int byr = 0;
                    int iry = 0;
                    int eyr = 0;
                    int hgt = 0;
                    String hcl = "";
                    String ecl = "";
                    int pid = 0;
                    int cid = 0;

                    int rangeDelimiter = line.indexOf(RANGE_DELIMITER);
                    int space = line.indexOf(SPACE);
                    String minimum = line.substring(0, rangeDelimiter);
                    String maximum = line.substring(rangeDelimiter +1, space);
                    int passwordDelimiter = line.indexOf(PASSWORD_DELIMITER);
                    String letter = line.substring(space +1, passwordDelimiter);
                    String password = line.substring(passwordDelimiter +1).trim();

                    if (debug)
                    {
                        System.out.println("\nLoaded < "+minimum+", "+maximum+" >");
                        System.out.println("Letter: "+letter);
                        System.out.println("Password to check: "+password);
                    }

                    PasswordPolicy policy = new PasswordPolicy(Integer.parseInt(minimum), Integer.parseInt(maximum), letter.charAt(0));

                    results.add(new PasswordData(policy, password));
                }
            }
        }
        catch (Throwable ex)
        {
            ex.printStackTrace();
        }
        finally
        {
            try
            {
                reader.close();
            }
            catch (Throwable ex)
            {
            }
        }

        return results;
    }

    private Batch ()
    {
    }
}
@@ -568,32 +568,78 @@
 )%0A            %7B%0A
+                Passport p = new Passport();%0A%0A
                 
@@ -713,20 +713,45 @@
     
-int byr = 0;
+String%5B%5D tuples = line.split(SPACE);%0A
 %0A   
@@ -771,193 +771,387 @@
     
+for (
 int i
-ry
  = 0;
-%0A                    int eyr = 0;%0A                    int hgt = 0;%0A                    String hcl = %22%22;%0A                    String ecl = %22%22;%0A                    int pid = 0;
+ i %3C tuples.length; i++)%0A                    %7B%0A                        String%5B%5D pairs = tuples%5Bi%5D.split(DELIMITER);%0A%0A                        if (pairs.length != 2)%0A                            System.out.println(%22Error - more than two in the pairs field! %22+pairs);%0A                        else%0A                        %7B%0A                            switch (pairs%5B0%5D)
 %0A   
@@ -1171,21 +1171,17 @@
     
-int cid = 0;%0A
+        %7B
 %0A   
@@ -1201,264 +1201,501 @@
     
-int rangeDelimiter = line.indexOf(RANGE_DELIMITER);%0A                    int space = line.indexOf(SPACE);%0A                    String minimum = line.substring(0, rangeDelimiter);%0A                    String maximum = line.substring(rangeDelimiter +1, space);%0A
+            case PassportFields.BIRTH_YEAR:%0A                                %7B%0A                                    p.setBirthYear(Integer.parseInt(pairs%5B1%5D));%0A                                %7D%0A                                break;%0A                                case PassportFields.ISSUE_YEAR:%0A                                %7B%0A                                    p.setIssueYear(Integer.parseInt(pairs%5B1%5D));%0A                                %7D%0A                                break;%0A           
     
@@ -1714,231 +1714,421 @@
     
-int passwordDelimiter = line.indexOf(PASSWORD_DELIMITER);%0A                    String letter = line.substring(space +1, passwordDelimiter);%0A                    String password = line.substring(passwordDelimiter +1).trim();%0A%0A
+ case PassportFields.EXPORATION_YEAR:%0A                                %7B%0A                                    p.setExpirationYear(Integer.parseInt(pairs%5B1%5D));%0A                                %7D%0A                                break;%0A                                case PassportFields.HEIGHT:%0A                                %7B%0A                                    p.setHeight(Integer.parseInt(pairs%5B1%5D));%0A            
     
@@ -2147,18 +2147,9 @@
     
-if (debug)
+%7D
 %0A   
@@ -2157,33 +2157,50 @@
                 
-%7B
+            break;
 %0A               
@@ -2212,454 +2212,1422 @@
     
-System.out.println(%22%5CnLoaded %3C %22+minimum+%22, %22+maximum+%22 %3E%22);%0A                        System.out.println(%22Letter: %22+letter);%0A                        System.out.println(%22Password to check: %22+password);%0A                    %7D%0A%0A                    PasswordPolicy policy = new PasswordPolicy(Integer.parseInt(minimum), Integer.parseInt(maximum), letter.charAt(0));%0A%0A                    results.add(new PasswordData(policy, password));%0A                %7D
+        case PassportFields.HAIR_COLOUR:%0A                                %7B%0A                                    p.setExpirationYear(pairs%5B1%5D);%0A                                %7D%0A                                break;%0A                                case PassportFields.EYE_COLOUR:%0A                                %7B%0A                                    p.setExpirationYear(pairs%5B1%5D);%0A                                %7D%0A                                break;%0A                                case PassportFields.PASSPORT_ID:%0A                                %7B%0A                                    p.setPassportIDInteger.parseInt(pairs%5B1%5D);%0A                                %7D%0A                                break;%0A                                case PassportFields.COUNTRY_ID:%0A                                %7B%0A                                    p.setCountryID(Integer.parseInt(pairs%5B1%5D));%0A                                %7D%0A                                break;%0A                                default:%0A                                %7B%0A                                    System.out.println(%22Error - unknown field: %22+pairs%5B0%5D);%0A                                %7D%0A                                break;%0A                            %7D%0A                        %7D%0A                    %7D%0A                %7D%0A%0A                if (debug)%0A                    System.out.println(%22Loaded passport: %22+p);%0A%0A                results.add(p);
 %0A   

Update Batch.java