1 /*
2 * Copyright 2011 The Kuali Foundation.
3 *
4 * Licensed under the Educational Community License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl1.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.sys.batch;
17
18 import java.util.regex.Pattern;
19
20 import org.apache.commons.lang.StringUtils;
21
22 /**
23 * FlatFileObjectSpecification for files which match lines to objects via regular expression patterns
24 */
25 public class FlatFileRegexObjectSpecification extends AbstractFlatFileObjectSpecification {
26 protected String regexPattern;
27 protected Pattern pattern;
28
29 /**
30 * @return the regular expression pattern to match lines with
31 */
32 public String getRegexPattern() {
33 return regexPattern;
34 }
35 /**
36 * Sets a regex pattern to match lines with
37 * @param regexPattern the regular expression pattern to match lines with
38 */
39 public void setRegexPattern(String regexPattern) {
40 this.regexPattern = regexPattern;
41 }
42 /**
43 * @return the Pattern to match lines for this object specification
44 */
45 public Pattern getPattern() {
46 if (pattern == null && !StringUtils.isBlank(regexPattern)) {
47 pattern = Pattern.compile(regexPattern);
48 }
49 return pattern;
50 }
51
52
53 }