001/* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 1.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl1.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.sys.batch; 017 018import java.util.regex.Pattern; 019 020import org.apache.commons.lang.StringUtils; 021 022/** 023 * FlatFileObjectSpecification for files which match lines to objects via regular expression patterns 024 */ 025public class FlatFileRegexObjectSpecification extends AbstractFlatFileObjectSpecification { 026 protected String regexPattern; 027 protected Pattern pattern; 028 029 /** 030 * @return the regular expression pattern to match lines with 031 */ 032 public String getRegexPattern() { 033 return regexPattern; 034 } 035 /** 036 * Sets a regex pattern to match lines with 037 * @param regexPattern the regular expression pattern to match lines with 038 */ 039 public void setRegexPattern(String regexPattern) { 040 this.regexPattern = regexPattern; 041 } 042 /** 043 * @return the Pattern to match lines for this object specification 044 */ 045 public Pattern getPattern() { 046 if (pattern == null && !StringUtils.isBlank(regexPattern)) { 047 pattern = Pattern.compile(regexPattern); 048 } 049 return pattern; 050 } 051 052 053}