001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.krad.datadictionary.validation.constraint; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.krad.datadictionary.parse.BeanTag; 020import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 021 022/** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025@BeanTag(name = "validDataPatternConstraint") 026public abstract class ValidDataPatternConstraint extends ValidCharactersConstraint { 027 028 /** 029 * Warning: This value should NOT be set on this class as the value is built dynamically from the 030 * flags set on the constraint - if this value IS set it will override any automatic generation and only 031 * use that which was set through this method for server side validation 032 * 033 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint#setValue(java.lang.String) 034 */ 035 @Override 036 public void setValue(String value) { 037 super.setValue(value); 038 } 039 040 /** 041 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint#getValue() 042 */ 043 @Override 044 @BeanTagAttribute(name = "value") 045 public String getValue() { 046 if (StringUtils.isEmpty(value)) { 047 return "^" + getRegexString() + "$"; 048 } 049 return value; 050 051 } 052 053 /** 054 * This method returns a string representing a regex with characters to match, this string should not 055 * include the start(^) and end($) symbols 056 * 057 * @return regular expression 058 */ 059 abstract protected String getRegexString(); 060 061}