264. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:44 PM 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.

264.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCommon\main\src\java\gov\va\med ClassTranslator.java Mon Dec 4 21:34:28 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCommon\main\src\java\gov\va\med ClassTranslator.java Mon Dec 4 22:01:47 2017 UTC

264.2 Comparison summary

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

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

264.4 Active regular expressions

No regular expressions were active.

264.5 Comparison detail

  1   /**
  2    * Package : MAG - Vi stA Imagin g
  3    * WARNING : Per VHA  Directive  2004-038,  this routi ne should  not be mod ified.
  4    * @date J ul 28, 201 0
  5    * Site Na me:  Washi ngton OI F ield Offic e, Silver  Spring, MD
  6    * @author  vhaiswbec kec
  7    * @versio n 1.0
  8    *
  9    * ------- ---------- ---------- ---------- ---------- ---------- -------
  10    * Propert y of the U S Governme nt.
  11    * No perm ission to  copy or re distribute  this soft ware is gi ven.
  12    * Use of  unreleased  versions  of this so ftware req uires the  user
  13    * to exec ute a writ ten test a greement w ith the Vi stA Imagin g
  14    * Develop ment Offic e of the D epartment  of Veteran s Affairs,
  15    * telepho ne (301) 7 34-0100.
  16    * 
  17    * The Foo d and Drug  Administr ation clas sifies thi s software  as
  18    * a Class  II medica l device.   As such,  it may not  be change d
  19    * in any  way.  Modi fications  to this so ftware may  result in  an
  20    * adulter ated medic al device  under 21CF R820, the  use of whi ch
  21    * is cons idered to  be a viola tion of US  Federal S tatutes.
  22    * ------- ---------- ---------- ---------- ---------- ---------- -------
  23    */
  24  
  25   package go v.va.med;
  26  
  27   import jav a.lang.ref lect.Metho d;
  28   import jav a.lang.ref lect.Modif ier;
  29   import jav a.util.Has hMap;
  30   import jav a.util.Map ;
  31   import org .apache.lo gging.log4 j.LogManag er;
  32   import org .apache.lo gging.log4 j.Logger;
  33  
  34   /**
  35    * A littl e helper t hat wraps  up the ugl y casting  and typing  into a te mplated
  36    * class.  To use thi s class cr eate an in stance wit h the targ et type sp ecified
  37    * for the  template,  e.g. Appl icationPro pertyAcces sor<Short>
  38    * shortPr opertyAcce ssor = new  Applicati onProperty Accessor<S hort>("sho rtValue",
  39    * "parseS hort"); Th e method n ames shoul d be the m ethod to c onvert fro m other
  40    * base ty pes to the  target ty pe and fro m a String  to the ta rget type.
  41    * 
  42    * For an  example of  usage, se e
  43    * 
  44    * @see go v.va.med.i maging.tra nsactionco ntext.Tran sactionCon textProxyI nvocationH andler
  45    * 
  46    * @author         
BECKEC
  47    * 
  48    * @param  <SRC> - th e type of  Object tha t we are c onverting  from.
  49    * @param  <DEST> - t he type of  Object th at we are  converting  to.
  50    */
  51   public cla ss ClassTr anslator<S RC, DEST>
  52   {
  53           pr ivate stat ic Logger  logger = L ogManager. getLogger( ClassTrans lator.clas s);
  54           
  55           pr ivate stat ic final M ap<Convers ionMapKey,  Method> c onversionM ethodMap;
  56           
  57           st atic
  58           {
  59                    conv ersionMeth odMap = ne w HashMap< Conversion MapKey, Me thod>();
  60                    
  61                    try
  62                    {
  63                    }
  64                    catc h (Excepti on x)
  65                    {
  66                             logger .error(x);
  67                    }                 
  68           }
  69           
  70           pu blic stati c <SRC ext ends Objec t, DEST ex tends Obje ct> void a ddConversi onMethod(C lass<SRC>  sourceClas s, Class<D EST> desti nationClas s, Method  conversion Method)
  71           {
  72                    conv ersionMeth odMap.put( new Conver sionMapKey (sourceCla ss, destin ationClass ), convers ionMethod) ;
  73           }
  74           
  75           pu blic stati c <SRC ext ends Objec t, DEST ex tends Obje ct> ClassT ranslator< SRC, DEST>  create(
  76                    Conv ersionMapK ey convers ionMapKey)
  77           {
  78                    try
  79                    {
  80                             Method  registere dMethod =  conversion MethodMap. get(conver sionMapKey );
  81                             if(reg isteredMet hod != nul l)
  82                                      return n ew ClassTr anslator<S RC, DEST>(  registere dMethod );
  83                             if(con versionMap Key.getSou rceClass()  == String .class)
  84                                      return n ew ClassTr anslator<S RC, DEST>(  conversio nMapKey.ge tDestinati onClass(). getMethod( "valueOf",  conversio nMapKey.ge tSourceCla ss()) );
  85                             if(con versionMap Key.getDes tinationCl ass() == S tring.clas s)
  86                                      return n ew ClassTr anslator<S RC, DEST>(  conversio nMapKey.ge tSourceCla ss().getMe thod("toSt ring", con versionMap Key.getDes tinationCl ass()) );
  87                    }
  88                    catc h (Excepti on x)
  89                    {
  90                             logger .warn("Don 't know ho w to conve rt '" + co nversionMa pKey.getSo urceClass( ).getName( ) + "' to  '" + conve rsionMapKe y.getDesti nationClas s().getNam e() + "'." );
  91                             // no  conversion  known, ju st return  null
  92                    }
  93                    
  94                    retu rn null;
  95           }
  96           
  97           pu blic stati c <SRC ext ends Objec t, DEST ex tends Obje ct> ClassT ranslator< SRC, DEST>  create(
  98                    Clas s<SRC> sou rceClass, 
  99                    Clas s<DEST> de stinationC lass)
  100           {
  101                    retu rn create( new Conver sionMapKey (sourceCla ss, destin ationClass ));
  102           }
  103  
  104           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =
  105           //  
  106           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== =
  107           pr ivate fina l Method c onversionM ethod;
  108           pr ivate fina l boolean  staticConv ersion;
  109  
  110           /* *
  111            *  
  112            * /
  113           pu blic Class Translator (Method co nversionMe thod)
  114           {
  115                    this .conversio nMethod =  conversion Method;                          // the Met hod to con vert
  116                    if(  !Modifier. isPublic(t his.conver sionMethod .getModifi ers()) )
  117                             throw  new Illega lArgumentE xception(" The method  '" + conv ersionMeth od.getName () + "' mu st be a pu blic metho d and it i s not.");
  118                    
  119                    if(  Modifier.i sStatic(th is.convers ionMethod. getModifie rs()) && c onversionM ethod.getP arameterTy pes().leng th == 1 )
  120                             static Conversion  = true;
  121                    else  if( !Modi fier.isSta tic(this.c onversionM ethod.getM odifiers() ) && conve rsionMetho d.getParam eterTypes( ).length = = 0 )
  122                             static Conversion  = false;
  123                    else
  124                             throw  new Illega lArgumentE xception(" The method  '" + conv ersionMeth od.getName () + "' mu st be eith er a stati c method t aking one  parameter  or an inst ance metho d taking n one.");
  125           }
  126  
  127           @S uppressWar nings("unc hecked")
  128           pu blic Objec t convert( Object val ue)
  129           {
  130                    if ( value == n ull)
  131                             return  (DEST)nul l;
  132  
  133                    Clas s<? extend s SRC>[] c onversionP arameterTy pes = (Cla ss<? exten ds SRC>[]) conversion Method.get ParameterT ypes();
  134  
  135                    try
  136                    {
  137                             // con verting fr om S to T  usually me ans callin g
  138                             // a p arse metho d
  139                             if(con versionMet hod != nul l)
  140                             {
  141                                      DEST con vertedValu e = (DEST) this.conve rsionMetho d.invoke(
  142                                               this.stati cConversio n ? null :  value,
  143                                               this.stati cConversio n ? conver sionParame terTypes[0 ].cast(val ue) : (Obj ect[])null );
  144                                      return c onvertedVa lue;
  145                             }
  146                    }
  147                    catc h (ClassCa stExceptio n ccX)
  148                    {
  149                             logger .error(ccX );
  150                    }
  151                    catc h (Excepti on e)
  152                    {
  153                             logger .warn(e);
  154                    }
  155                    
  156                    retu rn (DEST)n ull;
  157           }
  158           
  159           /* *
  160            *  
  161            *  @author v haiswbecke c
  162            *
  163            * /
  164           st atic class  Conversio nMapKey
  165           {
  166                    priv ate final  Class<?> s ourceClass ;
  167                    priv ate final  Class<?> d estination Class;
  168                    
  169                    publ ic Convers ionMapKey( Class<?> s ourceClass , Class<?>  destinati onClass)
  170                    {
  171                             super( );
  172                             this.s ourceClass  = sourceC lass;
  173                             this.d estination Class = de stinationC lass;
  174                    }
  175                    publ ic Class<? > getSourc eClass()
  176                    {
  177                             return  this.sour ceClass;
  178                    }
  179                    publ ic Class<? > getDesti nationClas s()
  180                    {
  181                             return  this.dest inationCla ss;
  182                    }
  183                    
  184                    @Ove rride
  185                    publ ic int has hCode()
  186                    {
  187                             final  int prime  = 31;
  188                             int re sult = 1;
  189                             result  = prime *  result +  ((this.des tinationCl ass == nul l) ? 0 : t his.destin ationClass .hashCode( ));
  190                             result  = prime *  result +  ((this.sou rceClass = = null) ?  0 : this.s ourceClass .hashCode( ));
  191                             return  result;
  192                    }
  193                    
  194                    @Ove rride
  195                    publ ic boolean  equals(Ob ject obj)
  196                    {
  197                             if (th is == obj)
  198                                      return t rue;
  199                             if (ob j == null)
  200                                      return f alse;
  201                             if (ge tClass() ! = obj.getC lass())
  202                                      return f alse;
  203                             Conver sionMapKey  other = ( Conversion MapKey) ob j;
  204                             if (th is.destina tionClass  == null)
  205                             {
  206                                      if (othe r.destinat ionClass ! = null)
  207                                               return fal se;
  208                             }
  209                             else i f (!this.d estination Class.equa ls(other.d estination Class))
  210                                      return f alse;
  211                             if (th is.sourceC lass == nu ll)
  212                             {
  213                                      if (othe r.sourceCl ass != nul l)
  214                                               return fal se;
  215                             }
  216                             else i f (!this.s ourceClass .equals(ot her.source Class))
  217                                      return f alse;
  218                             return  true;
  219                    }
  220           }
  221   }