1 package org.kuali.ole.sys.batch;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.apache.log4j.Logger;
5
6
7
8
9 public class DelimitedFlatFileSpecification extends AbstractFlatFilePrefixSpecificationBase {
10 private static final Logger LOG = Logger.getLogger(DelimitedFlatFileSpecification.class);
11 private String delimiter;
12
13
14
15
16
17 public void parseLineIntoObject(FlatFileObjectSpecification parseSpecification, String lineToParse, Object parseIntoObject, int lineNumber) {
18 String[] lineSegments = StringUtils.splitPreserveAllTokens(lineToParse, delimiter);
19 for (FlatFilePropertySpecification propertySpecification : parseSpecification.getParseProperties()) {
20 try {
21 propertySpecification.setProperty(lineSegments[((DelimitedFlatFilePropertySpecification) propertySpecification).getLineSegmentIndex()], parseIntoObject, lineNumber);
22 }
23 catch (ArrayIndexOutOfBoundsException e) {
24 LOG.debug("Unable to set property " + propertySpecification.getPropertyName() + " since lineSegmentIndex does not exist for line");
25 }
26 }
27 }
28
29
30
31
32
33 public void setDelimiter(String delimiter) {
34 this.delimiter = delimiter;
35 }
36 }