Produced by Araxis Merge on 6/9/2017 3:49:57 PM Eastern 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:49:57 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-common\src\main\java\gov\va\nvap\common\sort | BubbleSortListMap.java | Fri Apr 21 20:03:26 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 130 |
| 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.nvap. common.sor t; | |||||
| 2 | ||||||
| 3 | import gov .va.nvap.c ommon.vali dation.Nul lChecker; | |||||
| 4 | ||||||
| 5 | import jav a.security .InvalidPa rameterExc eption; | |||||
| 6 | import jav a.util.Arr ayList; | |||||
| 7 | import jav a.util.Lis t; | |||||
| 8 | import jav a.util.Map ; | |||||
| 9 | ||||||
| 10 | /** | |||||
| 11 | * @author Stephen T Miller | |||||
| 12 | */ | |||||
| 13 | public cla ss BubbleS ortListMap { | |||||
| 14 | ||||||
| 15 | pu blic Bubbl eSortListM ap() { | |||||
| 16 | ||||||
| 17 | } | |||||
| 18 | ||||||
| 19 | pr ivate List <Map<Strin g, Object> > reverseO rder( | |||||
| 20 | final List<Map<S tring, Obj ect>> reve rseMe) { | |||||
| 21 | List <Map<Strin g, Object> > correctL ist = new ArrayList< Map<String , Object>> (); | |||||
| 22 | fina l int size = reverse Me.size(); | |||||
| 23 | if ( size > 0) { | |||||
| 24 | for (i nt i = siz e - 1; i > = 0; i--) { | |||||
| 25 | correctL ist.add(re verseMe.ge t(i)); | |||||
| 26 | } | |||||
| 27 | } el se { | |||||
| 28 | correc tList = re verseMe; | |||||
| 29 | } | |||||
| 30 | retu rn correct List; | |||||
| 31 | } | |||||
| 32 | ||||||
| 33 | pr ivate List <Map<Strin g, Object> > sortByAl pha( | |||||
| 34 | final List<Map<S tring, Obj ect>> list , final St ring sortC olumn) { | |||||
| 35 | Map< String, Ob ject> temp ; | |||||
| 36 | bool ean wasSwi tch = true ; | |||||
| 37 | whil e (wasSwit ch) { | |||||
| 38 | wasSwi tch = fals e; | |||||
| 39 | for (i nt i = 0; i < list.s ize() - 1; i++) { | |||||
| 40 | String a ; | |||||
| 41 | String b ; | |||||
| 42 | final St ring nullC heckA = (S tring) lis t.get(i).g et(sortCol umn); | |||||
| 43 | final St ring nullC heckB = (S tring) lis t.get(i + 1).get( | |||||
| 44 | so rtColumn); | |||||
| 45 | if ((nul lCheckA == null) && (nullCheck B == null) ) { | |||||
| 46 | throw new RuntimeExc eption( | |||||
| 47 | "Nul lpointers -> Wrong s ort column : " + sort Column); | |||||
| 48 | } | |||||
| 49 | if (Null Checker.is NullOrEmpt y(nullChec kA)) { | |||||
| 50 | a = ""; // TODO: May need refa ctoring. C hange from non delim inated spa ce (alt+25 5) | |||||
| 51 | } else { | |||||
| 52 | a = nullCh eckA; | |||||
| 53 | } | |||||
| 54 | if (Null Checker.is NullOrEmpt y(nullChec kB)) { | |||||
| 55 | b = ""; // TODO: May need refa ctoring. C hange from non delim inated spa ce (alt+25 5) | |||||
| 56 | } else { | |||||
| 57 | b = nullCh eckB; | |||||
| 58 | } | |||||
| 59 | if (a.co mpareToIgn oreCase(b) > 0) { | |||||
| 60 | // switch em | |||||
| 61 | temp = lis t.get(i); | |||||
| 62 | list.remov e(i); | |||||
| 63 | list.add(i + 1, temp ); | |||||
| 64 | wasSwitch = true; | |||||
| 65 | } | |||||
| 66 | } | |||||
| 67 | } | |||||
| 68 | retu rn list; | |||||
| 69 | } | |||||
| 70 | ||||||
| 71 | pu blic List< Map<String , Object>> sortByCol umn( | |||||
| 72 | final List<Map<S tring, Obj ect>> unso rted, fina l String s ortColumn, | |||||
| 73 | final boolean as cending) { | |||||
| 74 | List <Map<Strin g, Object> > sorted = null; | |||||
| 75 | ||||||
| 76 | if (unsorted == null || unsorted. size() < 2 ) { | |||||
| 77 | return u nsorted; | |||||
| 78 | } | |||||
| 79 | ||||||
| 80 | if ( unsorted.s ize() > 1) { | |||||
| 81 | if (so rtColumn.e qualsIgnor eCase("tot al") || is ColumnNume ric(unsort ed, sortCo lumn)) { | |||||
| 82 | // sort by number | |||||
| 83 | sorted = this.sort ByNumber(u nsorted, s ortColumn) ; | |||||
| 84 | // } els e if (sort Column.equ alsIgnoreC ase("audit Time")) { | |||||
| 85 | // sort by date | |||||
| 86 | // sorte d = sortBy Date(unsor ted); | |||||
| 87 | } else { | |||||
| 88 | // sort by alphabe tical | |||||
| 89 | sort ed = this. sortByAlph a(unsorted , sortColu mn); | |||||
| 90 | } | |||||
| 91 | } | |||||
| 92 | if ( !ascending ) { | |||||
| 93 | sorted = this.re verseOrder (sorted); | |||||
| 94 | } | |||||
| 95 | retu rn sorted; | |||||
| 96 | } | |||||
| 97 | ||||||
| 98 | privat e boolean isColumnNu meric(fina l List<Map <String, O bject>> li st, final String sor tColumn) { | |||||
| 99 | Ma p<String, Object> ro w = list.g et(0); | |||||
| 100 | ||||||
| 101 | fo r (Map.Ent ry pair : row.entryS et()) { | |||||
| 102 | if (sort Column.equ als(pair.g etKey())) { | |||||
| 103 | retu rn pair.ge tValue() i nstanceof Long || pa ir.getValu e() instan ceof Integ er; | |||||
| 104 | } | |||||
| 105 | } | |||||
| 106 | ||||||
| 107 | re turn false ; | |||||
| 108 | } | |||||
| 109 | ||||||
| 110 | pr ivate List <Map<Strin g, Object> > sortByNu mber( | |||||
| 111 | final List<Map<S tring, Obj ect>> list , final St ring sortC olumn) { | |||||
| 112 | bool ean wasSwi tch = true ; | |||||
| 113 | Map< String, Ob ject> temp ; | |||||
| 114 | whil e (wasSwit ch) { | |||||
| 115 | wasSwi tch = fals e; | |||||
| 116 | for (i nt i = 0; i < list.s ize() - 1; i++) { | |||||
| 117 | final Lo ng a = (Lo ng) list.g et(i).get( sortColumn ); | |||||
| 118 | final Lo ng b = (Lo ng) list.g et(i + 1). get(sortCo lumn); | |||||
| 119 | if (a.co mpareTo(b) > 0) { | |||||
| 120 | // switch em | |||||
| 121 | temp = lis t.get(i); | |||||
| 122 | list.remov e(i); | |||||
| 123 | list.add(i + 1, temp ); | |||||
| 124 | wasSwitch = true; | |||||
| 125 | } | |||||
| 126 | } | |||||
| 127 | } | |||||
| 128 | retu rn list; | |||||
| 129 | } | |||||
| 130 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.