1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.banking.util;
22
23 import java.io.IOException;
24 import java.io.InputStreamReader;
25 import java.io.LineNumberReader;
26 import java.io.UnsupportedEncodingException;
27 import java.net.URL;
28 import java.text.DecimalFormat;
29 import java.text.NumberFormat;
30 import java.text.ParseException;
31 import java.util.ArrayList;
32 import java.util.Date;
33 import java.util.HashMap;
34 import java.util.Iterator;
35 import java.util.List;
36 import java.util.Locale;
37 import java.util.Map;
38 import org.jdtaus.banking.Bankleitzahl;
39 import org.jdtaus.banking.BankleitzahlInfo;
40 import org.jdtaus.banking.messages.UpdatesBankleitzahlenDateiMessage;
41 import org.jdtaus.core.container.ContainerFactory;
42 import org.jdtaus.core.container.PropertyException;
43 import org.jdtaus.core.logging.spi.Logger;
44 import org.jdtaus.core.monitor.spi.Task;
45 import org.jdtaus.core.monitor.spi.TaskMonitor;
46
47
48
49
50
51
52
53
54
55
56
57
58 public final class BankleitzahlenDatei
59 {
60
61
62
63
64
65
66
67
68
69
70 private Logger getLogger()
71 {
72 return (Logger) ContainerFactory.getContainer().
73 getDependency( this, "Logger" );
74
75 }
76
77
78
79
80
81
82 private TaskMonitor getTaskMonitor()
83 {
84 return (TaskMonitor) ContainerFactory.getContainer().
85 getDependency( this, "TaskMonitor" );
86
87 }
88
89
90
91
92
93
94 private Locale getLocale()
95 {
96 return (Locale) ContainerFactory.getContainer().
97 getDependency( this, "Locale" );
98
99 }
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 private java.lang.String getDefaultEncoding()
115 {
116 return (java.lang.String) ContainerFactory.getContainer().
117 getProperty( this, "defaultEncoding" );
118
119 }
120
121
122
123
124
125
126
127
128
129
130 private static final BankleitzahlInfo[] NO_RECORDS =
131 {
132 };
133
134
135
136
137
138 public static final int JUNE_2006_FORMAT = 20060601;
139
140
141
142
143
144 public static final int JUNE_2013_FORMAT = 20130601;
145
146
147
148
149 private static final int[] FIELD_TO_OFFSET =
150 {
151 0, 8, 9, 67, 72, 107, 134, 139, 150, 152, 158, 159, 160, 168, 172
152 };
153
154
155
156
157 private static final int[] FIELD_TO_LENGTH =
158 {
159 8, 1, 58, 5, 35, 27, 5, 11, 2, 6, 1, 1, 8, 4, 2
160 };
161
162
163
164
165 private static final int[] FIELD_TO_ENDOFFSET =
166 {
167 FIELD_TO_OFFSET[0] + FIELD_TO_LENGTH[0],
168 FIELD_TO_OFFSET[1] + FIELD_TO_LENGTH[1],
169 FIELD_TO_OFFSET[2] + FIELD_TO_LENGTH[2],
170 FIELD_TO_OFFSET[3] + FIELD_TO_LENGTH[3],
171 FIELD_TO_OFFSET[4] + FIELD_TO_LENGTH[4],
172 FIELD_TO_OFFSET[5] + FIELD_TO_LENGTH[5],
173 FIELD_TO_OFFSET[6] + FIELD_TO_LENGTH[6],
174 FIELD_TO_OFFSET[7] + FIELD_TO_LENGTH[7],
175 FIELD_TO_OFFSET[8] + FIELD_TO_LENGTH[8],
176 FIELD_TO_OFFSET[9] + FIELD_TO_LENGTH[9],
177 FIELD_TO_OFFSET[10] + FIELD_TO_LENGTH[10],
178 FIELD_TO_OFFSET[11] + FIELD_TO_LENGTH[11],
179 FIELD_TO_OFFSET[12] + FIELD_TO_LENGTH[12],
180 FIELD_TO_OFFSET[13] + FIELD_TO_LENGTH[13],
181 FIELD_TO_OFFSET[14] + FIELD_TO_LENGTH[14]
182 };
183
184
185 private Map records = new HashMap( 5000 );
186 private Map deletedRecords = new HashMap( 5000 );
187 private Map headOffices = new HashMap( 5000 );
188 private Map branchOffices = new HashMap( 5000 );
189 private Map deletedHeadOffices = new HashMap( 5000 );
190 private Map deletedBranchOffices = new HashMap( 5000 );
191 private BankleitzahlInfo[] cachedRecords;
192 private BankleitzahlInfo[] cachedDeletedRecords;
193
194
195 private String encoding;
196
197
198
199
200
201 private int format;
202
203
204
205
206
207 private Date dateOfValidity;
208
209
210
211
212
213 private Date dateOfExpiration;
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 public BankleitzahlenDatei( final URL resource ) throws IOException
232 {
233 super();
234
235 if ( resource == null )
236 {
237 throw new NullPointerException( "resource" );
238 }
239
240 this.assertValidProperties();
241 this.format = JUNE_2006_FORMAT;
242 this.dateOfValidity = null;
243 this.dateOfExpiration = null;
244 this.readBankfile( resource );
245 }
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265 public BankleitzahlenDatei( final URL resource, final int format, final Date dateOfValidity,
266 final Date dateOfExpiration ) throws IOException
267 {
268 super();
269
270 if ( resource == null )
271 {
272 throw new NullPointerException( "resource" );
273 }
274 if ( dateOfValidity == null )
275 {
276 throw new NullPointerException( "dateOfValidity" );
277 }
278 if ( dateOfExpiration == null )
279 {
280 throw new NullPointerException( "dateOfExpiration" );
281 }
282
283 assertValidFormat( format );
284 this.assertValidProperties();
285 this.format = format;
286 this.dateOfValidity = (Date) dateOfValidity.clone();
287 this.dateOfExpiration = (Date) dateOfExpiration.clone();
288 this.readBankfile( resource );
289 }
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309 public BankleitzahlenDatei( final URL resource, final String encoding ) throws IOException
310 {
311 super();
312
313 if ( resource == null )
314 {
315 throw new NullPointerException( "resource" );
316 }
317 if ( encoding == null )
318 {
319 throw new NullPointerException( "encoding" );
320 }
321
322 this.assertValidProperties();
323 this.format = JUNE_2006_FORMAT;
324 this.encoding = encoding;
325 this.dateOfValidity = null;
326 this.dateOfExpiration = null;
327 this.readBankfile( resource );
328 }
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350 public BankleitzahlenDatei( final URL resource, final String encoding, final int format,
351 final Date dateOfValidity, final Date dateOfExpiration ) throws IOException
352 {
353 super();
354
355 if ( resource == null )
356 {
357 throw new NullPointerException( "resource" );
358 }
359 if ( encoding == null )
360 {
361 throw new NullPointerException( "encoding" );
362 }
363 if ( dateOfValidity == null )
364 {
365 throw new NullPointerException( "dateOfValidity" );
366 }
367 if ( dateOfExpiration == null )
368 {
369 throw new NullPointerException( "dateOfExpiration" );
370 }
371
372 assertValidFormat( format );
373 this.assertValidProperties();
374 this.encoding = encoding;
375 this.format = format;
376 this.dateOfValidity = (Date) dateOfValidity.clone();
377 this.dateOfExpiration = (Date) dateOfExpiration.clone();
378 this.readBankfile( resource );
379 }
380
381
382
383
384
385
386 public String getEncoding()
387 {
388 if ( this.encoding == null )
389 {
390 this.encoding = this.getDefaultEncoding();
391 }
392
393 return this.encoding;
394 }
395
396
397
398
399
400
401
402
403 public int getFormat()
404 {
405 return this.format;
406 }
407
408
409
410
411
412
413
414
415
416 public Date getDateOfValidity()
417 {
418 return (Date) ( this.dateOfValidity != null ? this.dateOfValidity.clone() : null );
419 }
420
421
422
423
424
425
426
427
428
429 public Date getDateOfExpiration()
430 {
431 return (Date) ( this.dateOfExpiration != null ? this.dateOfExpiration.clone() : null );
432 }
433
434
435
436
437
438
439 public BankleitzahlInfo[] getRecords()
440 {
441 if ( this.cachedRecords == null )
442 {
443 this.cachedRecords = (BankleitzahlInfo[]) this.records.values().
444 toArray( new BankleitzahlInfo[ this.records.size() ] );
445
446 }
447
448 return this.cachedRecords;
449 }
450
451
452
453
454
455
456
457
458
459
460
461 public BankleitzahlInfo[] getDeletedRecords()
462 {
463 if ( this.cachedDeletedRecords == null )
464 {
465 this.cachedDeletedRecords = (BankleitzahlInfo[]) this.deletedRecords.values().
466 toArray( new BankleitzahlInfo[ this.deletedRecords.size() ] );
467
468 }
469
470 return this.cachedDeletedRecords;
471 }
472
473
474
475
476
477
478
479
480
481
482
483 public BankleitzahlInfo getRecord( final Integer serialNumber )
484 {
485 if ( serialNumber == null )
486 {
487 throw new NullPointerException( "serialNumber" );
488 }
489
490 return (BankleitzahlInfo) this.records.get( serialNumber );
491 }
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506 public BankleitzahlInfo getDeletedRecord( final Integer serialNumber )
507 {
508 if ( serialNumber == null )
509 {
510 throw new NullPointerException( "serialNumber" );
511 }
512
513 return (BankleitzahlInfo) this.deletedRecords.get( serialNumber );
514 }
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530 public BankleitzahlInfo getHeadOfficeRecord( final Bankleitzahl bankCode )
531 {
532 if ( bankCode == null )
533 {
534 throw new NullPointerException( "bankCode" );
535 }
536
537 return (BankleitzahlInfo) this.headOffices.get( bankCode );
538 }
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555 public BankleitzahlInfo getDeletedHeadOfficeRecord( final Bankleitzahl bankCode )
556 {
557 if ( bankCode == null )
558 {
559 throw new NullPointerException( "bankCode" );
560 }
561
562 return (BankleitzahlInfo) this.deletedHeadOffices.get( bankCode );
563 }
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578 public BankleitzahlInfo[] getBranchOfficeRecords( final Bankleitzahl bankCode )
579 {
580 if ( bankCode == null )
581 {
582 throw new NullPointerException( "bankCode" );
583 }
584
585 final List records = (List) this.branchOffices.get( bankCode );
586 return records != null
587 ? (BankleitzahlInfo[]) records.toArray( new BankleitzahlInfo[ records.size() ] )
588 : NO_RECORDS;
589
590 }
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605 public BankleitzahlInfo[] getDeletedBranchOfficeRecords( final Bankleitzahl bankCode )
606 {
607 if ( bankCode == null )
608 {
609 throw new NullPointerException( "bankCode" );
610 }
611
612 final List records = (List) this.deletedBranchOffices.get( bankCode );
613 return records != null
614 ? (BankleitzahlInfo[]) records.toArray( new BankleitzahlInfo[ records.size() ] )
615 : NO_RECORDS;
616
617 }
618
619
620
621
622
623
624
625
626
627 public void update( final BankleitzahlenDatei file )
628 {
629 if ( file == null )
630 {
631 throw new NullPointerException( "file" );
632 }
633 if ( file.getFormat() < this.getFormat() )
634 {
635 throw new IllegalArgumentException( this.getCannotUpdateIncomptibleFileMessage(
636 this.getLocale(), toFormatName( this.getFormat() ), toFormatName( file.getFormat() ) ) );
637
638 }
639
640 final boolean log = this.getLogger().isDebugEnabled();
641 final boolean upgrade = this.getFormat() < file.getFormat();
642
643 int progress = 0;
644 Task task = new Task();
645 task.setIndeterminate( false );
646 task.setCancelable( false );
647 task.setDescription( new UpdatesBankleitzahlenDateiMessage() );
648 task.setMinimum( 0 );
649 task.setMaximum( file.getRecords().length );
650 task.setProgress( progress );
651
652 try
653 {
654 this.getTaskMonitor().monitor( task );
655
656 for ( int i = file.getRecords().length - 1; i >= 0; i-- )
657 {
658 task.setProgress( progress++ );
659 final BankleitzahlInfo newVersion = file.getRecords()[i];
660
661 if ( 'A' == newVersion.getChangeLabel() )
662 {
663 final BankleitzahlInfo oldVersion =
664 (BankleitzahlInfo) this.records.get( newVersion.getSerialNumber() );
665
666 if ( oldVersion != null && oldVersion.getChangeLabel() != 'D' )
667 {
668 this.resetRecords();
669 throw new IllegalArgumentException( this.getCannotAddDuplicateRecordMessage(
670 this.getLocale(), newVersion.getSerialNumber() ) );
671
672 }
673
674 this.records.put( newVersion.getSerialNumber(), newVersion );
675
676 if ( log )
677 {
678 this.getLogger().debug( this.getAddRecordInfoMessage(
679 this.getLocale(), String.valueOf( newVersion.getChangeLabel() ),
680 newVersion.getSerialNumber() ) );
681
682 }
683 }
684 else if ( 'M' == newVersion.getChangeLabel() || 'D' == newVersion.getChangeLabel() )
685 {
686 if ( this.records.put( newVersion.getSerialNumber(), newVersion ) == null )
687 {
688 this.resetRecords();
689 throw new IllegalArgumentException( this.getCannotModifyNonexistentRecordMessage(
690 this.getLocale(), newVersion.getSerialNumber() ) );
691
692 }
693
694 if ( log )
695 {
696 this.getLogger().debug( this.getModifyRecordInfoMessage(
697 this.getLocale(), String.valueOf( newVersion.getChangeLabel() ),
698 newVersion.getSerialNumber() ) );
699
700 }
701 }
702 else if ( 'U' == newVersion.getChangeLabel() )
703 {
704 if ( ( upgrade && this.records.put( newVersion.getSerialNumber(), newVersion ) == null )
705 || !this.records.containsKey( newVersion.getSerialNumber() ) )
706 {
707 this.resetRecords();
708 throw new IllegalArgumentException( this.getCannotModifyNonexistentRecordMessage(
709 this.getLocale(), newVersion.getSerialNumber() ) );
710
711 }
712 }
713 }
714
715 if ( upgrade )
716 {
717 if ( this.getLogger().isInfoEnabled() )
718 {
719 this.getLogger().info( this.getBankcodeFileUpgradeInfoMessage(
720 this.getLocale(), toFormatName( this.format ), toFormatName( file.getFormat() ) ) );
721
722 }
723
724 this.format = file.getFormat();
725 }
726
727 this.dateOfValidity = file.getDateOfValidity();
728 this.dateOfExpiration = file.getDateOfExpiration();
729 }
730 finally
731 {
732 this.getTaskMonitor().finish( task );
733 }
734
735 progress = 0;
736 task = new Task();
737 task.setIndeterminate( false );
738 task.setCancelable( false );
739 task.setDescription( new UpdatesBankleitzahlenDateiMessage() );
740 task.setMinimum( 0 );
741 task.setMaximum( this.records.size() );
742 task.setProgress( progress );
743
744 try
745 {
746 this.getTaskMonitor().monitor( task );
747
748 for ( final Iterator it = this.records.values().iterator(); it.hasNext(); )
749 {
750 task.setProgress( progress++ );
751 final BankleitzahlInfo oldVersion = (BankleitzahlInfo) it.next();
752
753 if ( 'D' == oldVersion.getChangeLabel() )
754 {
755 final BankleitzahlInfo newVersion = file.getRecord( oldVersion.getSerialNumber() );
756
757 if ( newVersion == null )
758 {
759 if ( this.deletedRecords.put( oldVersion.getSerialNumber(), oldVersion ) != null )
760 {
761 this.resetRecords();
762 throw new IllegalStateException( this.getCannotRemoveDuplicateRecordMessage(
763 this.getLocale(), oldVersion.getSerialNumber() ) );
764
765 }
766
767 it.remove();
768
769 if ( log )
770 {
771 this.getLogger().debug( this.getRemoveRecordInfoMessage(
772 this.getLocale(), String.valueOf( oldVersion.getChangeLabel() ),
773 oldVersion.getSerialNumber() ) );
774
775 }
776 }
777 }
778 }
779 }
780 finally
781 {
782 this.getTaskMonitor().finish( task );
783 }
784
785 this.updateRecords();
786 }
787
788
789
790
791
792
793 private void assertValidProperties()
794 {
795 if ( this.getEncoding() == null || this.getEncoding().length() == 0 )
796 {
797 throw new PropertyException( "encoding", this.getEncoding() );
798 }
799
800 try
801 {
802 "".getBytes( this.getEncoding() );
803 }
804 catch ( final UnsupportedEncodingException e )
805 {
806 throw new PropertyException( "encoding", this.getEncoding(), e );
807 }
808 }
809
810
811
812
813
814
815
816
817
818 private static void assertValidFormat( final int value )
819 {
820 if ( value != JUNE_2006_FORMAT && value != JUNE_2013_FORMAT )
821 {
822 throw new IllegalArgumentException( Integer.toString( value ) );
823 }
824 }
825
826
827
828
829
830
831
832
833
834
835 private void readBankfile( final URL resource ) throws IOException
836 {
837 if ( resource == null )
838 {
839 throw new NullPointerException( "resource" );
840 }
841
842 this.records.clear();
843
844 if ( this.getLogger().isDebugEnabled() )
845 {
846 this.getLogger().debug( this.getFileNameInfoMessage( this.getLocale(), resource.toExternalForm() ) );
847 }
848
849 LineNumberReader reader = null;
850 final NumberFormat plzFmt = new DecimalFormat( "00000" );
851 final NumberFormat serFmt = new DecimalFormat( "000000" );
852 final NumberFormat blzFmt = new DecimalFormat( "00000000" );
853
854 try
855 {
856 reader = new LineNumberReader( new InputStreamReader( resource.openStream(), this.getEncoding() ) );
857 boolean emptyLine = false;
858
859 for ( String line = reader.readLine(); line != null; line = reader.readLine() )
860 {
861 if ( line.trim().length() == 0 )
862 {
863 emptyLine = true;
864 continue;
865 }
866
867 if ( emptyLine )
868 {
869 throw new IllegalArgumentException( this.getUnexpectedDataMessage(
870 this.getLocale(), new Integer( reader.getLineNumber() ), resource.toExternalForm() ) );
871
872 }
873
874 final BankleitzahlInfo r = new BankleitzahlInfo();
875
876
877 r.setBankCode( Bankleitzahl.parse( field( line, FIELD_TO_OFFSET[0], FIELD_TO_ENDOFFSET[0] ) ) );
878
879 r.setHeadOffice( "1".equals( field( line, FIELD_TO_OFFSET[1], FIELD_TO_ENDOFFSET[1] ) ) );
880
881 r.setName( field( line, FIELD_TO_OFFSET[2], FIELD_TO_ENDOFFSET[2] ) );
882
883 r.setPostalCode( plzFmt.parse( field( line, FIELD_TO_OFFSET[3], FIELD_TO_ENDOFFSET[3] ) ).intValue() );
884
885 r.setCity( field( line, FIELD_TO_OFFSET[4], FIELD_TO_ENDOFFSET[4] ) );
886
887 r.setDescription( field( line, FIELD_TO_OFFSET[5], FIELD_TO_ENDOFFSET[5] ) );
888
889 String field = field( line, FIELD_TO_OFFSET[6], FIELD_TO_ENDOFFSET[6] );
890 r.setPanInstituteNumber( field.length() > 0 ? plzFmt.parse( field ).intValue() : 0 );
891
892 r.setBic( field( line, FIELD_TO_OFFSET[7], FIELD_TO_ENDOFFSET[7] ) );
893
894 r.setValidationLabel( field( line, FIELD_TO_OFFSET[8], FIELD_TO_ENDOFFSET[8] ) );
895
896 field = field( line, FIELD_TO_OFFSET[9], FIELD_TO_ENDOFFSET[9] );
897 r.setSerialNumber( new Integer( serFmt.parse( field ).intValue() ) );
898
899 r.setChangeLabel( field( line, FIELD_TO_OFFSET[10], FIELD_TO_ENDOFFSET[10] ).toCharArray()[0] );
900
901 r.setMarkedForDeletion( "1".equals( field( line, FIELD_TO_OFFSET[11], FIELD_TO_ENDOFFSET[11] ) ) );
902
903 Number blz = blzFmt.parse( field( line, FIELD_TO_OFFSET[12], FIELD_TO_ENDOFFSET[12] ) );
904 if ( blz.intValue() != 0 )
905 {
906 r.setReplacingBankCode( Bankleitzahl.valueOf( blz ) );
907 }
908 else
909 {
910 r.setReplacingBankCode( null );
911 }
912
913 if ( this.getFormat() >= JUNE_2013_FORMAT )
914 {
915
916 r.setIbanRuleLabel( Integer.valueOf( field( line, FIELD_TO_OFFSET[13],
917 FIELD_TO_ENDOFFSET[13] ) ) );
918
919 r.setIbanRuleVersion( Integer.valueOf( field( line, FIELD_TO_OFFSET[14],
920 FIELD_TO_ENDOFFSET[14] ) ) );
921
922 }
923
924 switch ( r.getChangeLabel() )
925 {
926 case 'A':
927 r.setCreationDate( this.getDateOfValidity() );
928 break;
929 case 'M':
930 r.setModificationDate( this.getDateOfValidity() );
931 break;
932 case 'D':
933 r.setDeletionDate( this.getDateOfExpiration() );
934 break;
935 case 'U':
936
937 break;
938 default:
939 throw new AssertionError( r.getChangeLabel() );
940 }
941
942 if ( this.records.put( r.getSerialNumber(), r ) != null )
943 {
944 this.resetRecords();
945 throw new IllegalArgumentException( this.getCannotAddDuplicateRecordMessage(
946 this.getLocale(), r.getSerialNumber() ) );
947
948 }
949 }
950 }
951 catch ( final ParseException e )
952 {
953 this.resetRecords();
954 throw (IllegalArgumentException) new IllegalArgumentException( resource.toExternalForm() ).initCause( e );
955 }
956 catch ( final IndexOutOfBoundsException e )
957 {
958 this.resetRecords();
959 throw (IllegalArgumentException) new IllegalArgumentException( resource.toExternalForm() ).initCause( e );
960 }
961 catch ( final IOException e )
962 {
963 this.resetRecords();
964 throw e;
965 }
966 finally
967 {
968 this.cachedRecords = null;
969 this.cachedDeletedRecords = null;
970
971 if ( reader != null )
972 {
973 reader.close();
974 }
975 }
976 }
977
978 private void resetRecords()
979 {
980 this.records.clear();
981 this.deletedRecords.clear();
982 this.updateRecords();
983 }
984
985 private void updateRecords()
986 {
987 this.headOffices.clear();
988 this.deletedHeadOffices.clear();
989 this.branchOffices.clear();
990 this.deletedBranchOffices.clear();
991 this.cachedRecords = null;
992 this.cachedDeletedRecords = null;
993
994 for ( int i = 0, l0 = this.getRecords().length; i < l0; i++ )
995 {
996 final BankleitzahlInfo record = this.getRecords()[i];
997
998 if ( record.isHeadOffice() )
999 {
1000 if ( this.headOffices.put( record.getBankCode(), record ) != null )
1001 {
1002 this.resetRecords();
1003 throw new IllegalStateException( this.getCannotAddDuplicateHeadOfficeRecordMessage(
1004 this.getLocale(), record.getBankCode() ) );
1005
1006 }
1007 }
1008 else
1009 {
1010 List list = (List) this.branchOffices.get( record.getBankCode() );
1011
1012 if ( list == null )
1013 {
1014 list = new ArrayList();
1015 this.branchOffices.put( record.getBankCode(), list );
1016 }
1017
1018 list.add( record );
1019 }
1020 }
1021
1022 for ( int i = 0, l0 = this.getDeletedRecords().length; i < l0; i++ )
1023 {
1024 final BankleitzahlInfo record = this.getDeletedRecords()[i];
1025
1026 if ( record.isHeadOffice() )
1027 {
1028 if ( this.deletedHeadOffices.put( record.getBankCode(), record ) != null )
1029 {
1030 this.resetRecords();
1031 throw new IllegalStateException( this.getCannotAddDuplicateHeadOfficeRecordMessage(
1032 this.getLocale(), record.getBankCode() ) );
1033
1034 }
1035 }
1036 else
1037 {
1038 List list = (List) this.deletedBranchOffices.get( record.getBankCode() );
1039
1040 if ( list == null )
1041 {
1042 list = new ArrayList();
1043 this.deletedBranchOffices.put( record.getBankCode(), list );
1044 }
1045
1046 list.add( record );
1047 }
1048 }
1049 }
1050
1051 private static String field( final String line, final int startOffset, final int endOffset )
1052 {
1053 return line.substring( startOffset, endOffset ).trim();
1054 }
1055
1056 private static String toFormatName( final long format )
1057 {
1058 String name = "";
1059
1060 if ( format == JUNE_2006_FORMAT )
1061 {
1062 name = "JUNE2006";
1063 }
1064 else if ( format == JUNE_2013_FORMAT )
1065 {
1066 name = "JUNE2013";
1067 }
1068
1069 return name;
1070 }
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088 private String getFileNameInfoMessage( final Locale locale,
1089 final java.lang.String fileName )
1090 {
1091 return ContainerFactory.getContainer().
1092 getMessage( this, "fileNameInfo", locale,
1093 new Object[]
1094 {
1095 fileName
1096 });
1097
1098 }
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111 private String getAddRecordInfoMessage( final Locale locale,
1112 final java.lang.String label,
1113 final java.lang.Number serialNumber )
1114 {
1115 return ContainerFactory.getContainer().
1116 getMessage( this, "addRecordInfo", locale,
1117 new Object[]
1118 {
1119 label,
1120 serialNumber
1121 });
1122
1123 }
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136 private String getModifyRecordInfoMessage( final Locale locale,
1137 final java.lang.String label,
1138 final java.lang.Number serialNumber )
1139 {
1140 return ContainerFactory.getContainer().
1141 getMessage( this, "modifyRecordInfo", locale,
1142 new Object[]
1143 {
1144 label,
1145 serialNumber
1146 });
1147
1148 }
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161 private String getRemoveRecordInfoMessage( final Locale locale,
1162 final java.lang.String label,
1163 final java.lang.Number serialNumber )
1164 {
1165 return ContainerFactory.getContainer().
1166 getMessage( this, "removeRecordInfo", locale,
1167 new Object[]
1168 {
1169 label,
1170 serialNumber
1171 });
1172
1173 }
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185 private String getCannotAddDuplicateRecordMessage( final Locale locale,
1186 final java.lang.Number serialNumber )
1187 {
1188 return ContainerFactory.getContainer().
1189 getMessage( this, "cannotAddDuplicateRecord", locale,
1190 new Object[]
1191 {
1192 serialNumber
1193 });
1194
1195 }
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207 private String getCannotAddDuplicateHeadOfficeRecordMessage( final Locale locale,
1208 final java.lang.Number bankCode )
1209 {
1210 return ContainerFactory.getContainer().
1211 getMessage( this, "cannotAddDuplicateHeadOfficeRecord", locale,
1212 new Object[]
1213 {
1214 bankCode
1215 });
1216
1217 }
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229 private String getCannotModifyNonexistentRecordMessage( final Locale locale,
1230 final java.lang.Number serialNumber )
1231 {
1232 return ContainerFactory.getContainer().
1233 getMessage( this, "cannotModifyNonexistentRecord", locale,
1234 new Object[]
1235 {
1236 serialNumber
1237 });
1238
1239 }
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252 private String getCannotUpdateIncomptibleFileMessage( final Locale locale,
1253 final java.lang.String targetBankCodeFileFormat,
1254 final java.lang.String sourceBankCodeFileFormat )
1255 {
1256 return ContainerFactory.getContainer().
1257 getMessage( this, "cannotUpdateIncomptibleFile", locale,
1258 new Object[]
1259 {
1260 targetBankCodeFileFormat,
1261 sourceBankCodeFileFormat
1262 });
1263
1264 }
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277 private String getUnexpectedDataMessage( final Locale locale,
1278 final java.lang.Number lineNumber,
1279 final java.lang.String resourceName )
1280 {
1281 return ContainerFactory.getContainer().
1282 getMessage( this, "unexpectedData", locale,
1283 new Object[]
1284 {
1285 lineNumber,
1286 resourceName
1287 });
1288
1289 }
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302 private String getBankcodeFileUpgradeInfoMessage( final Locale locale,
1303 final java.lang.String targetBankCodeFileFormat,
1304 final java.lang.String sourceBankCodeFileFormat )
1305 {
1306 return ContainerFactory.getContainer().
1307 getMessage( this, "bankcodeFileUpgradeInfo", locale,
1308 new Object[]
1309 {
1310 targetBankCodeFileFormat,
1311 sourceBankCodeFileFormat
1312 });
1313
1314 }
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326 private String getCannotRemoveDuplicateRecordMessage( final Locale locale,
1327 final java.lang.Number serialNumber )
1328 {
1329 return ContainerFactory.getContainer().
1330 getMessage( this, "cannotRemoveDuplicateRecord", locale,
1331 new Object[]
1332 {
1333 serialNumber
1334 });
1335
1336 }
1337
1338
1339
1340
1341 }