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