1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.batch;
17
18 import java.util.Comparator;
19 import java.util.Map;
20
21 import org.kuali.ole.gl.businessobject.OriginEntryFieldUtil;
22 import org.kuali.ole.sys.OLEPropertyConstants;
23
24 public class DemergerSortComparator implements Comparator<String> {
25
26 OriginEntryFieldUtil oefu = new OriginEntryFieldUtil();
27 Map<String, Integer> pMap = oefu.getFieldBeginningPositionMap();
28
29 private class Range {
30 public Range( int start, int end ) { this.start = start; this.end = end; }
31 public int start;
32 public int end;
33 }
34
35 Range[] compareRanges;
36 {
37 compareRanges = new Range[2];
38 compareRanges[0] = new Range(pMap.get(OLEPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE), pMap.get(OLEPropertyConstants.TRANSACTION_ENTRY_SEQUENCE_NUMBER));
39 compareRanges[1] = new Range(pMap.get(OLEPropertyConstants.TRANSACTION_ENTRY_SEQUENCE_NUMBER), pMap.get(OLEPropertyConstants.TRANSACTION_LEDGER_ENTRY_DESC));
40 }
41
42 public int compare(String string1, String string2) {
43 StringBuilder sb1 = new StringBuilder();
44 sb1.append(string1.substring(compareRanges[0].start,compareRanges[0].end));
45 sb1.append(string1.substring(compareRanges[1].start,compareRanges[1].end));
46
47 StringBuilder sb2 = new StringBuilder();
48 sb2.append(string2.substring(compareRanges[0].start,compareRanges[0].end));
49 sb2.append(string2.substring(compareRanges[1].start,compareRanges[1].end));
50
51 return sb1.toString().compareTo(sb2.toString());
52 }
53 }