View Javadoc
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 java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.rice.krad.uif.UifConstants;
23  
24  /**
25   * Class used to 
26   * 
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public abstract class ValidDataPatternConstraint extends ValidCharactersConstraint {
30  
31      /**
32       * Warning: This value should NOT be set on this class as the value is built dynamically from the
33       * flags set on the constraint - if this value IS set it will override any automatic generation and only
34       * use that which was set through this method for server side validation
35       * 
36       * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint#setValue(java.lang.String)
37       */
38      @Override
39      public void setValue(String value) {
40          super.setValue(value);
41      }
42  
43      /**
44       * @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint#getValue()
45       */
46      @Override
47      public String getValue() {
48          if(StringUtils.isEmpty(value)){
49              return "^" + getRegexString() + "$";
50          }
51          return value;
52  
53      }
54  
55      /**
56       * This method returns a string representing a regex with characters to match, this string should not
57       * include the start(^) and end($) symbols
58       */
59      abstract protected String getRegexString(); 
60      
61  }