-
Notifications
You must be signed in to change notification settings - Fork 0
/
Globals.java
executable file
·979 lines (860 loc) · 33.2 KB
/
Globals.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
/*********************************************************************
* Class to handle the global variables.
* This includes
* ** the static list of iVotronic terminals discovered in the data
* ** the static list of messages discovered in the data
* ** the static list of PEBs discovered in the data
*
* We are going to violate some of the rules of modern programming
* and use these as globals because we need to access and modify
* them from several places.
*
* @author Duncan A. Buell
* Copyright (c) 2010-2012 Duncan A. Buell
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
**/
public class Globals
{
/*********************************************************************
* Instance variables for the class.
**/
private static final String TAG = "Globals: "; // for testing
static public final int DUMMYINT = Integer.MIN_VALUE;
static public final String DUMMYCODE = "dummycode";
static public final String DUMMYCLOSEPEB = "dummyclosepeb";
static public final String DUMMYCOUNTY = "dummycounty";
static public final String DUMMYDATE = "dummydate";
static public final String DUMMYIVONUMBER = "dummyivonumber";
static public final String DUMMYOPENPEB = "dummyopenpeb";
static public final String DUMMYPEBNUMBER = "dummypebnumber";
static public final String DUMMYPEBTYPE = "dummytype";
static public final String DUMMYSTRING = "dummy";
static public final String DEFAULTTIME = "1970_01_01 00:00:00";
static private String county = Globals.DUMMYCOUNTY;
static private String electionDate = Globals.DUMMYDATE;
static private int ballotCount152 = Integer.MIN_VALUE;
static private int ballotCount155 = Integer.MIN_VALUE;
static public TreeMap<String, Integer> conCand; //contest,candidate
static public TreeMap<String, Integer> ivoPctCount;
static public TreeMap<String, Integer> pctConCand; //pct,contest,candidate
static public TreeMap<String, Integer> pctIvoConCand; //pct,ivo,contest,candidate
static public TreeMap<String, Integer> pctIvoCount;
static public TreeMap<String, Integer> theVotes; //pct,ivo,style,seq,cand
// the following is added to be able to compute undervotes
static public TreeMap<String, Integer> ballotCountPctStyleIvo; //pct,style,ivo
static public TreeMap<String, Integer> ballotCountPctStyle; //pct,style
static public TreeMap<String, Integer> pctIvoStyleCon; //pct,style
static public TreeMap<String, String> eventTexts;
static public TreeMap<String, OnePEB> thePEBs;
static public TreeMap<String, OnePrecinct> pctsByName;
static public TreeMap<String, OnePrecinct> pctsByNumber;
static public TreeMap<String, OneTerminal> theTerms;
/*********************************************************************
* Constructor.
**/
public Globals()
{
county = Globals.DUMMYCOUNTY;
electionDate = Globals.DUMMYDATE;
ballotCount152 = Integer.MIN_VALUE;
ballotCount155 = Integer.MIN_VALUE;
conCand = new TreeMap<String, Integer>();
ivoPctCount = new TreeMap<String, Integer>();
pctConCand = new TreeMap<String, Integer>();
pctIvoConCand = new TreeMap<String, Integer>();
pctIvoCount = new TreeMap<String, Integer>();
theVotes = new TreeMap<String, Integer>();
ballotCountPctStyleIvo = new TreeMap<String, Integer>();
ballotCountPctStyle = new TreeMap<String, Integer>();
pctIvoStyleCon = new TreeMap<String, Integer>();
eventTexts = new TreeMap<String, String>();
thePEBs = new TreeMap<String, OnePEB>();
pctsByName = new TreeMap<String, OnePrecinct>();
pctsByNumber = new TreeMap<String, OnePrecinct>();
theTerms = new TreeMap<String, OneTerminal>();
} // public Globals()
/*********************************************************************
* Accessors and mutators.
**/
/*********************************************************************
* Method to get the ballot count from the 152 file.
*
* @return the ballot count from the 152 file
**/
public static int getBallotCount152()
{
return ballotCount152;
} // public static int getBallotCount152()
/*********************************************************************
* Method to add to the ballot count from the 152 file.
*
* @param howMany the number of ballots to add
**/
public static void addToBallotCount152(int howMany)
{
ballotCount152 += howMany;
} // public static void addToBallotCount152(int howMany)
/*********************************************************************
* Method to get the ballot count from the 155 file.
*
* @return the ballot count from the 155 file
**/
public static int getBallotCount155()
{
return ballotCount155;
} // public static int getBallotCount155()
/*********************************************************************
* Method to set the ballot count 155 from the 155 file.
*
* @param what the value to set.
**/
public static void setBallotCount155(int count)
{
ballotCount155 = count;
} // public static void setBallotCount155(int count)
/*********************************************************************
* Method to get the global county label.
*
* @return the county
**/
public static String getCounty()
{
return county;
} // public static String getCounty()
/*********************************************************************
* Method to set the county label.
*
* @param what the county.
* @param state whether to add 'State' to the county
**/
public static void setCounty(String county, boolean state)
{
Globals.county = county;
if(state)
Globals.county = Globals.county + "State";
} // public static void setCounty(String county, boolean state)
/*********************************************************************
* Method to get the election date.
*
* @return the election date.
**/
public static String getElectionDate()
{
return electionDate;
} // public static String getElectionDate()
/*********************************************************************
* Method to set the election date.
*
* This assumes that the date comes in as 'yyyymmdd' and this code
* converts that to 'yyyy_mm_dd'
*
* @param the unformatted date string.
**/
public static void setElectionDate(String date)
{
electionDate = String.format("%4s_%2s_%2s", date.substring(0,4),
date.substring(4,6),
date.substring(6));
FileUtils.logFile.printf("%s election date is set to %s%n", TAG, electionDate);
} // public static String convertToPctNumber(int number)
/*********************************************************************
* General methods.
**/
/*********************************************************************
* Method to compare two date strings.
*
* @param s1 first date
* @param s2 second date
* @return -1, 0, 1 as usual
**/
public static int compareDateTime(String s1, String s2)
{
int returnValue = 0; // default is that s1 equals s2
String day1, day2, month1, month2, year1, year2;
String hour1, hour2, minute1, minute2, second1, second2;
year1 = s1.substring(0,4);
month1 = s1.substring(5,7);
day1 = s1.substring(8,10);
hour1 = s1.substring(11,13);
minute1 = s1.substring(14,16);
second1 = s1.substring(17);
year2 = s2.substring(0,4);
month2 = s2.substring(5,7);
day2 = s2.substring(8,10);
hour2 = s2.substring(11,13);
minute2 = s2.substring(14,16);
second2 = s2.substring(17);
// FileUtils.logFile.printf("ONE %s %s %s %s %s %s%n", year1, month1, day1, hour1, minute1, second1);
// FileUtils.logFile.printf("TWO %s %s %s %s %s %s%n", year2, month2, day2, hour2, minute2, second2);
if(year1.compareTo(year2) < 0)
{
returnValue = -1;
}
else if(year1.compareTo(year2) > 0)
{
returnValue = 1;
}
else if(month1.compareTo(month2) < 0)
{
returnValue = -1;
}
else if(month1.compareTo(month2) > 0)
{
returnValue = 1;
}
else if(day1.compareTo(day2) < 0)
{
returnValue = -1;
}
else if(day1.compareTo(day2) > 0)
{
returnValue = 1;
}
else if(hour1.compareTo(hour2) < 0)
{
returnValue = -1;
}
else if(hour1.compareTo(hour2) > 0)
{
returnValue = 1;
}
else if(minute1.compareTo(minute2) < 0)
{
returnValue = -1;
}
else if(minute1.compareTo(minute2) > 0)
{
returnValue = 1;
}
else if(second1.compareTo(second2) < 0)
{
returnValue = -1;
}
else if(second1.compareTo(second2) > 0)
{
returnValue = 1;
}
return returnValue;
} // public static int compareDate(String s1, String s2)
/*********************************************************************
* Method to convert a DateTime to an seconds interval after opening.
*
* By default, if the date is not on the election date, we set the
* return value to the max integer.
*
* @param s the Datetime
* @return the seconds after 7am on the election date
**/
public static int convertDateTime(String s)
{
int returnValue = 0; // default is that s1 equals s2
String hour, minute, second;
if(!s.substring(0,10).equals(Globals.electionDate))
{
// FileUtils.logFile.printf("WRONG DAY %s%n", s);
return Integer.MAX_VALUE;
}
hour = s.substring(11,13);
minute = s.substring(14,16);
second = s.substring(17);
returnValue += (Integer.valueOf(hour.trim()) - 7) * 3600;
returnValue += (Integer.valueOf(minute.trim())) * 60;
returnValue += (Integer.valueOf(second.trim()));
// FileUtils.logFile.printf("TIME %s %s %s %d%n", hour, minute, second, returnValue);
return returnValue;
} // public static int convertDateTime(String s)
/*********************************************************************
* Method to convert an int to a precinct number string.
*
* @return the formatted <code>String</code> value.
**/
public static String convertToPctNumber(int number)
{
return String.format("%04d", number).trim();
} // public static String convertToPctNumber(int number)
/*********************************************************************
* Method to convert a string to a precinct number string.
*
* @return the formatted <code>String</code> value.
**/
public static String convertToPctNumber(String number)
{
String s = "0000";
s += number.trim();
return s.substring(s.length()-4).trim();
} // public static String convertToPctNumber(String number)
/*********************************************************************
* Method to convert a vote count to a string or else 'XXXXXX'.
* This is to flag the vote count values that have never been set
* to anything other that the 'Globals.DUMMYINT' value or else
* have had that value added in or subtracted off and are thus bogus.
*
* @param what the number to convert
*
* @return the converted value
**/
public static String convertToGoodVoteNumber(int what)
{
String s = "";
if((-999999 < what) && (what < 9999999))
s = String.format("%d", what);
else
s = "XXXXXX";
return s;
} // public static String convertToGoodVoteNumber(int what)
/*********************************************************************
* Method to initialize or increment a TreeMap.
*
* @param key the key for the <code>Treemap</code>.
* @param treemap the actual <code>TreeMap</code>.
* @param howMany how much to increment or store.
**/
public static void incrementTreeMap(String key,
TreeMap<String, Integer> treemap,
Integer howMany)
{
Integer value = treemap.get(key);
if(null == value)
{
treemap.put(key, howMany);
}
else
{
treemap.put(key, treemap.get(key)+howMany);
}
} // public static String convertToPctNumber(String number)
/*********************************************************************
* Method to open and return a <code>Scanner</code> from a
* filename prefix and a filename suffix.
*
* @return the opened <code>Scanner</code>
**/
public static Scanner OpenInputFile(String prefix, String suffix)
{
String inFileName = prefix + suffix;
Scanner inFile = null;
FileUtils.logFile.printf("%s open input file '%s'%n", TAG, inFileName);
FileUtils.logFile.flush();
inFile = FileUtils.ScannerOpen(inFileName);
if(null == inFile)
{
FileUtils.logFile.printf("%s FILE '%s' NOT FOUND%n", TAG, inFileName);
FileUtils.logFile.flush();
}
return inFile;
} // public static Scanner OpenInputFile(String prefix, String suffix)
/*********************************************************************
* Method to output the PctStyleIvo ballot counts.
*
* Contrary to what the method name actually says, this outputs not
* just one but two lists of totals, first in complete detail of
* counts by pct, style, and ivo, and then only by pct and style.
*
* @param outFile the output file to which to write
**/
public static void outputBallotCountPctStyleIvo(String prefix)
{
int localCount;
String contest;
String candidate;
String fileName = prefix + "_BallotCountPctStyleIvo.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Ballot counts by Pct, Style, Ivo for %s%n%n",
Globals.getCounty());
for(String bspsikey: Globals.ballotCountPctStyleIvo.keySet())
{
localCount = Globals.ballotCountPctStyleIvo.get(bspsikey);
outFile.printf("%s %7d%n", bspsikey, localCount);
outFile.flush();
}
outFile.printf("%n%nBallot counts by Pct, Style for %s%n%n",
Globals.getCounty());
for(String bspskey: Globals.ballotCountPctStyle.keySet())
{
localCount = Globals.ballotCountPctStyle.get(bspskey);
outFile.printf("%s %7d%n", bspskey, localCount);
outFile.flush();
}
outFile.printf("%n%nBallot counts by Pct, Ivo, Style, Contest for %s%n%n",
Globals.getCounty());
for(String thekey: Globals.pctIvoStyleCon.keySet())
{
int contestCount = Globals.pctIvoStyleCon.get(thekey);
String localPct = Keys.getPctFromUndervoteKey(thekey);
String localStyle = Keys.getStyleFromUndervoteKey(thekey);
String localIvo = Keys.getIvoFromUndervoteKey(thekey);
String bspsikey = Keys.makeKeyForBallotCountPctStyleIvo(localPct, localStyle, localIvo);
int voteCount = Globals.ballotCountPctStyleIvo.get(bspsikey);
outFile.printf("%7d %7d %7d %s%n", voteCount, contestCount, voteCount-contestCount, thekey);
outFile.flush();
}
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputBallotCountPctStyleIvo(String prefix)
/*********************************************************************
* Method to output the contest-candidate totals
*
* @param outFile the output file to which to write
**/
public static void outputContestCandidate(String prefix)
{
int localCount;
String contest;
String candidate;
String fileName = prefix + "_ContestCandidate.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Contest-Candidate totals for %s%n%n",
Globals.getCounty());
for(String concand: Globals.conCand.keySet())
{
localCount = Globals.conCand.get(concand);
contest = Keys.getContestFromConCandKey(concand);
candidate = Keys.getCandidateFromConCandKey(concand);
outFile.printf("%7d %s %s %n", localCount, contest, candidate);
outFile.flush();
}
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputContestCandidate(String prefix)
/*********************************************************************
* Method to output the event logs for all terminals.
*
* @param outFile the output file to which to write
**/
public static void outputEventLogs(String prefix)
{
int count;
String fileName = prefix + "_EventLogs.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Event logs by ivo for %s%n%n", Globals.getCounty());
count = 0;
outFile.printf("Event logs%n");
for(String termKey: Globals.theTerms.keySet())
{
OneTerminal term = Globals.theTerms.get(termKey);
outFile.printf("%s%n", term.dumpEvents());
count += term.getEventLogSize();
}
outFile.printf("Total number of terminals dumped: %8d%n",
Globals.theTerms.size());
outFile.printf("Total number of events dumped: %8d%n%n", count);
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputEventLogs(String prefix)
/*********************************************************************
* Method to output the event log counts for all terminals.
*
* @param outFile the output file to which to write
**/
public static void outputEventLogCounts(String prefix)
{
int count;
String fileName = prefix + "_EventLogCounts.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Event log counts by ivo for %s%n%n", Globals.getCounty());
count = 0;
outFile.printf("Event log counts%n");
for(String termKey: Globals.theTerms.keySet())
{
OneTerminal term = Globals.theTerms.get(termKey);
outFile.printf("%s%n", term.dumpEventCounts());
count += term.getEventLogSize();
}
outFile.printf("Total number of terminals dumped: %8d%n",
Globals.theTerms.size());
outFile.printf("Total number of events dumped: %8d%n%n", count);
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputEventLogCounts(String prefix)
/*********************************************************************
* Method to output the event texts.
*
* @param outFile the output file to which to write
**/
public static void outputEventTexts(String prefix)
{
String fileName = prefix + "_EventLogText.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Event text list is for %s%n%n", Globals.getCounty());
outFile.printf("Event texts%n");
for(String textKey: Globals.eventTexts.keySet())
{
outFile.printf("%8s %s%n",
textKey, Globals.eventTexts.get(textKey).toString());
}
outFile.printf("Total number of event texts: %8d%n%n",
Globals.eventTexts.size());
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputEventTexts(String prefix)
/*********************************************************************
* Method to output the ivos by pct and pcts by ivo lists
*
* @param outFile the output file to which to write
**/
public static void outputIvosAndPcts(String prefix)
{
boolean firstTime = true;
int ivoCount;
int localTotal;
int pctTotal;
int votesCast;
String ivo = "";
String name = "";
String oldpct = Globals.convertToPctNumber(0);
String pct = "";
String fileName = prefix + "_IvosAndPcts.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
// First we do by ivos within precincts.
localTotal = 0;
pctTotal = 0;
outFile.printf("Pct Ivo Count for %s%n", Globals.getCounty());
outFile.printf(" PCT IVO PCTTOT 155 152 : RUNNINGTOTAL%n");
for(String pctivoKey: Globals.pctIvoCount.keySet())
{
pct = Keys.getPctFromPctIvoCountKey(pctivoKey);
ivo = Keys.getIvoFromPctIvoCountKey(pctivoKey);
ivoCount = Globals.pctIvoCount.get(pctivoKey);
if(!oldpct.equals(pct))
{
if(!firstTime)
{
name = Globals.pctsByNumber.get(oldpct).getName();
votesCast = Globals.pctsByNumber.get(oldpct).getVotesCast();
outFile.printf("PCT TOTAL %25s %4s %7s: %7s", name, oldpct,
Globals.convertToGoodVoteNumber(pctTotal),
Globals.convertToGoodVoteNumber(votesCast));
if(pctTotal != votesCast)
outFile.printf(" ( %8s) ZORK",
Globals.convertToGoodVoteNumber(votesCast - pctTotal));
outFile.printf("%n");
// set the votes from 155 in the precinct instance
Globals.pctsByNumber.get(oldpct).setVotes155(pctTotal);
oldpct = pct;
pctTotal = 0;
}
else
{
firstTime = false;
oldpct = pct;
}
} // if(!oldpct.equals(pct))
pctTotal += ivoCount;
localTotal += ivoCount;
outFile.printf("%4s %7s %7s %7s %7s : %7s", pct, ivo,
Globals.convertToGoodVoteNumber(ivoCount),
Globals.convertToGoodVoteNumber(Globals.theTerms.get(ivo).getVotesCast155()),
Globals.convertToGoodVoteNumber(Globals.theTerms.get(ivo).getVotesCast152()),
Globals.convertToGoodVoteNumber(pctTotal));
if((ivoCount != Globals.theTerms.get(ivo).getVotesCast152()) &&
(Globals.theTerms.get(ivo).isNotAbsentee()))
{
outFile.printf(" (ZORK PCTTOT-152)");
}
if((ivoCount != Globals.theTerms.get(ivo).getVotesCast155()) &&
(Globals.theTerms.get(ivo).isNotAbsentee()))
{
outFile.printf(" (ZORK PCTTOT-155)");
}
if((Globals.theTerms.get(ivo).getVotesCast152() !=
Globals.theTerms.get(ivo).getVotesCast155()) &&
(Globals.theTerms.get(ivo).isNotAbsentee()))
{
outFile.printf(" (ZORK 155-152)");
}
outFile.printf("%n");
}
name = Globals.pctsByNumber.get(pct).getName();
votesCast = Globals.pctsByNumber.get(pct).getVotesCast();
outFile.printf("PCT TOTAL %25s %4s %7s: %7s", name, oldpct,
Globals.convertToGoodVoteNumber(pctTotal),
Globals.convertToGoodVoteNumber(votesCast));
if(pctTotal != votesCast)
outFile.printf(" ( %8s) ZORK",
Globals.convertToGoodVoteNumber(votesCast - pctTotal));
outFile.printf("%n");
// set the votes from 155 in the precinct instance
Globals.pctsByNumber.get(oldpct).setVotes155(pctTotal);
outFile.printf("%n");
outFile.printf("COUNTY TOTAL %7d%n%n", localTotal);
// Now we do the other way around for the second half of the file.
localTotal = 0;
outFile.printf("Pcts By Ivo%n");
outFile.printf(" IVO PCT COUNT%n");
for(String ivopctKey: Globals.ivoPctCount.keySet())
{
outFile.printf("%7s %4s %7d%n",
Keys.getIvoFromIvoPctCountKey(ivopctKey),
Keys.getPctFromIvoPctCountKey(ivopctKey),
Globals.ivoPctCount.get(ivopctKey));
localTotal += Globals.ivoPctCount.get(ivopctKey);
}
outFile.printf("%nCOUNTY TOTAL %7d%n%n%n", localTotal);
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputIvosAndPcts(String prefix)
/*********************************************************************
* Method to output the pcts by name and then by number.
*
* @param outFile the output file to which to write
**/
public static void outputPcts(String prefix)
{
String fileName = prefix + "_PctDetail.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Precinct Detail List By Name and Number for %s%n%n", Globals.getCounty());
//****************************************************************
// first by name
outFile.printf("Pcts By Name%n");
for(String pctKey: Globals.pctsByName.keySet())
{
outFile.printf("%s",
Globals.pctsByName.get(pctKey).toString().substring(0,63));
if(null == Globals.pctsByName.get(pctKey).getPctNumber())
{
outFile.printf(" PCT MISSING%n");
}
else if(Globals.pctsByName.get(pctKey).getVotes155() !=
Globals.pctsByName.get(pctKey).getVotesCast())
{
outFile.printf(" DATA MISSING%n");
}
else
{
outFile.printf("%n");
}
outFile.printf(" terminals: %s%n",
Globals.pctsByName.get(pctKey).toStringTerminals());
outFile.printf(" open/close pebs: %s %s%n",
Globals.pctsByName.get(pctKey).toStringOpenPEBs(),
Globals.pctsByName.get(pctKey).toStringClosePEBs());
}
outFile.printf("%n");
//****************************************************************
// then by number
outFile.printf("Pcts By Number%n");
for(String pctKey: Globals.pctsByNumber.keySet())
{
// outFile.printf("%s%n", Globals.pctsByNumber.get(pctKey).toString());
outFile.printf("%s",
Globals.pctsByNumber.get(pctKey).toString().substring(0,63));
if(null == Globals.pctsByNumber.get(pctKey).getPctNumber())
{
outFile.printf(" PCT MISSING%n");
}
else if(Globals.pctsByNumber.get(pctKey).getVotes155() !=
Globals.pctsByNumber.get(pctKey).getVotesCast())
{
outFile.printf(" DATA MISSING%n");
}
else
{
outFile.printf("%n");
}
outFile.printf(" terminals: %s%n",
Globals.pctsByNumber.get(pctKey).toStringTerminals());
outFile.printf(" open/close pebs: %s %s%n",
Globals.pctsByNumber.get(pctKey).toStringOpenPEBs(),
Globals.pctsByNumber.get(pctKey).toStringClosePEBs());
}
outFile.printf("%n");
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputPcts(String prefix)
/*********************************************************************
* Method to output the pct-contest-candidate totals
*
* @param outFile the output file to which to write
**/
public static void outputPctContestCandidate(String prefix)
{
int localCount;
String pct;
String contest;
String candidate;
String fileName = prefix + "_PctContestCandidate.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Pct-Contest-Candidate totals for %s%n%n", Globals.getCounty());
for(String pctconcand: Globals.pctConCand.keySet())
{
localCount = Globals.pctConCand.get(pctconcand);
pct = Keys.getPctFromPctConCandKey(pctconcand);
contest = Keys.getContestFromPctConCandKey(pctconcand);
candidate = Keys.getCandidateFromPctConCandKey(pctconcand);
outFile.printf("%7d %s %s %s %n",
localCount, pct, contest, candidate);
outFile.flush();
}
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputPctContestCandidate(String prefix)
/*********************************************************************
* Method to output the pct-ivo-contest-candidate totals
*
* @param outFile the output file to which to write
**/
public static void outputPctIvoContestCandidate(String prefix)
{
int localCount;
String pct;
String ivo;
String contest;
String candidate;
String fileName = prefix + "_PctIvoContestCandidate.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Pct-Ivo-Contest-Candidate totals for %s%n%n", Globals.getCounty());
for(String pctivoconcand: Globals.pctIvoConCand.keySet())
{
localCount = Globals.pctIvoConCand.get(pctivoconcand);
pct = Keys.getPctFromPctIvoConCandKey(pctivoconcand);
ivo = Keys.getIvoFromPctIvoConCandKey(pctivoconcand);
contest = Keys.getContestFromPctIvoConCandKey(pctivoconcand);
candidate = Keys.getCandidateFromPctIvoConCandKey(pctivoconcand);
outFile.printf("%7d %s %s %s %s %n", localCount, pct, ivo, contest, candidate);
outFile.flush();
}
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputPctIvoContestCandidate(String prefix)
/*********************************************************************
* Method to output the PEB list.
*
* @param outFile the output file to which to write
**/
public static void outputPEBs(String prefix)
{
String fileName = prefix + "_PEBDetail.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("PEB list for %s%n%n", Globals.getCounty());
outFile.printf("PEBs not used in closing in 152 and not in 68A%n");
for(String pebKey: Globals.thePEBs.keySet())
{
if((!Globals.thePEBs.get(pebKey).getUsedForClosing()) &&
(!Globals.thePEBs.get(pebKey).getFoundInSystemLog()))
{
outFile.printf("%s%n", Globals.thePEBs.get(pebKey).toString());
}
}
outFile.printf("%nPEBs used in closing in 152 but not in 68A%n");
for(String pebKey: Globals.thePEBs.keySet())
{
if(( Globals.thePEBs.get(pebKey).getUsedForClosing()) &&
(!Globals.thePEBs.get(pebKey).getFoundInSystemLog()))
{
outFile.printf("%s%n", Globals.thePEBs.get(pebKey).toString());
}
}
outFile.printf("%nPEBs not used in closing in 152 but present in 68A%n");
for(String pebKey: Globals.thePEBs.keySet())
{
if((!Globals.thePEBs.get(pebKey).getUsedForClosing()) &&
( Globals.thePEBs.get(pebKey).getFoundInSystemLog()))
{
outFile.printf("%s%n", Globals.thePEBs.get(pebKey).toString());
}
}
outFile.printf("%nPEBs used in closing in 152 and present in 68A%n");
for(String pebKey: Globals.thePEBs.keySet())
{
if(( Globals.thePEBs.get(pebKey).getUsedForClosing()) &&
( Globals.thePEBs.get(pebKey).getFoundInSystemLog()))
{
outFile.printf("%s%n", Globals.thePEBs.get(pebKey).toString());
}
}
outFile.printf("Total number of PEBs: %8d%n%n", Globals.thePEBs.size());
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputPEBs(String prefix)
/*********************************************************************
* Method to output the terminals list.
*
* @param outFile the output file to which to write
**/
public static void outputTerminals(String prefix)
{
//****************************************************************
// First we output the terminal list with all the data.
String fileName1 = prefix + "_IvoDetail.txt";
PrintWriter outFile1 = FileUtils.PrintWriterOpen(fileName1);
outFile1.printf("output the ivo terminal list for %s%n%n", Globals.getCounty());
outFile1.printf("Terminals%n");;
for(String termKey: Globals.theTerms.keySet())
{
outFile1.printf("%s%n", Globals.theTerms.get(termKey).toString());
}
outFile1.printf("Total number of terminals: %8d%n%n", Globals.theTerms.size());
outFile1.flush();
FileUtils.CloseFile(outFile1);
//****************************************************************
// Then we output the list of memory card collection times.
String fileName2 = prefix + "_IvoMemoryCards.txt";
PrintWriter outFile2 = FileUtils.PrintWriterOpen(fileName2);
outFile2.printf("output the times of ivo memory card data collection for %s%n%n", Globals.getCounty());
// get the times
ArrayList<String> list = new ArrayList<String>();
for(String termKey: Globals.theTerms.keySet())
{
String s = Globals.theTerms.get(termKey).toStringMemoryCollectionTime() +
" " + termKey;
list.add(s);
if(Globals.theTerms.get(termKey).toStringMemoryCollectionTime().equals(""))
{
outFile2.printf("NO MEMORY CARD DATA COLLECTION FOR TERMINAL %s%n", termKey);
}
}
// sort the times
Collections.sort(list);
for(int i = 0; i < list.size(); ++i)
{
outFile2.printf("%s%n", list.get(i));
} // for(int i = 0; i < list.size()-1; ++i)
outFile2.flush();
FileUtils.CloseFile(outFile2);
} // public static void outputTerminals(String prefix)
/*********************************************************************
* Method to output the votes list.
*
* @param outFile the output file to which to write
**/
public static void outputVotes(String prefix)
{
String fileName = prefix + "_PctIvoBSContestCandidate.txt";
PrintWriter outFile = FileUtils.PrintWriterOpen(fileName);
outFile.printf("Vote Detail for %s%n%n", Globals.getCounty());
outFile.printf("Votes%n");
for(String votesKey: Globals.theVotes.keySet())
{
outFile.printf("%6d %s%n", Globals.theVotes.get(votesKey), votesKey);
}
outFile.printf("Total number of vote items: %8d%n", Globals.theVotes.size());
outFile.printf("Total ballot count in 155: %8d%n%n", ballotCount155);
outFile.flush();
FileUtils.CloseFile(outFile);
} // public static void outputVotes(String prefix)
} // public class Globals