Coverage Report - org.kuali.rice.kns.datadictionary.validation.constraint.RegexPatternConstraint
 
Classes in this File Line Coverage Branch Coverage Complexity
RegexPatternConstraint
0%
0/11
0%
0/2
1.333
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.datadictionary.validation.constraint;
 17  
 
 18  
 import javax.xml.bind.annotation.XmlAccessType;
 19  
 import javax.xml.bind.annotation.XmlAccessorType;
 20  
 import javax.xml.bind.annotation.XmlElement;
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 import org.kuali.rice.kns.datadictionary.validation.ValidationPattern.ValidationPatternException;
 24  
 
 25  
 /**
 26  
  * This class is used to set a regex pattern of characters to match. This string should not
 27  
  * include the start(^) and end($) symbols or any length related symbols (*, {0,}, etc)
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  *
 31  
  */
 32  
 @XmlAccessorType(XmlAccessType.FIELD)
 33  0
 public class RegexPatternConstraint extends ValidCharactersPatternConstraint {
 34  
 
 35  
     @XmlElement
 36  
     protected String pattern;
 37  
         
 38  
     @XmlElement
 39  
     private String validationErrorMessageKey;
 40  
         
 41  
         /**
 42  
          * @return the pattern
 43  
          */
 44  
         public String getPattern() {
 45  0
                 return this.pattern;
 46  
         }
 47  
 
 48  
         /**
 49  
          * @param pattern the pattern to set
 50  
          */
 51  
         public void setPattern(String pattern) {
 52  0
                 this.pattern = pattern;
 53  0
         }
 54  
 
 55  
         /**
 56  
          * @return the validationErrorMessageKey
 57  
          */
 58  
         public String getValidationErrorMessageKey() {
 59  0
                 return this.validationErrorMessageKey;
 60  
         }
 61  
 
 62  
         /**
 63  
          * @param validationErrorMessageKey the validationErrorMessageKey to set
 64  
          */
 65  
         public void setValidationErrorMessageKey(String validationErrorMessageKey) {
 66  0
                 this.validationErrorMessageKey = validationErrorMessageKey;
 67  0
         }
 68  
 
 69  
         /**
 70  
          * This overridden method ...
 71  
          * 
 72  
          * @see org.kuali.rice.kns.datadictionary.validation.constraint.BaseConstraint#getLabelKey()
 73  
          */
 74  
         @Override
 75  
         public String getLabelKey() {
 76  0
                 if (StringUtils.isBlank(getValidationErrorMessageKey())) {
 77  0
                         throw new ValidationPatternException("Regex Validation Patterns must have a validation error message key defined");
 78  
                 }
 79  0
                 return getValidationErrorMessageKey();
 80  
         }
 81  
 
 82  
         /**
 83  
          * This overridden method returns the regex pattern as set by the application
 84  
          * 
 85  
          * @see org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersPatternConstraint#getRegexString()
 86  
          */
 87  
         @Override
 88  
         protected String getRegexString() {
 89  0
                 return getPattern();
 90  
         }
 91  
 
 92  
 }