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 PosterSortComparator implements Comparator<String> {
25 OriginEntryFieldUtil oefu = new OriginEntryFieldUtil();
26 Map<String, Integer> pMap = oefu.getFieldBeginningPositionMap();
27
28 private class Range {
29 public Range( int start, int end ) { this.start = start; this.end = end; }
30 public int start;
31 public int end;
32 }
33
34 Range[] compareRanges;
35 {
36 compareRanges = new Range[2];
37 compareRanges[0] = new Range(pMap.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(OLEPropertyConstants.TRANSACTION_ENTRY_SEQUENCE_NUMBER));
38 compareRanges[1] = new Range(pMap.get(OLEPropertyConstants.PROJECT_CODE), pMap.get(OLEPropertyConstants.REFERENCE_FIN_DOCUMENT_TYPE_CODE));
39 }
40
41 public int compare(String string1, String string2) {
42 StringBuilder sb1 = new StringBuilder();
43 sb1.append(string1.substring(compareRanges[0].start,compareRanges[0].end));
44 sb1.append(string1.substring(compareRanges[1].start,compareRanges[1].end));
45
46 StringBuilder sb2 = new StringBuilder();
47 sb2.append(string2.substring(compareRanges[0].start,compareRanges[0].end));
48 sb2.append(string2.substring(compareRanges[1].start,compareRanges[1].end));
49
50 return sb1.toString().compareTo(sb2.toString());
51 }
52 }