1 package org.kuali.ole.sys.batch;
2
3 import java.util.List;
4
5 import org.springframework.util.StringUtils;
6
7
8
9
10 public abstract class AbstractFlatFilePrefixSpecificationBase extends AbstractFlatFileSpecificationBase {
11 protected List<String> insignificantPrefixes;
12 protected int prefixStartingPosition = 0;
13
14
15
16
17
18
19
20 public Class<?> determineClassForLine(String line) {
21 if (line != null) {
22 if (objectSpecifications != null && !objectSpecifications.isEmpty()) {
23 for (FlatFileObjectSpecification objectSpecification : objectSpecifications) {
24 final FlatFilePrefixObjectSpecification prefixObjectSpecification = (FlatFilePrefixObjectSpecification)objectSpecification;
25 String prefix = prefixObjectSpecification.getLinePrefix();
26 if ((prefix != null) && (line.length() >= (prefixStartingPosition + prefix.length())) &&
27 (line.substring(prefixStartingPosition, prefixStartingPosition + prefix.length()).equals(prefix))) {
28 return objectSpecification.getBusinessObjectClass();
29 }
30 }
31 }
32 if (insignificantPrefixes != null && !insignificantPrefixes.isEmpty()) {
33 for (String insignificantPrefix : insignificantPrefixes) {
34 if ((line.length() >= (prefixStartingPosition + insignificantPrefix.length())) &&
35 line.substring(prefixStartingPosition, prefixStartingPosition + insignificantPrefix.length()).
36 equals(insignificantPrefix)) {
37 return null;
38 }
39 }
40 }
41 return defaultBusinessObjectClass;
42 }
43
44 return null;
45 }
46
47
48
49
50
51 public void setInsignificantPrefixes(List<String> insignificantPrefixes) {
52 this.insignificantPrefixes = insignificantPrefixes;
53 }
54
55
56
57
58
59 public void setPrefixStartingPosition(int prefixStartingPosition) {
60 this.prefixStartingPosition = prefixStartingPosition;
61 }
62 }