17. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 11/14/2017 6:57:19 AM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

17.1 Files compared

# Location File Last Modified
1 cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\jasper ScanLine.java Thu Nov 9 14:19:42 2017 UTC
2 cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\jasper ScanLine.java Tue Nov 14 12:25:51 2017 UTC

17.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 884
Changed 1 2
Inserted 0 0
Removed 0 0

17.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

17.4 Active regular expressions

No regular expressions were active.

17.5 Comparison detail

  1   package go v.va.cpss. jasper;
  2  
  3   import jav a.util.Arr ayList;
  4   import jav a.util.Col lections;
  5   import jav a.util.Has hMap;
  6   import jav a.util.Lis t;
  7   import jav a.util.Map ;
  8   import jav a.util.Opt ional;
  9  
  10   /**
  11    * The Sca n Line is  the string  of charac ters in th e coupon p ortion of  the
  12    * stateme nt. The Sc an Line is  used by L ock Box fo r routing  payments.  The Scan
  13    * Line lo gic is pro vided to u s from AIT C in Cobol  and trans lated to J ava.
  14    * 
  15    * @author   DN S      BROWNL
  16    */
  17   public cla ss ScanLin e {
  18  
  19           //  The size  of the sca n line hap pens to be  the same  as the ans wer to lif e.
  20           pr ivate stat ic final i nt CHECK_D IGIT_ARRAY _SIZE = 42 ;
  21  
  22           //  Reserved  size of fa cility.
  23           pr ivate stat ic final i nt FACILIT Y_NUMBER_R ESERVED_LE NGTH = 5;
  24  
  25           //  Reserved  size of ac count numb er.
  26           pr ivate stat ic final i nt ACCOUNT _NUMBER_RE SERVED_LEN GTH = 24;
  27  
  28           //  Reserved  miscellane ous string  is always  four zero s.
  29           pr ivate stat ic final S tring MISC ELLANEOUS_ NUMBER_RES ERVED_VALU E = "0000" ;
  30  
  31           //  Reserved  size of am ount due.
  32           pr ivate stat ic final i nt AMOUNT_ DUE_RESERV ED_LENGTH  = 9;
  33  
  34           //  The expec ted size o f the temp orary weig ht number.
  35           pr ivate stat ic final i nt TEMPORA RY_WEIGHT_ NUMBER_LEN GTH = 2;
  36  
  37           //  The expec ted size o f the chec k digit to tal.
  38           pr ivate stat ic final i nt CHECK_D IGIT_TOTAL _LENGTH =  4;
  39  
  40           //  Initializ ed to 0 as  per Cobol  8100 algo rithm.
  41           pr ivate stat ic final i nt CHECK_D IGIT_SUM_I NITIAL_VAL UE = 0;
  42  
  43           //  Initializ ed to 2 as  per Cobol  8100 algo rithm.
  44           pr ivate stat ic final i nt WEIGHT_ NUMBER_INI TIAL_VALUE  = 2;
  45  
  46           //  The tempo rary scan  line array  that has  been sanit ized to re move inval id
  47           //  character s.
  48           pr ivate char [] scanLin eA = new c har[CHECK_ DIGIT_ARRA Y_SIZE];
  49  
  50           //  The weigh t number u sed during  calculati on.
  51           pr ivate int  weightNumb er = WEIGH T_NUMBER_I NITIAL_VAL UE;
  52  
  53           //  The check  digit sum  used duri ng calcula tion.
  54           pr ivate int  checkDigit Sum = CHEC K_DIGIT_SU M_INITIAL_ VALUE;
  55  
  56           //  An array  of integer s represen ting the a ssociated  integer va lues mappe d
  57           //  for the s can line a rray.
  58           pr ivate int[ ] checkDig itDataPos  = new int[ CHECK_DIGI T_ARRAY_SI ZE];
  59  
  60           //  An array  of weights  that were  calculate d from the  checkDigi tDataPos.
  61           pr ivate int[ ] weightUp datedAns =  new int[C HECK_DIGIT _ARRAY_SIZ E];
  62  
  63           //  The resul ting scan  check digi t that res ults from  the algori thm
  64           //  calculati on.
  65           pr ivate int  scanCheckD igit = 0;
  66  
  67           //  The resul ting scan  line. It i s the orig inal data  with the t railing sc an
  68           //  check dig it.
  69           pr ivate Stri ng calcula tedScanLin e = null;
  70  
  71           //  The infam ous lookup  map.
  72           pr ivate stat ic Map<Cha racter, In teger> con versionTab leM;
  73           {
  74                    Map< Character,  Integer>  conversion TableInitM  = new Has hMap<Chara cter, Inte ger>();
  75                    // A lphabet
  76                    conv ersionTabl eInitM.put ('A', 0);
  77                    conv ersionTabl eInitM.put ('B', 1);
  78                    conv ersionTabl eInitM.put ('C', 2);
  79                    conv ersionTabl eInitM.put ('D', 3);
  80                    conv ersionTabl eInitM.put ('E', 4);
  81                    conv ersionTabl eInitM.put ('F', 5);
  82                    conv ersionTabl eInitM.put ('G', 6);
  83                    conv ersionTabl eInitM.put ('H', 7);
  84                    conv ersionTabl eInitM.put ('I', 8);
  85                    conv ersionTabl eInitM.put ('J', 9);
  86                    conv ersionTabl eInitM.put ('K', 0);
  87                    conv ersionTabl eInitM.put ('L', 1);
  88                    conv ersionTabl eInitM.put ('M', 2);
  89                    conv ersionTabl eInitM.put ('N', 3);
  90                    conv ersionTabl eInitM.put ('O', 4);
  91                    conv ersionTabl eInitM.put ('P', 5);
  92                    conv ersionTabl eInitM.put ('Q', 6);
  93                    conv ersionTabl eInitM.put ('R', 7);
  94                    conv ersionTabl eInitM.put ('S', 8);
  95                    conv ersionTabl eInitM.put ('T', 9);
  96                    conv ersionTabl eInitM.put ('U', 0);
  97                    conv ersionTabl eInitM.put ('V', 1);
  98                    conv ersionTabl eInitM.put ('W', 2);
  99                    conv ersionTabl eInitM.put ('X', 3);
  100                    conv ersionTabl eInitM.put ('Y', 4);
  101                    conv ersionTabl eInitM.put ('Z', 5);
  102                    // S ymbols
  103                    conv ersionTabl eInitM.put ('`', 0);
  104                    conv ersionTabl eInitM.put ('!', 1);
  105                    conv ersionTabl eInitM.put ('@', 2);
  106                    conv ersionTabl eInitM.put ('#', 3);
  107                    conv ersionTabl eInitM.put ('$', 4);
  108                    conv ersionTabl eInitM.put ('%', 5);
  109                    conv ersionTabl eInitM.put ('^', 6);
  110                    conv ersionTabl eInitM.put ('&', 7);
  111                    conv ersionTabl eInitM.put ('*', 8);
  112                    conv ersionTabl eInitM.put ('(', 9);
  113                    conv ersionTabl eInitM.put (')', 0);
  114                    conv ersionTabl eInitM.put ('-', 1);
  115                    conv ersionTabl eInitM.put ('+', 2);
  116                    conv ersionTabl eInitM.put ('=', 3);
  117                    conv ersionTabl eInitM.put (';', 4);
  118                    conv ersionTabl eInitM.put (':', 5);
  119                    conv ersionTabl eInitM.put ('\'', 6);
  120                    conv ersionTabl eInitM.put ('"', 7);
  121                    conv ersionTabl eInitM.put (',', 8);
  122                    conv ersionTabl eInitM.put ('.', 9);
  123                    conv ersionTabl eInitM.put ('/', 0);
  124                    conv ersionTabl eInitM.put ('\\', 1);
  125                    conv ersionTabl eInitM.put ('<', 2);
  126                    conv ersionTabl eInitM.put ('>', 3);
  127                    conv ersionTabl eInitM.put ('?', 4);
  128                    conv ersionTabl eInitM.put (']', 5);
  129                    conv ersionTabl eInitM.put ('_', 6);
  130                    conv ersionTabl eInitM.put ('{', 7);
  131                    conv ersionTabl eInitM.put ('}', 8);
  132                    conv ersionTabl eInitM.put ('[', 9);
  133                    conv ersionTabl eInitM.put ('\u00A2',  0); // ce nt symbol
  134                    conv ersionTabl eInitM.put ('~', 5);
  135                    // N umbers
  136                    // c onversionT ableInitM. put('0', 0 );
  137                    // c onversionT ableInitM. put('1', 3 );
  138                    // c onversionT ableInitM. put('2', 6 );
  139                    // c onversionT ableInitM. put('3', 9 );
  140                    // c onversionT ableInitM. put('4', 2 );
  141                    // c onversionT ableInitM. put('5', 6 );
  142                    // c onversionT ableInitM. put('6', 9 );
  143                    // c onversionT ableInitM. put('7', 2 );
  144                    // c onversionT ableInitM. put('8', 5 );
  145                    // c onversionT ableInitM. put('9', 8 );
  146  
  147                    conv ersionTabl eInitM.put ('0', 0);
  148                    conv ersionTabl eInitM.put ('1', 1);
  149                    conv ersionTabl eInitM.put ('2', 2);
  150                    conv ersionTabl eInitM.put ('3', 3);
  151                    conv ersionTabl eInitM.put ('4', 4);
  152                    conv ersionTabl eInitM.put ('5', 5);
  153                    conv ersionTabl eInitM.put ('6', 6);
  154                    conv ersionTabl eInitM.put ('7', 7);
  155                    conv ersionTabl eInitM.put ('8', 8);
  156                    conv ersionTabl eInitM.put ('9', 9);
  157  
  158                    conv ersionTabl eM = Colle ctions.unm odifiableM ap(convers ionTableIn itM);
  159           }
  160  
  161           /* *
  162            *  Construct  a scan li ne from th e site num ber, accou nt number,  and amoun t
  163            *  due. The  constructo r will run  the algor ithm at co nstruction  to create  the
  164            *  resulting  scan line . Creation  of new ob ject shoul d be wrapp ed in a tr y
  165            *  catch blo ck in case  of invali d inputs.
  166            *  
  167            *  @param si teNumber
  168            *              The faci lity or si te number.
  169            *  @param ac countNumbe r
  170            *              The acco unt number .
  171            *  @param am ountDue
  172            *              The amou nt due.
  173            * /
  174           pu blic ScanL ine(final  String sit eNumber, f inal Strin g accountN umber, fin al String  amountDue)  {
  175  
  176                    Stri ngBuilder  builder =  new String Builder();
  177  
  178                    // B uild a sca n line str ing based  on the inp ut values.
  179                    buil der.append (rightPad( siteNumber .trim(), F ACILITY_NU MBER_RESER VED_LENGTH , '*'));
  180                    buil der.append (rightPad( accountNum ber.trim() , ACCOUNT_ NUMBER_RES ERVED_LENG TH, '*'));
  181                    buil der.append (MISCELLAN EOUS_NUMBE R_RESERVED _VALUE);
  182                    fina l String a mountDueS  = amountDu e.trim().r eplace("." , "");
  183                    buil der.append (leftPad(a mountDueS,  AMOUNT_DU E_RESERVED _LENGTH, ' 0'));
  184  
  185                    fina l String s canLine =  builder.to String();
  186  
  187                    if ( scanLine.l ength() !=  CHECK_DIG IT_ARRAY_S IZE) {
  188                             throw  new IndexO utOfBounds Exception( "Scan Line  (" + scan Line + ")  has invali d length ( " + scanLi ne.length( )
  189                                               + ") but e xpected ("  + CHECK_D IGIT_ARRAY _SIZE + ") ");
  190                    }
  191  
  192                    // C onvert the  scan line  to an arr ay while a lso cleani ng the sca n line
  193                    // o f invalid  characters .
  194                    conv ertScanLin eToArray(s canLine);
  195  
  196                    // B uild the c heck digit  data arra y from the  scan line .
  197                    popu lateCheckD igitData() ;
  198  
  199                    // C ompute the  scan chec k digit;
  200                    comp uteScanChe ckDigit();
  201  
  202                    // B uild the c ompleted s can line.
  203                    buil dScanLine( );
  204           }
  205  
  206           /* *
  207            *  Get the c alculated  scan line.
  208            *  
  209            *  @return T he calcula ted scan l ine.
  210            * /
  211           pu blic Strin g getCalcu latedScanL ine() {
  212                    retu rn calcula tedScanLin e;
  213           }
  214  
  215           /* *
  216            *  Build a s can line a rray from  the input  scan line  while also  sanitizin g
  217            *  the scan  line chara cters of i nvalid spa ce or doub le quote c haracters.
  218            *  
  219            *  @param sc anLine
  220            *              The orig inal scan  line.
  221            * /
  222           pr ivate void  convertSc anLineToAr ray(final  String sca nLine) {
  223                    for  (int i = 0 ; i < CHEC K_DIGIT_AR RAY_SIZE;  ++i) {
  224                             char c  = scanLin e.charAt(i );
  225                             switch  (c) {
  226                             case '  ':
  227                                      c = '*';
  228                                      break;
  229                             case ' "':
  230                                      c = '/';
  231                                      break;
  232                             defaul t:
  233                                      break;
  234                             }
  235                             scanLi neA[i] = c ;
  236                    }
  237           }
  238  
  239           /* *
  240            *  Build a c heck digit  array ass ociated wi th the sca n line arr ay.
  241            * /
  242           pr ivate void  populateC heckDigitD ata() {
  243  
  244                    for  (int i = 0 ; i < CHEC K_DIGIT_AR RAY_SIZE;  ++i) {
  245                             checkD igitDataPo s[i] = loo kupNumberM apping(sca nLineA[i]) ;
  246                    }
  247           }
  248  
  249           /* *
  250            *  Compute t he scan ch eck digit.  This is c obol algor ithm 8100.
  251            * /
  252           //  8100-COMP UTE-SCAN-C HECK-DIGIT .
  253           //  MOVE WS-N ONE TO CHE CK-DIGIT-S UM.
  254           //  MOVE 2 TO  WEIGHT-NU MBER.
  255           //  PERFORM 8 400-CHECK- DIGIT-FORM ULA-1 VARY ING SCAN-S UB FROM
  256           //  ONE BY ON E UNTIL SC AN-SUB > F ORTY-TWO.
  257           //  PERFORM 8 500-CHECK- DIGIT-FORM ULA-2 VARY ING SCAN-S UB FROM
  258           //  ONE BY ON E UNTIL SC AN-SUB > F ORTY-TWO.
  259           //  PERFORM 8 700-CHECK- DIGIT-FORM ULA-3.
  260           pr ivate void  computeSc anCheckDig it() {
  261  
  262                    chec kDigitSum  = CHECK_DI GIT_SUM_IN ITIAL_VALU E;
  263                    weig htNumber =  WEIGHT_NU MBER_INITI AL_VALUE;
  264  
  265                    // P erform 840 0
  266                    for  (int i = 0 ; i < CHEC K_DIGIT_AR RAY_SIZE;  ++i) {
  267                             checkD igitFormul a1(i);
  268                    }
  269  
  270                    // P erform 850 0
  271                    for  (int j = 0 ; j < CHEC K_DIGIT_AR RAY_SIZE;  ++j) {
  272                             checkD igitFormul a2(j);
  273                    }
  274  
  275                    // P erform 870 0
  276                    chec kDigitForm ula3();
  277           }
  278  
  279           /* *
  280            *  Compute t he scan ch eck digit  formula 1.  This is c obol algor ithm 8400.
  281            * /
  282           //  8400-CHEC K-DIGIT-FO RMULA-1.
  283           //  COMPUTE T EMP-WEIGHT -NUM = CHE CK-DIGIT-D ATA-POS (S CAN-SUB)
  284           //  * WEIGHT- NUMBER.
  285           //  ADD WEIGH T-NUM-1 TO  WEIGHT-NU M-2.
  286           //  COMPUTE W EIGHT-NUMB ER = WEIGH T-NUMBER -  1.
  287           //  MOVE WEIG HT-NUM-2 T O WEIGHT-U PDATED-ANS  (SCAN-SUB ).
  288           //  IF WEIGHT -NUMBER <  1
  289           //  MOVE 2 TO  WEIGHT-NU MBER.
  290           pr ivate void  checkDigi tFormula1( final int  scanSub) {
  291  
  292                    fina l int temp WeightNum  = checkDig itDataPos[ scanSub] *  weightNum ber;
  293  
  294                    fina l List<Int eger> temp WeightNumL  = convert ValueToLis t(tempWeig htNum, TEM PORARY_WEI GHT_NUMBER _LENGTH);
  295  
  296                    fina l int adde dWeightNum  = tempWei ghtNumL.ge t(0) + tem pWeightNum L.get(1);
  297  
  298                    weig htNumber =  weightNum ber - 1;
  299  
  300                    weig htUpdatedA ns[scanSub ] = addedW eightNum;
  301  
  302                    if ( weightNumb er < 1) {
  303                             weight Number = W EIGHT_NUMB ER_INITIAL _VALUE;
  304                    }
  305           }
  306  
  307           /* *
  308            *  Compute t he scan ch eck digit  formula 2.  This is c obol algor ithm 8500.
  309            * /
  310           //  8500-CHEC K-DIGIT-FO RMULA-2.
  311           //  ADD WEIGH T-UPDATED- ANS (SCAN- SUB) TO CH ECK-DIGIT- SUM.
  312           pr ivate void  checkDigi tFormula2( final int  scanSub) {
  313                    chec kDigitSum  += weightU pdatedAns[ scanSub];
  314           }
  315  
  316           /* *
  317            *  Compute t he scan ch eck digit  formula 3.  This is c obol algor ithm 8700.
  318            * /
  319           //  8700-CHEC K-DIGIT-FO RMULA-3.
  320           //  MOVE CHEC K-DIGIT-SU M TO CHECK -DIGIT-TOT AL.
  321           //  IF CHECK- DIGIT-UNIT S-POS NOT  = ZERO
  322           //  SUBTRACT  CHECK-DIGI T-UNITS-PO S FROM 10
  323           //  GIVING SC AN-CHECK-D IGIT
  324           //  ELSE
  325           //  MOVE CHEC K-DIGIT-UN ITS-POS TO  SCAN-CHEC K-DIGIT.
  326           pr ivate void  checkDigi tFormula3( ) {
  327  
  328                    fina l List<Int eger> chec kDigitTota lL = conve rtValueToL ist(checkD igitSum, C HECK_DIGIT _TOTAL_LEN GTH);
  329  
  330                    fina l int chec kDigitUnit sPos = che ckDigitTot alL.get(3) ;
  331  
  332                    if ( checkDigit UnitsPos >  0) {
  333                             scanCh eckDigit =  10 - chec kDigitUnit sPos;
  334                    }
  335           }
  336  
  337           /* *
  338            *  Build the  resulting  calculate d scan lin e by appen ding the s can check
  339            *  digit to  the scan l ine array.
  340            * /
  341           pr ivate void  buildScan Line() {
  342                    calc ulatedScan Line = Str ing.valueO f(scanLine A) + Strin g.valueOf( scanCheckD igit);
  343           }
  344  
  345           /* *
  346            *  Look up t he associa ted number  for the i nput chara cter. If t he charact er
  347            *  is not re cognized i n the map  the associ ated value  is zero.
  348            *  
  349            *  @param c
  350            *              The char acter to l ook up in  the map.
  351            *  @return T he associa ted number  value for  the chara cter.
  352            * /
  353           pr ivate int  lookupNumb erMapping( final char  c) {
  354                    fina l Integer  value = co nversionTa bleM.get(c );
  355                    if ( value == n ull) {
  356                             return  0;
  357                    }
  358                    retu rn value;
  359           }
  360  
  361           /* *
  362            *  Return th e specifie d string t hat is lef t padded b y the spec ified pad
  363            *  character  that is t he specifi ed length.
  364            *  
  365            *  @param s
  366            *              The stri ng to pad.
  367            *  @param nb
  368            *              The tota l length o f the desi red padded  string.
  369            *  @param pa d
  370            *              The char acter to u se as a pa d.
  371            *  @return T he padded  string.
  372            * /
  373           pr ivate stat ic String  leftPad(St ring s, in t nb, char  pad) {
  374                    retu rn Optiona l.of(nb -  s.length() ).filter(i  -> i > 0)
  375                                      .map(i - > String.f ormat("%"  + i + "s",  "").repla ce(" ", pa d + "") +  s).orElse( s);
  376           }
  377  
  378           /* *
  379            *  Return th e specifie d string t hat is rig ht padded  by the spe cified pad
  380            *  character  that is t he specifi ed length.
  381            *  
  382            *  @param s
  383            *              The stri ng to pad.
  384            *  @param nb
  385            *              The tota l length o f the desi red padded  string.
  386            *  @param pa d
  387            *              The char acter to u se as a pa d.
  388            *  @return T he padded  string.
  389            * /
  390           pr ivate stat ic String  rightPad(S tring s, i nt nb, cha r pad) {
  391                    retu rn Optiona l.of(nb -  s.length() ).filter(i  -> i > 0)
  392                                      .map(i - > s + Stri ng.format( "%" + i +  "s", "").r eplace(" " , pad + "" )).orElse( s);
  393           }
  394  
  395           /* *
  396            *  Convert a n integer  to a list  of integer s. Easiest  to explai n by examp les:
  397            *  1. Input  value of 1 234 and pa d size of  4 results  in list of  Integer { 1,
  398            *  2, 3, 4}  2. Input v alue of 12  and pad s ize of 4 r esults in  list of
  399            *  Integer { 0, 0, 1, 2 }
  400            *  
  401            *  @param va lue
  402            *              The inte ger to con vert.
  403            *  @param pa dSize
  404            *              The pad  size that  specifies  the size o f the retu rned list.
  405            *  @return L ist of Int egers that  represent  the passe d in value .
  406            *  @throws N umberForma tException
  407            * /
  408           pu blic stati c List<Int eger> conv ertValueTo List(int v alue, fina l int padS ize) throw s NumberFo rmatExcept ion {
  409  
  410                    // H ow many di gits are i n the valu e?
  411                    int  length = 1 ;
  412                    if ( value > 0)  {
  413                             length  = (int) ( Math.log10 (value) +  1);
  414                    }
  415  
  416                    // I f too big  throw exce ption.
  417                    if ( length > p adSize) {
  418                             throw  new Number FormatExce ption("Val ue larger  than expec ted: " + v alue);
  419                    }
  420  
  421                    List <Integer>  valueL = n ew ArrayLi st<>();
  422  
  423                    do {
  424                             valueL .add(value  % 10);
  425                             value  /= 10;
  426                    } wh ile (value  > 0);
  427  
  428                    // I f bigger t han expect ed size, t hrow excep tion.
  429                    if ( valueL.siz e() > padS ize) {
  430                             throw  new Number FormatExce ption("Fai led to con vert to Li st: " + va lue);
  431                    }
  432  
  433                    // P ad if need ed to expe cted lengt h.
  434                    whil e (valueL. size() < p adSize) {
  435                             valueL .add(0);
  436                    }
  437  
  438                    // F lip the or der.
  439                    Coll ections.re verse(valu eL);
  440  
  441                    retu rn valueL;
  442           }
  443   }