52. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/10/2017 1:01:43 PM Central Daylight 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.

52.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\ImagingCommon\main\src\java\gov\va\med\imaging StringUtil.java Thu Jun 29 17:23:00 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\ImagingCommon\main\src\java\gov\va\med\imaging StringUtil.java Thu Jul 6 15:02:24 2017 UTC

52.2 Comparison summary

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

52.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

52.4 Active regular expressions

No regular expressions were active.

52.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging;
  5  
  6   import jav a.util.Arr ayList;
  7   import jav a.util.Ite rator;
  8   import jav a.util.Tre eMap;
  9   import jav a.util.reg ex.Matcher ;
  10   import jav a.util.reg ex.Pattern ;
  11  
  12   /**
  13    * @author         
BECKEC
  14    *
  15    */
  16   public cla ss StringU til
  17   {
  18           
  19       public  static fi nal String  CRLF = "\ r\n";
  20       public  static fi nal String  CARET = " ^";
  21       public  static fi nal String  STICK = " |";
  22       public  static fi nal String  COLON = " :";
  23       public  static fi nal String  DOUBLECOL ON = "::";
  24       public  static fi nal String  SEMICOLON  = ";";
  25       public  static fi nal String  COMMA = " ,";
  26       public  static fi nal String  PERIOD =  ".";
  27       public  static fi nal String  SLASH = " /";
  28       public  static fi nal String  SPACE = "  ";
  29           pu blic stati c final St ring EQUAL S = "=";
  30           pu blic stati c final St ring AMPER SAND = "&" ;
  31           pu blic stati c final St ring ATSIG N = "@";
  32           pu blic stati c final St ring NEW_L INE = "\n" ;
  33           pu blic stati c final St ring TILDE  = "~";
  34           pu blic stati c final St ring LEFT_ BRACKET =  "[";
  35           pu blic stati c final St ring RIGHT _BRACKET =  "]";
  36  
  37       public  static fi nal char C RCHAR = '\ r';
  38       public  static fi nal char N EW_LINECHA R = '\n';
  39       public  static fi nal char T ABCHAR = ' \t';
  40       public  static fi nal char F ORM_FEEDCH AR = '\f';
  41       public  static fi nal char B ACKCHAR =  '\b';
  42       public  static fi nal char D OUBLE_QUOT ECHAR = '\ "';
  43       public  static fi nal char S INGLE_QUOT ECHAR = '\ '';
  44       public  static fi nal char S LASHCHAR =  '\\';
  45           pu blic stati c final St ring DASH  = "-";
  46  
  47       
  48           /* *
  49            *  return tr ue if both  r1 and r2  are null  or 
  50            *  if r1 equ als r2
  51            *  
  52            *  @param s1
  53            *  @param s2
  54            *  @return
  55            * /
  56           pu blic stati c boolean  equalOrNul l(String s 1, String  s2)
  57           {
  58                    retu rn (s1 ==  null && s2  == null)  || (s1 !=  null && s1 .equals(s2 ));
  59           }
  60  
  61           /* *
  62            *  return tr ue if both  r1 and r2  are null  or 
  63            *  if r1 equ als r2, up  to the in dex specif ied
  64            *  
  65            *  @param r1
  66            *  @param r2
  67            *  @param en dIndex
  68            *  @return
  69            * /
  70           pu blic stati c boolean  equalOrNul l(String r 1, String  r2, int en dIndex)
  71           {
  72                    if(r 1==null &&  r1==null)
  73                             return  true;
  74                    if(r 1==null ||  r2==null)
  75                             return  false;
  76                    
  77                    Stri ng compara bleR1 = r1 .substring (0, endInd ex);
  78                    
  79                    Stri ng compara bleR2 = r2 .substring (0, endInd ex);
  80                    
  81                    retu rn compara bleR1.equa ls(compara bleR2);
  82           }
  83  
  84           /* *
  85            *  Return tr ue if both  r1 and r2  are null  or if r1 e quals r2,  up to the  first
  86            *  occurence  of endDel imiter.
  87            *  
  88            *  e.g.
  89            *  equalsOrN ull(null,  null, null ) = true
  90            *  equalsOrN ull("Hello  person na med Fred",  "Hello pe rson named  Barney",  "person na med") = tr ue
  91            *  
  92            *  @param r1
  93            *  @param r2
  94            *  @param en dDelimiter
  95            *  @return
  96            * /
  97           pu blic stati c boolean  equalOrNul lStrings(S tring r1,  String r2,  String en dDelimiter )
  98           {
  99                    if(e ndDelimite r == null)
  100                             return  equalOrNu ll(r1, r2) ;
  101                    
  102                    if(r 1==null &&  r1==null)
  103                             return  true;
  104                    if(r 1==null ||  r2==null)
  105                             return  false;
  106                    
  107                    int  comparable R1Index =  r1.indexOf (endDelimi ter);
  108                    comp arableR1In dex = (com parableR1I ndex == -1  ? r1.leng th()-1 : c omparableR 1Index);
  109                    Stri ng compara bleR1 = r1 .substring (0, compar ableR1Inde x);
  110                    
  111                    int  comparable R2Index =  r2.indexOf (endDelimi ter);
  112                    comp arableR2In dex = (com parableR2I ndex == -1  ? r1.leng th()-1 : c omparableR 2Index);
  113                    Stri ng compara bleR2 = r2 .substring (0, compar ableR2Inde x);
  114                    
  115                    retu rn compara bleR1.equa ls(compara bleR2);
  116           }
  117           
  118       public  static St ring[] spl it(String  s,String d elimiter)  {
  119           // Can't use  StringToke nizer beca use it ski ps blank f ields.
  120           // Can't use  it with re turnTokens  because i t screws u p multi-ch ar delimit ers.
  121           // All in all , it's a p retty godd amn useles s utility
  122                    if ( s.endsWith (delimiter ))
  123                    {
  124                             s += d elimiter;
  125                    }
  126           Ar rayList<St ring> al =  new Array List<Strin g>();
  127           in t p1 = 0,  p2 = 0;
  128           St ring prev  = delimite r;
  129           wh ile ((p2 =  s.indexOf (delimiter ,p1)) != - 1) {
  130                String f ld = s.sub string(p1, p2);
  131                if (fld. equals(del imiter) &&  prev.equa ls(delimit er)) {
  132                    al.a dd("");
  133                } else i f (!fld.eq uals(delim iter)) {
  134                    al.a dd(fld);
  135                }
  136                prev = f ld;
  137                p1 = p2  + delimite r.length() ;
  138           }
  139           if  (p1 != s. length())  al.add(s.s ubstring(p 1));
  140           // String rtn [] = (Stri ng[])al.to Array(new  String[0]) ;
  141           // Since abov e line doe sn't work  with .NET  we have to  do it thi s way:
  142           St ring rtn[]  = new Str ing[al.siz e()];
  143           in t i = 0;
  144           It erator<Str ing> iter  = al.itera tor();
  145           wh ile (iter. hasNext())  {
  146                rtn[i++]  = (String )iter.next ();
  147           }
  148           re turn rtn;
  149       }
  150  
  151       public  static bo olean isNu meric(Stri ng s) {
  152           fo r (int i=0 ; i<s.leng th(); i++)  {
  153                char c =  s.charAt( i);
  154                if (c <  '0' || c >  '9') retu rn false;
  155           }
  156           re turn true;
  157       }
  158  
  159           pu blic stati c String p repend(Str ing s, cha r c, int l th)
  160           {
  161                    if ( s.length()  > lth)
  162                    {
  163                             throw  new Illega lArgumentE xception(" Input stri ng longer  than reque sted strin g");
  164                    }
  165                    if ( s.length()  == lth)
  166                    {
  167                             return  s;
  168                    }
  169                    whil e (s.lengt h() < lth)
  170                    {
  171                             s += c ;
  172                    }
  173                    retu rn new Str ingBuffer( s).reverse ().toStrin g();
  174           }
  175  
  176           pu blic stati c boolean  isNumericC har(char c )
  177           {
  178                    retu rn (c >= ' 0' && c <=  '9');
  179           }
  180  
  181           pu blic stati c boolean  isAlphaCha r(char c)
  182           {
  183                    retu rn ((c >=  'A' && c < = 'Z') ||  (c >= 'a'  && c <= 'z '));
  184           }
  185  
  186           pu blic stati c boolean  isAlphaNum ericChar(c har c)
  187           {
  188                    retu rn (isAlph aChar(c) | | isNumeri cChar(c));
  189           }
  190  
  191           pu blic stati c boolean  isWhiteSpa ce(char c)
  192           {
  193                    retu rn (c == '  ' || c ==  '\t' || c  == '\n' | | c == '\r ');
  194           }
  195  
  196           pu blic stati c String r emoveNonNu mericChars (String s)
  197           {
  198                    if ( s == null)
  199                    {
  200                             return  null;
  201                    }
  202                    Stri ng rtn = " ";
  203                    for  (int i=0;  i<s.length (); i++)
  204                    {
  205                             char c  = s.charA t(i);
  206                             if (c  >= '0' &&  c <= '9')
  207                             {
  208                                      rtn += c ;
  209                             }
  210                    }
  211                    retu rn rtn;
  212           }
  213           
  214           pu blic stati c String r emoveNonAl phaNumeric Chars(Stri ng s)
  215           {
  216                    if ( s == null)
  217                    {
  218                             return  null;
  219                    }
  220                    Stri ng rtn = " ";
  221                    for  (int i=0;  i<s.length (); i++)
  222                    {
  223                             char c  = s.charA t(i);
  224                             if ((c  >= '0' &&  c <= '9') ||(c >= 'A ' && c <=  'Z')||(c > ='a' && c  <='z'))
  225                             {
  226                                      rtn += c ;
  227                             }
  228                    }
  229                    retu rn rtn;
  230           }
  231           
  232           pu blic stati c String r emoveBlank Lines(Stri ng s) 
  233           {
  234                    Stri ng[] lines  = split(s ,CRLF);
  235                    bool ean lastLi neBlank =  false;
  236                    Stri ng newS =  "";
  237                    for  (int i=0;  i<lines.le ngth; i++)  
  238                    {
  239                             if (!l ines[i].eq uals("")) 
  240                             {
  241                                      newS +=  lines[i] +  CRLF;
  242                                      lastLine Blank = fa lse;
  243                             } 
  244                             else 
  245                             {
  246                                      if (!las tLineBlank ) newS +=  CRLF;
  247                                      lastLine Blank = tr ue;
  248                             }
  249                    }
  250                    retu rn newS;
  251           }
  252  
  253           pu blic stati c boolean  isEmpty(St ring s)
  254           {
  255                    retu rn s == nu ll || s.le ngth() ==  0;
  256           }        
  257           
  258           pu blic stati c String[]  breakStri ng(String  input, int  partLengt h) {
  259                    int  numParts =  input.len gth() / pa rtLength;
  260                    if ( input.leng th() % par tLength >  0)
  261                             numPar ts++;
  262                    Stri ng[] parts  = new Str ing[numPar ts];
  263                    int  startIndex , endIndex ;
  264                    for  (int i = 0 ; i < numP arts; i++)  {
  265                             startI ndex = i *  partLengt h;
  266                             endInd ex = start Index + pa rtLength;
  267                             if (en dIndex > i nput.lengt h()){
  268                                      endIndex  = input.l ength();
  269                             }
  270                             parts[ i] = input .substring (i * partL ength, end Index);
  271                    }
  272  
  273                    retu rn parts;
  274           }
  275           
  276           
  277           pu blic stati c String P iece(Strin g s, Strin g delimite r, int pie ceNum) 
  278           {
  279                    // J MW 8/7/200 6 changed  to pieceNu m > flds.l ength from  pieceNum  >= flds.le ngth
  280           St ring[] fld s = split( s,delimite r);
  281           if  (pieceNum  > flds.le ngth) retu rn null;
  282           re turn flds[ pieceNum-1 ];
  283       }
  284           
  285       public  static St ring Piece (String li ne, char d elimiter,  int intere stedPiece) {
  286           
  287           // parse the  line and r eturn only  the inter ested piec e based on  delimiter s.
  288           St ring[] pie ces;
  289           St ring strDe limiter =  "\\"+Strin g.valueOf( delimiter) ;
  290         //Ca nnot use s plit() met hod in Str ingUtil.   Does not w ork proper ly.
  291           pi eces = lin e.split(st rDelimiter );
  292           if (intereste dPiece > p ieces.leng th) return  null;
  293           re turn piece s[interest edPiece-1] ;
  294       }
  295  
  296           pu blic stati c String M agPiece(St ring s, St ring delim iter, int  pieceNum)  {
  297                    Stri ng[] flds  = split(s, delimiter) ;
  298           if  (pieceNum  > flds.le ngth) retu rn s;
  299           re turn flds[ pieceNum-1 ];
  300           }
  301  
  302           pu blic stati c String[]  sortByPie ce(String[ ] s, Strin g delimite r, int pie ceNum) 
  303           {
  304                    Tree Map<String ,String> t m = new Tr eeMap<Stri ng, String >();
  305                    for  (int i=0;  i<s.length ; i++) {
  306                             String  key=Piece (s[i], del imiter, pi eceNum);
  307                             tm.put (key, s[i] );
  308                    }
  309                    Obje ct[] iter  = tm.keySe t().toArra y();
  310                    for  (int i=0;  i<tm.size( ); i++)
  311                             s[i] =  tm.get(it er[i]);
  312  
  313                    retu rn s;
  314           }     
  315           
  316       public  static St ring displ ayEncodedC hars(Strin g encodedS tring){
  317           St ringBuffer  decodedSt ring = new  StringBuf fer();
  318           ch ar[] chars  = encoded String.toC harArray() ;
  319                
  320           fo r(int x=0;  x<chars.l ength; x++ ){
  321                if(chars [x] == TAB CHAR){
  322                    deco dedString. append("\\ t");
  323                }
  324                else if( chars[x] = = CRCHAR){
  325                    deco dedString. append("\\ r");
  326                }
  327                else if( chars[x] = = NEW_LINE CHAR){
  328                    deco dedString. append("\\ n");
  329                }
  330                else if( chars[x] = = FORM_FEE DCHAR){
  331                    deco dedString. append("\\ f");
  332                }
  333                else if( chars[x] = = BACKCHAR ){
  334                    deco dedString. append("\\ b");
  335                }
  336                else if( chars[x] = = DOUBLE_Q UOTECHAR){
  337                    deco dedString. append("\\ \"");
  338                }
  339                else if( chars[x] = = SINGLE_Q UOTECHAR){
  340                    deco dedString. append("\\ '");
  341                }
  342                else if( chars[x] = = SLASHCHA R){
  343                    deco dedString. append("\\ \\");
  344                }
  345                else{
  346                    deco dedString. append(cha rs[x]);
  347                }
  348           }
  349           re turn decod edString.t oString();
  350       }
  351       
  352       
  353       public  static St ring forma tPatientID WithDashes (String pa tientID){
  354           St ring expre ssion = "^ \\d{9}$";
  355           Ch arSequence  inputSSN  = patientI D;
  356           Pa ttern patt ern = Patt ern.compil e(expressi on);
  357           Ma tcher matc her = patt ern.matche r(inputSSN );
  358           if (matcher.m atches()){
  359                    Stri ngBuffer s b = new St ringBuffer (inputSSN) ;
  360                    sb.i nsert(3, D ASH);
  361                    sb.i nsert(6, D ASH);
  362                    retu rn sb.toSt ring();
  363           }
  364           el se{
  365                    retu rn patient ID;
  366           }
  367       }
  368       
  369       /**
  370        * Met hod intVal  Calulates  integer v alue based  on first  characters  in a
  371        * str ing: "123a bcde" yiel ds 123
  372        *
  373        * @pa ram str
  374        *             in put string
  375        * @re turn integ er value o f start of  string
  376        */
  377       public  synchroni zed static  int intVa l (String  str)
  378       {
  379         int  charpos =  0;
  380         int  ready = 0;
  381         char  letter;
  382         int  value = 0;
  383         int  neg = 1;
  384  
  385         whil e ((ready  < 1) && (c harpos < s tr.length  ()))
  386         {
  387           le tter = str .charAt (c harpos++);
  388           sw itch (lett er)
  389           {
  390           ca se '0':
  391           ca se '1':
  392           ca se '2':
  393           ca se '3':
  394           ca se '4':
  395           ca se '5':
  396           ca se '6':
  397           ca se '7':
  398           ca se '8':
  399           ca se '9':
  400              value = va lue * 10 +  letter -  '0';
  401              break;
  402           ca se '-':
  403              neg = -neg ;
  404              break;
  405           de fault:
  406              ready = 1;
  407              break;
  408           }
  409         }
  410         retu rn value *  neg;
  411       }   
  412   }