Produced by Araxis Merge on 12/5/2017 12:06:39 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\DicomCodecImpl\main\src\java\gov\va\med\imaging\dicom | DataElement.java | Mon Dec 4 21:34:32 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\DicomCodecImpl\main\src\java\gov\va\med\imaging\dicom | DataElement.java | Mon Dec 4 21:59:18 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 738 |
| 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 | package go v.va.med.i maging.dic om; | |
| 2 | ||
| 3 | import gov .va.med.im aging.dico m.dictiona ry.DicomDi ctionaryEn try; | |
| 4 | import gov .va.med.im aging.dico m.exceptio ns.DicomFo rmatExcept ion; | |
| 5 | import gov .va.med.im aging.dico m.exceptio ns.ValueRe presentati onInterpre tationExce ption; | |
| 6 | import gov .va.med.im aging.dico m.exceptio ns.ValueRe presentati onValueLen gthExceede dException ; | |
| 7 | import gov .va.med.im aging.dico m.exceptio ns.ValueRe presentati onValueLen gthInsuffi cientExcep tion; | |
| 8 | ||
| 9 | import org .apache.lo gging.log4 j.LogManag er; | |
| 10 | import org .apache.lo gging.log4 j.Logger; | |
| 11 | ||
| 12 | /** | |
| 13 | * From th e DICOM Sp ecificatio n, Part 5: | |
| 14 | * | |
| 15 | * A Data Element is made up o f fields. Three fiel ds are com mon to all three Dat a Element structures ; | |
| 16 | * these a re the Dat a Element Tag, Value Length, a nd Value F ield. | |
| 17 | * A fourt h field, V alue Repre sentation, is only p resent in the two Ex plicit VR Data Eleme nt structu res. | |
| 18 | * The Dat a Element structures are defin ed in Sect ions 7.1.2 . and 7.1. 3. The def initions o f the fiel ds are: | |
| 19 | * | |
| 20 | * Data El ement Tag: An ordere d pair of 16-bit uns igned inte gers repre senting th e Group Nu mber follo wed by Ele ment Numbe r. | |
| 21 | * | |
| 22 | * Value R epresentat ion: A two -byte char acter stri ng contain ing the VR of the Da ta Element . | |
| 23 | * The VR for a give n Data Ele ment Tag s hall be as defined b y the Data Dictionar y as speci fied in PS 3.6. | |
| 24 | * The two character VR shall be encoded using cha racters fr om the DIC OM default character set. | |
| 25 | * | |
| 26 | * Value L ength: | |
| 27 | * Either: | |
| 28 | * - a 16 or 32-bit (dependent on VR and whether V R is expli cit or imp licit) uns igned inte ger | |
| 29 | * contain ing the Ex plicit Len gth of the Value Fie ld as the number of bytes (eve n) that ma ke up the Value. | |
| 30 | * It does not inclu de the len gth of the Data Elem ent Tag, V alue Repre sentation, and Value Length Fi elds. | |
| 31 | * - a 32- bit Length Field set to Undefi ned Length (FFFFFFFF H). Undefi ned Length s may be u sed for Da ta Element s | |
| 32 | * having the Value Representa tion (VR) Sequence o f Items (S Q) and Unk nown (UN). | |
| 33 | * For Dat a Elements with Valu e Represen tation OW or OB Unde fined Leng th may be used depen ding on th e negotiat ed | |
| 34 | * Transfe r Syntax ( see Sectio n 10 and A nnex A). | |
| 35 | * | |
| 36 | * A unit of informa tion as de fined by a single en try in the data dict ionary. | |
| 37 | * An enco ded Inform ation Obje ct Definit ion (IOD) Attribute that is co mposed of, at a mini mum, | |
| 38 | * three f ields: a D ata Elemen t Tag, a V alue Lengt h, and a V alue Field . For some specific | |
| 39 | * Transfe r Syntaxes , a Data E lement als o contains a VR Fiel d where th e Value Re presentati on of | |
| 40 | * that Da ta Element is specif ied explic itly. | |
| 41 | * | |
| 42 | * REPEATI NG GROUP: Standard D ata Elemen ts within a particul ar range o f Group Nu mbers wher e elements | |
| 43 | * that ha ve identic al Element Numbers h ave the sa me meaning within ea ch Group ( and the sa me VR, VM, | |
| 44 | * and Dat a Element Type). Rep eating Gro ups shall only exist for Curve s and Over lay Planes (Group Nu mbers | |
| 45 | * (50xx,e eee) and ( 60xx,eeee) , respecti vely) and are a remn ant of ver sions of t his standa rd prior t o V3.0. | |
| 46 | * | |
| 47 | * RETIRED DATA ELEM ENT: A Dat a Element that is un supported beginning with Versi on 3.0 of this stand ard. | |
| 48 | * Impleme ntations m ay continu e to suppo rt Retired Data Elem ents for t he purpose of backwa rd compati bility | |
| 49 | * with ve rsions pri or to V3.0 , but this is not a requiremen t of this version of the stand ard. | |
| 50 | * | |
| 51 | * A Data Element sh all have o ne of thre e structur es. | |
| 52 | * Two of these stru ctures con tain the V R of the D ata Elemen t (Explici t VR) but differ in the way th eir | |
| 53 | * lengths are expre ssed, whil e the othe r structur e does not contain t he VR (Imp licit VR). | |
| 54 | * All thr ee structu res contai n the Data Element T ag, Value Length and Value for the Data Element. S ee Figure 7.1-1. | |
| 55 | * Implici t and Expl icit VR Da ta Element s shall no t coexist in a Data Set and Da ta Sets ne sted withi n it | |
| 56 | * (see Se ction 7.5) . Whether a Data Set uses Expl icit or Im plicit VR, among oth er charact eristics, | |
| 57 | * is dete rmined by the negoti ated Trans fer Syntax (see Sect ion 10 and Annex A). | |
| 58 | * Note: V Rs are not contained in Data E lements wh en using D ICOM Defau lt Transfe r Syntax ( DICOM Impl icit VR | |
| 59 | * Little Endian Tra nsfer Synt ax). | |
| 60 | * | |
| 61 | * This im plementati on include s a refere nce to a D ataDiction aryEntry, which cont ains the i mplicit VR . | |
| 62 | * | |
| 63 | * The met hods equal s(), hashC ode() and compareTo( ) are all consistent . | |
| 64 | * The met hods equal s(), hashC ode() and compareTo( ) are all sensitive only to th e dataElem entTag mem ber. | |
| 65 | * | |
| 66 | * | |
| 67 | * @author
|
|
| 68 | * | |
| 69 | */ | |
| 70 | public abs tract clas s DataElem ent<T> | |
| 71 | implements Comparabl e<DataElem ent<T>> | |
| 72 | { | |
| 73 | pr ivate fina l DataElem entFactory instantia tingFactor y; // ret ain a refe rence to o ur factory because w e may need it to par se our own data | |
| 74 | pr ivate fina l DataElem entTag dat aElementTa g; // the a ctual grou p and elem ent number s | |
| 75 | pr ivate fina l DicomDic tionaryEnt ry diction aryEntry; // null for explic it VR, not -null for implicit V R | |
| 76 | pr ivate fina l ValueRep resentatio n[] explic itVRField; // not null for explicit V R, null fo r implicit VR | |
| 77 | pr ivate fina l long val ueLength; // will alwa ys be pres ent, 16 or 32 bit un signed, mu st be stor ed as long | |
| 78 | pr ivate byte [] rawValu e; // | |
| 79 | pu blic final static lo ng INDETER MINATE_LEN GTH = -1L; | |
| 80 | ||
| 81 | pr ivate fina l Logger l ogger = Lo gManager.g etLogger(t his.getCla ss().getNa me()); | |
| 82 | ||
| 83 | /* * | |
| 84 | * The const ructor of DataElemen t instance s using ex plicit VR. | |
| 85 | * This shou ld be call ed only fr om a DataE lementFact ory. | |
| 86 | * | |
| 87 | * @param da taElementT ag | |
| 88 | * @param ex plicitVRFi eld | |
| 89 | * @param va lueLength | |
| 90 | * @param va lue | |
| 91 | * / | |
| 92 | pr otected Da taElement( | |
| 93 | DataEl ementFacto ry instant iatingFact ory, | |
| 94 | DataEl ementTag d ataElement Tag, | |
| 95 | ValueR epresentat ion explic itVRField, | |
| 96 | long v alueLength , | |
| 97 | byte[] value) | |
| 98 | th rows Dicom FormatExce ption | |
| 99 | { | |
| 100 | if(e xplicitVRF ield == nu ll) | |
| 101 | throw new Illega lArgumentE xception(" Explicit V R Field mu st be spec ified when encoding specifies that expli cit VR is being used ."); | |
| 102 | ||
| 103 | this .instantia tingFactor y = instan tiatingFac tory; | |
| 104 | this .dataEleme ntTag = da taElementT ag; | |
| 105 | this .dictionar yEntry = n ull; | |
| 106 | this .explicitV RField = n ew ValueRe presentati on[]{expli citVRField }; | |
| 107 | this .valueLeng th = value Length; | |
| 108 | this .rawValue = value; | |
| 109 | ||
| 110 | try{ validateLe ngthValues ();} | |
| 111 | catc h(DicomFor matExcepti on dfX){lo gger.warn( "DICOM com pliance ex ception-" + dfX.getM essage() + "'.");} | |
| 112 | ||
| 113 | pars eRawValue( ); | |
| 114 | } | |
| 115 | ||
| 116 | /* * | |
| 117 | * The const ructor of DataElemen t instance s using im plicit VR. | |
| 118 | * This shou ld be call ed only fr om a DataE lementFact ory. | |
| 119 | * | |
| 120 | * @param da taElementT ag | |
| 121 | * @param di ctionaryEn try | |
| 122 | * @param va lueLength | |
| 123 | * @param va lue | |
| 124 | * @param da taElementF actory | |
| 125 | * / | |
| 126 | pr otected Da taElement( | |
| 127 | Data ElementFac tory insta ntiatingFa ctory, | |
| 128 | Data ElementTag dataEleme ntTag, | |
| 129 | Dico mDictionar yEntry dic tionaryEnt ry, | |
| 130 | long valueLeng th, | |
| 131 | byte [] value) | |
| 132 | th rows Dicom FormatExce ption | |
| 133 | { | |
| 134 | if(d ictionaryE ntry == nu ll) | |
| 135 | throw new Illega lArgumentE xception(" Dictionary Entry fie ld must be specified when enco ding speci fies that implicit V R is being used."); | |
| 136 | ||
| 137 | this .instantia tingFactor y = instan tiatingFac tory; | |
| 138 | this.dat aElementTa g = dataEl ementTag; | |
| 139 | this.dic tionaryEnt ry = dicti onaryEntry ; | |
| 140 | this.val ueLength = valueLeng th; | |
| 141 | this.raw Value = va lue; | |
| 142 | this .explicitV RField = n ull; | |
| 143 | ||
| 144 | try{ validateLe ngthValues ();} | |
| 145 | catc h(DicomFor matExcepti on dfX){lo gger.warn( "DICOM com pliance ex ception-" + dfX.getM essage() + "'.");} | |
| 146 | ||
| 147 | pars eRawValue( ); | |
| 148 | } | |
| 149 | ||
| 150 | /* * | |
| 151 | * Do basic validation of the le ngth field and the l ength of t he value a gainst the | |
| 152 | * specified values. | |
| 153 | * | |
| 154 | * @throws V alueRepres entationIn terpretati onExceptio n | |
| 155 | * / | |
| 156 | pr otected vo id validat eLengthVal ues() | |
| 157 | th rows Value Representa tionInterp retationEx ception | |
| 158 | { | |
| 159 | if(g etValueLen gth() < ge tValueRepr esentation ()[0].getM inLengthOf Value() && | |
| 160 | !getValu eRepresent ation()[0] .isAllowUn definedLen gth()) | |
| 161 | throw new ValueR epresentat ionValueLe ngthInsuff icientExce ption( | |
| 162 | "Element '" + getD ataElement Tag() + "' " + getVa lueReprese ntation()[ 0].toStrin g() + | |
| 163 | " length of " + va lueLength + " is out side range of [" + | |
| 164 | getValue Representa tion()[0]. getMinLeng thOfValue( ) + "-" + | |
| 165 | getValue Representa tion()[0]. getMaxLeng thOfValue( ) + "]."); | |
| 166 | ||
| 167 | if(g etValueLen gth() > ge tValueRepr esentation ()[0].getM axLengthOf Value() && | |
| 168 | !getValu eRepresent ation()[0] .isAllowUn definedLen gth()) | |
| 169 | throw new ValueR epresentat ionValueLe ngthExceed edExceptio n( | |
| 170 | "Element '" + getD ataElement Tag() + "' " + getVa lueReprese ntation()[ 0].toStrin g() + | |
| 171 | " length of " + va lueLength + " is out side range of [" + | |
| 172 | getValue Representa tion()[0]. getMinLeng thOfValue( ) + "-" + | |
| 173 | getValue Representa tion()[0]. getMaxLeng thOfValue( ) + "]."); | |
| 174 | ||
| 175 | if(g etRawValue () == null ) | |
| 176 | return ; | |
| 177 | ||
| 178 | if(g etRawValue ().length < getValue Representa tion()[0]. getMinLeng thOfValue( ) && | |
| 179 | !getValu eRepresent ation()[0] .isAllowUn definedLen gth()) | |
| 180 | throw new ValueR epresentat ionValueLe ngthInsuff icientExce ption( | |
| 181 | "Element '" + getD ataElement Tag() + "' " + getVa lueReprese ntation()[ 0].toStrin g() + | |
| 182 | " raw va lue length of " + ge tRawValue( ).length + " is outs ide range of [" + | |
| 183 | getValue Representa tion()[0]. getMinLeng thOfValue( ) + "-" + | |
| 184 | getValue Representa tion()[0]. getMaxLeng thOfValue( ) + "]."); | |
| 185 | ||
| 186 | if(g etValueLen gth() > ge tRawValue( ).length & & | |
| 187 | !getValu eRepresent ation()[0] .isAllowUn definedLen gth()) | |
| 188 | throw new ValueR epresentat ionValueLe ngthExceed edExceptio n( | |
| 189 | "Element '" + getD ataElement Tag() + "' " + getVa lueReprese ntation()[ 0].toStrin g() + | |
| 190 | " raw va lue length of " + ra wValue.len gth + " is outside r ange of [" + | |
| 191 | getValue Representa tion()[0]. getMinLeng thOfValue( ) + "-" + | |
| 192 | getValue Representa tion()[0]. getMaxLeng thOfValue( ) + "]."); | |
| 193 | } | |
| 194 | ||
| 195 | /* * | |
| 196 | * Called fr om the con structor, | |
| 197 | * The imple menting cl ass must t ake the ra w value as a byte ar ray and cr eate a imp lememntati on | |
| 198 | * specific representa tion from it. | |
| 199 | * The resul ting value must be m ade availa ble throug h the getV alue() met hod. | |
| 200 | * | |
| 201 | * / | |
| 202 | pr otected ab stract voi d parseRaw Value() | |
| 203 | th rows Dicom FormatExce ption; | |
| 204 | ||
| 205 | /** | |
| 206 | * Get the value of this f ield accor ding to th e interpre tation of the | |
| 207 | * ass ociated Va lueReprese ntation | |
| 208 | * @re turn | |
| 209 | * @th rows Value Representa tionInterp retationEx ception | |
| 210 | */ | |
| 211 | public abstract T getValue () | |
| 212 | throws ValueRepr esentation Interpreta tionExcept ion; | |
| 213 | ||
| 214 | /** | |
| 215 | * | |
| 216 | * @re turn | |
| 217 | */ | |
| 218 | pr otected Lo gger getLo gger() | |
| 219 | { | |
| 220 | re turn logge r; | |
| 221 | } | |
| 222 | ||
| 223 | /* * | |
| 224 | * | |
| 225 | * @return | |
| 226 | * / | |
| 227 | pr otected Da taElementF actory get Instantiat ingFactory () | |
| 228 | { | |
| 229 | re turn insta ntiatingFa ctory; | |
| 230 | } | |
| 231 | ||
| 232 | /* * | |
| 233 | * @re turn the t ag | |
| 234 | */ | |
| 235 | public DataEleme ntTag getD ataElement Tag() | |
| 236 | { | |
| 237 | re turn dataE lementTag; | |
| 238 | } | |
| 239 | ||
| 240 | /* * | |
| 241 | * Will alwa ys return a non-null value. I f using ex plicit VR then this | |
| 242 | * will retu rn a singl e element array that contains the VR spe cified | |
| 243 | * when this instance was create d. | |
| 244 | * If using implicit V R then thi s will ret urn an arr ay of VR m apped to | |
| 245 | * the entry in the Di comDiction ary that t he element tag value s were | |
| 246 | * mapped to when this instance was create d. | |
| 247 | * | |
| 248 | * @re turn the V alueRepres entation a rray | |
| 249 | */ | |
| 250 | public ValueRepr esentation [] getValu eRepresent ation() | |
| 251 | { | |
| 252 | if (isExplici tVR()) | |
| 253 | retu rn this.ex plicitVRFi eld; | |
| 254 | el se | |
| 255 | retu rn this.ge tDictionar yEntry().g etVr(); | |
| 256 | } | |
| 257 | ||
| 258 | public boolean i sExplicitV R() | |
| 259 | { | |
| 260 | re turn this. explicitVR Field != n ull; | |
| 261 | } | |
| 262 | ||
| 263 | /* * | |
| 264 | * Will retu rn null if isExplici tVR() is t rue. | |
| 265 | * | |
| 266 | * @re turn the d ictionaryE ntry | |
| 267 | */ | |
| 268 | public DicomDict ionaryEntr y getDicti onaryEntry () | |
| 269 | { | |
| 270 | re turn dicti onaryEntry ; | |
| 271 | } | |
| 272 | ||
| 273 | ||
| 274 | /* * | |
| 275 | * Will retu rn null if isExplici tVR() is f alse. | |
| 276 | * | |
| 277 | * @re turn the e xplicitVRF ield | |
| 278 | */ | |
| 279 | public ValueRepr esentation [] getExpl icitVRFiel d() | |
| 280 | { | |
| 281 | re turn expli citVRField ; | |
| 282 | } | |
| 283 | ||
| 284 | ||
| 285 | /* * | |
| 286 | * @re turn the v alue | |
| 287 | */ | |
| 288 | public byte[] ge tRawValue( ) | |
| 289 | { | |
| 290 | re turn rawVa lue; | |
| 291 | } | |
| 292 | ||
| 293 | /** | |
| 294 | * In some cases the deriv ed classes use the r aw value a s the inte rpreted | |
| 295 | * val ue, option ally havin g manipula ted the co ntents. | |
| 296 | * @pa ram rawVal ue | |
| 297 | */ | |
| 298 | protec ted void s etRawValue (byte[] ra wValue) | |
| 299 | { | |
| 300 | th is.rawValu e = rawVal ue; | |
| 301 | } | |
| 302 | ||
| 303 | /* * | |
| 304 | * @re turn the v alueLength | |
| 305 | */ | |
| 306 | public long getV alueLength () | |
| 307 | { | |
| 308 | re turn value Length; | |
| 309 | } | |
| 310 | ||
| 311 | /* * | |
| 312 | * The natur al orderin g of this class is t he natural ordering of the Dat aElementTa g within t his class. | |
| 313 | * | |
| 314 | * @se e java.lan g.Comparab le#compare To(java.la ng.Object) | |
| 315 | */ | |
| 316 | @Overr ide | |
| 317 | public int compa reTo(DataE lement<T> that) | |
| 318 | { | |
| 319 | re turn this. dataElemen tTag.compa reTo(that. dataElemen tTag); | |
| 320 | } | |
| 321 | ||
| 322 | @O verride | |
| 323 | public int hashC ode() | |
| 324 | { | |
| 325 | final in t prime = 31; | |
| 326 | int resu lt = 1; | |
| 327 | result = prime * r esult + (( dataElemen tTag == nu ll) ? 0 : dataElemen tTag.hashC ode()); | |
| 328 | return r esult; | |
| 329 | } | |
| 330 | ||
| 331 | @O verride | |
| 332 | public boolean e quals(Obje ct obj) | |
| 333 | { | |
| 334 | if (this == obj) | |
| 335 | return tru e; | |
| 336 | if (obj == null) | |
| 337 | return fal se; | |
| 338 | if (getC lass() != obj.getCla ss()) | |
| 339 | return fal se; | |
| 340 | final Da taElement other = (D ataElement ) obj; | |
| 341 | if (data ElementTag == null) | |
| 342 | { | |
| 343 | if (other. dataElemen tTag != nu ll) | |
| 344 | re turn false ; | |
| 345 | } else i f (!dataEl ementTag.e quals(othe r.dataElem entTag)) | |
| 346 | return fal se; | |
| 347 | return t rue; | |
| 348 | } | |
| 349 | ||
| 350 | // ========= ========== ========== ========== ========== ========== ========== ========== ========= | |
| 351 | // Helper Me thods to d o various, usually b it or byte level, ma nipulation s | |
| 352 | // ========= ========== ========== ========== ========== ========== ========== ========== ========= | |
| 353 | protec ted static String tr ansformVal ueToString RemoveNull s(byte[] r awValue, l ong valueL ength) | |
| 354 | { | |
| 355 | for (int j = 0 ; j < valu eLength; j ++) | |
| 356 | if (ra wValue[j] == 0) rawV alue[j] = 20; | |
| 357 | retu rn new Str ing(rawVal ue); | |
| 358 | } | |
| 359 | ||
| 360 | protec ted String getRawVal ueCharacte rRepresent ation() | |
| 361 | { | |
| 362 | St ringBuffer sb = new StringBuff er(); | |
| 363 | ||
| 364 | by te[] raw = getRawVal ue(); | |
| 365 | if (raw != nu ll) | |
| 366 | for( byte c : g etRawValue ()) | |
| 367 | sb.app end("0x" + Integer.t oHexString (c) + " ") ; | |
| 368 | re turn sb.to String(); | |
| 369 | } | |
| 370 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.