Produced by Araxis Merge on 12/5/2017 12:06:51 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\VixCacheWebApp\main\src\gov\va\med\imaging\cache | AbstractNamedVO.java | Mon Dec 4 21:34:28 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\VixCacheWebApp\main\src\gov\va\med\imaging\cache | AbstractNamedVO.java | Mon Dec 4 22:07:16 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 544 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 1 | /** | |
| 2 | * | |
| 3 | */ | |
| 4 | package go v.va.med.i maging.cac he; | |
| 5 | ||
| 6 | import jav a.io.Seria lizable; | |
| 7 | import jav a.util.Arr ayList; | |
| 8 | import jav a.util.Col lection; | |
| 9 | import jav a.util.Ite rator; | |
| 10 | import jav a.util.Lis t; | |
| 11 | import jav a.util.Sor tedSet; | |
| 12 | import org .apache.lo gging.log4 j.LogManag er; | |
| 13 | import org .apache.lo gging.log4 j.Logger; | |
| 14 | ||
| 15 | /** | |
| 16 | * @author
|
|
| 17 | * | |
| 18 | */ | |
| 19 | public abs tract clas s Abstract NamedVO | |
| 20 | implements Serializa ble, Merga ble<Abstra ctNamedVO> , Comparab le<Abstrac tNamedVO> | |
| 21 | { | |
| 22 | pr ivate stat ic final l ong serialVers ionUID = 1L; | |
| 23 | ||
| 24 | pr otected tr ansient Lo gger logge r = LogMan ager.getLo gger("Abst ractNamedV O"); | |
| 25 | pr ivate Stri ng name; // the name is both th e displaye d name and the prima ry key | |
| 26 | pr ivate tran sient bool ean childr enPopulate d = false; | |
| 27 | pr ivate tran sient Abst ractNamedV O parent; // transie nt because the paren t is not | |
| 28 | // set unt il it join s the clie nt-side ca ched hiera rchy | |
| 29 | ||
| 30 | pu blic Abstr actNamedVO (){ this.n ame = null ;} | |
| 31 | pu blic Abstr actNamedVO (String na me) | |
| 32 | { | |
| 33 | this .name = na me; | |
| 34 | } | |
| 35 | ||
| 36 | pu blic Strin g getName( ) | |
| 37 | { | |
| 38 | retu rn name; | |
| 39 | } | |
| 40 | ||
| 41 | pu blic Abstr actNamedVO getParent () | |
| 42 | { | |
| 43 | retu rn parent; | |
| 44 | } | |
| 45 | ||
| 46 | pu blic void setParent( AbstractNa medVO pare nt) | |
| 47 | { | |
| 48 | this .parent = parent; | |
| 49 | } | |
| 50 | ||
| 51 | pu blic boole an isChild renPopulat ed() | |
| 52 | { | |
| 53 | retu rn childre nPopulated ; | |
| 54 | } | |
| 55 | pu blic void setChildre nPopulated (boolean c hildrenPop ulated) | |
| 56 | { | |
| 57 | this .childrenP opulated = childrenP opulated; | |
| 58 | } | |
| 59 | ||
| 60 | pu blic abstr act CacheI temPath ge tPath(); | |
| 61 | ||
| 62 | /* * | |
| 63 | * Return a count of t he total n umber of c hildren re gardless o f type. | |
| 64 | * i.e. Grou pVO includ es its chi ld groups and instan ces. | |
| 65 | * @return | |
| 66 | * / | |
| 67 | pu blic abstr act int ge tChildCoun t(); | |
| 68 | ||
| 69 | /* * | |
| 70 | * | |
| 71 | * @param na me | |
| 72 | * @return | |
| 73 | * / | |
| 74 | pu blic abstr act Abstra ctNamedVO childWithN ame(String name); | |
| 75 | ||
| 76 | /* * | |
| 77 | * | |
| 78 | * @param ch ildName | |
| 79 | * @return | |
| 80 | * / | |
| 81 | pu blic Abstr actNamedVO removeChi ld(String childName) | |
| 82 | { | |
| 83 | Abst ractNamedV O child = childWithN ame(childN ame); | |
| 84 | ||
| 85 | retu rn removeC hild(child ) ? child : null; | |
| 86 | } | |
| 87 | ||
| 88 | pr otected ab stract boo lean remov eChild(Abs tractNamed VO child); | |
| 89 | ||
| 90 | /* * | |
| 91 | * | |
| 92 | * @param <T > | |
| 93 | * @param ch ildren | |
| 94 | * @param na me | |
| 95 | * @return | |
| 96 | * / | |
| 97 | pr otected <T extends A bstractNam edVO> T se archChildC ollection( Collection <T> childr en, String name) | |
| 98 | { | |
| 99 | for( T child : children ) | |
| 100 | if( ch ild.getNam e().equals (name) ) | |
| 101 | return c hild; | |
| 102 | ||
| 103 | retu rn null; | |
| 104 | } | |
| 105 | ||
| 106 | /* * | |
| 107 | * | |
| 108 | * @param ot her | |
| 109 | * @throws M ergeExcept ion | |
| 110 | * / | |
| 111 | @O verride | |
| 112 | pu blic void merge(Abst ractNamedV O other) | |
| 113 | th rows Merge Exception | |
| 114 | { | |
| 115 | // N OTE, the n ame field is NOT mer ged becaus e they mus t be equal to do a m erge | |
| 116 | if(! this.equa ls(other)) | |
| 117 | throw new MergeE xception( | |
| 118 | "Attempt to merge unequal ob jects '" | |
| 119 | + this.g etName() | |
| 120 | + "' and '" | |
| 121 | + other. getName() | |
| 122 | + "'."); | |
| 123 | ||
| 124 | if(i sChildrenP opulated() || other. isChildren Populated( )) | |
| 125 | setChi ldrenPopul ated(true) ; | |
| 126 | } | |
| 127 | ||
| 128 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 129 | // | |
| 130 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 131 | /* * | |
| 132 | * | |
| 133 | * @param <T > | |
| 134 | * @param th isCollecti on | |
| 135 | * @param ot herCollect ion | |
| 136 | * @throws M ergeExcept ion | |
| 137 | * / | |
| 138 | pr otected <C extends A bstractNam edVO, T ex tends Abst ractNamedV O> void me rgeCollect ions( | |
| 139 | C pa rent, | |
| 140 | Coll ection<T> thisColl ection, | |
| 141 | Coll ection<T> otherCol lection) | |
| 142 | th rows Merge Exception | |
| 143 | { | |
| 144 | for( Iterator<T > otherIte r = otherC ollection. iterator() ; otherIte r.hasNext( ); ) | |
| 145 | { | |
| 146 | T othe rElement = otherIter .next(); | |
| 147 | if( th isCollecti on.contain s(otherEle ment) ) | |
| 148 | { | |
| 149 | for(T th isElement : thisColl ection) | |
| 150 | if(otherEl ement.equa ls(thisEle ment)) | |
| 151 | { | |
| 152 | ot herElement .setParent (parent); | |
| 153 | th isElement. setParent( parent); // this is a kludge !! !! | |
| 154 | th isElement. merge(othe rElement); | |
| 155 | lo gger.info( "Merged '" + otherEl ement.getN ame() + "' into '" + thisEleme nt.getName () + "', c hild of '" + parent. getName() + "'."); | |
| 156 | br eak; | |
| 157 | } | |
| 158 | } | |
| 159 | else | |
| 160 | { | |
| 161 | logger.i nfo("Addin g '" + oth erElement. getName() + "' as ch ild of '" + parent.g etName() + "'."); | |
| 162 | otherEle ment.setPa rent(paren t); | |
| 163 | thisColl ection.add (otherElem ent); | |
| 164 | } | |
| 165 | } | |
| 166 | } | |
| 167 | ||
| 168 | /* * | |
| 169 | * Get ALL o f the chil dren as on e List. | |
| 170 | * @return | |
| 171 | * / | |
| 172 | pu blic abstr act <E ext ends Abstr actNamedVO > SortedSe t<E> getCh ildren(); | |
| 173 | ||
| 174 | /* * | |
| 175 | * | |
| 176 | * @return | |
| 177 | * / | |
| 178 | pu blic List< AbstractNa medVO> get ChildrenAs List() | |
| 179 | { | |
| 180 | List <AbstractN amedVO> li st = new A rrayList<A bstractNam edVO>(); | |
| 181 | ||
| 182 | for( Iterator<A bstractNam edVO> itr = getChild ren().iter ator(); it r.hasNext( ); ) | |
| 183 | list.a dd(itr.nex t()); | |
| 184 | ||
| 185 | retu rn list; | |
| 186 | } | |
| 187 | ||
| 188 | /* * | |
| 189 | * | |
| 190 | * @param pa th | |
| 191 | * @param cu rrentDepth | |
| 192 | * / | |
| 193 | pr otected Ab stractName dVO remove Item(Cache ItemPath p ath, CACHE _POPULATIO N_DEPTH cu rrentDepth ) | |
| 194 | { | |
| 195 | Stri ng name = path.ge tNameAt(cu rrentDepth ); | |
| 196 | CACH E_POPULATI ON_DEPTH childDepth = path.ne xtDepth(cu rrentDepth ); | |
| 197 | Stri ng chil dName = ch ildDepth = = null ? n ull : path .getNameAt (childDept h); | |
| 198 | bool ean chil dIsEndOfPa th = child Depth == n ull ? fals e : path.n extDepth(c hildDepth) == null; | |
| 199 | ||
| 200 | logg er.info("r emoveItem( " + path.t oString() + "," + cu rrentDepth .toString( ) + ")"); | |
| 201 | ||
| 202 | // t he name of the item at the cur rent depth must not be null | |
| 203 | if(n ame != nul l) | |
| 204 | { | |
| 205 | // if the child name is nu ll, we som ehow went too far do wn the cha in, | |
| 206 | // thi s is an er ror | |
| 207 | if(chi ldName == null) | |
| 208 | { | |
| 209 | logger.e rror("Unab le to remo veItem(" + path.toSt ring() + " , " + curr entDepth.t oString() + "), name at child depth is n ull."); | |
| 210 | } | |
| 211 | else | |
| 212 | if(child IsEndOfPat h) | |
| 213 | { | |
| 214 | AbstractNa medVO orph anedChild = this.rem oveChild(c hildName); | |
| 215 | orphanedCh ild.setPar ent(null); | |
| 216 | logger.inf o("'" + or phanedChil d.getName( ) + "' has been dele ted."); | |
| 217 | return orp hanedChild ; | |
| 218 | } | |
| 219 | else | |
| 220 | { | |
| 221 | return c hildWithNa me(childNa me).remove Item(path, childDept h); | |
| 222 | } | |
| 223 | } | |
| 224 | else | |
| 225 | logger .error("Un able to re moveItem(" + path.to String() + ", " + cu rrentDepth .toString( ) + "), na me at curr ent depth is null.") ; | |
| 226 | ||
| 227 | retu rn null; | |
| 228 | } | |
| 229 | ||
| 230 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== == | |
| 231 | // Generated .equals a nd .hashCo de applies to all de rived clas ses, if th e names ar e the same | |
| 232 | // then the instances are the sa me. | |
| 233 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== == | |
| 234 | @O verride | |
| 235 | pu blic int h ashCode() | |
| 236 | { | |
| 237 | fina l int prim e = 31; | |
| 238 | int result = 1 ; | |
| 239 | resu lt = prime * result + ((name = = null) ? 0 : name.h ashCode()) ; | |
| 240 | retu rn result; | |
| 241 | } | |
| 242 | ||
| 243 | @O verride | |
| 244 | pu blic boole an equals( Object obj ) | |
| 245 | { | |
| 246 | if ( this == ob j) return true; | |
| 247 | if ( obj == nul l) return false; | |
| 248 | if ( getClass() != obj.ge tClass()) return fal se; | |
| 249 | Abst ractNamedV O other = (AbstractN amedVO) ob j; | |
| 250 | if ( name == nu ll) | |
| 251 | { | |
| 252 | if (ot her.name ! = null) re turn false ; | |
| 253 | } | |
| 254 | else if (!name .equals(ot her.name)) return fa lse; | |
| 255 | ||
| 256 | // t he parents must be e quals also , all the way back t o the root | |
| 257 | if(t his.getPar ent() == n ull) // i f there is no parent , then we' re at our root | |
| 258 | return true; | |
| 259 | ||
| 260 | retu rn this.ge tParent(). equals(oth er.getPare nt()); | |
| 261 | } | |
| 262 | ||
| 263 | @O verride | |
| 264 | pu blic int c ompareTo(A bstractNam edVO that) | |
| 265 | { | |
| 266 | if(t hat == nul l) | |
| 267 | return -1; | |
| 268 | ||
| 269 | retu rn this.ge tName().co mpareTo(th at.getName ()); | |
| 270 | } | |
| 271 | ||
| 272 | ||
| 273 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.