1 /** 2 * Copyright 2005-2016 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.krad.datadictionary.validation.constraint; 17 18 import org.apache.commons.lang.StringUtils; 19 import org.kuali.rice.krad.datadictionary.parse.BeanTag; 20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 21 22 /** 23 * This abstract class extends from ValidCharactersConstraint. Its subclasses contain a regex that 24 * is built out with flags that can be turned off and on. All ValidCharactersPatternConstraints 25 * allow a certain set of characters to be repeated multiple times 26 * 27 * @author Kuali Rice Team (rice.collab@kuali.org) 28 */ 29 @BeanTag(name = "validCharactersPatternContraint-bean") 30 public abstract class ValidCharactersPatternConstraint extends ValidCharactersConstraint { 31 /** 32 * Warning: This value should NOT be set on ValidCharactersPatternConstraints as the value is 33 * built dynamically from the flags set on the constraint - if this value IS set it will 34 * override any automatic generation and only use that which was set through this method for 35 * server side validation 36 * 37 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint#setValue(java.lang.String) 38 */ 39 @Override 40 public void setValue(String value) { 41 super.setValue(value); 42 } 43 44 /** 45 * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint#getValue() 46 */ 47 @Override 48 @BeanTagAttribute(name = "value") 49 public String getValue() { 50 if (StringUtils.isEmpty(value)) { 51 return "^" + getRegexString() + "*$"; 52 } 53 return value; 54 55 } 56 57 /** 58 * This method returns a string representing a regex with characters to match, this string 59 * should not include the start(^) and end($) symbols or any length related symbols (*, {0,}, 60 * etc) 61 * 62 * @return 63 */ 64 abstract protected String getRegexString(); 65 66 }