Coverage Report - org.kuali.rice.kns.datadictionary.validation.charlevel.UTF8AnyCharacterValidationPattern
 
Classes in this File Line Coverage Branch Coverage Complexity
UTF8AnyCharacterValidationPattern
0%
0/18
0%
0/6
1.8
 
 1  
 /*
 2  
  * Copyright 2007 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.charlevel;
 17  
 
 18  
 import org.kuali.rice.kns.datadictionary.exporter.ExportMap;
 19  
 import org.kuali.rice.kns.datadictionary.validation.CharacterLevelValidationPattern;
 20  
 import org.kuali.rice.kns.util.KNSConstants;
 21  
 
 22  
 /**
 23  
  * Pattern for matching any UTF-8 character with whitespace option
 24  
  * 
 25  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 26  
  *
 27  
  */
 28  0
 public class UTF8AnyCharacterValidationPattern extends CharacterLevelValidationPattern{
 29  
         
 30  0
     protected boolean allowWhitespace = false;
 31  
 
 32  
 
 33  
     /**
 34  
      * @return allowWhitespace
 35  
      */
 36  
     public boolean getAllowWhitespace() {
 37  0
         return allowWhitespace;
 38  
     }
 39  
 
 40  
     /**
 41  
      * @param allowWhitespace
 42  
      */
 43  
     public void setAllowWhitespace(boolean allowWhitespace) {
 44  0
         this.allowWhitespace = allowWhitespace;
 45  0
     }
 46  
 
 47  
         /**
 48  
          * This overridden method ...
 49  
          * 
 50  
          * @see org.kuali.rice.kns.datadictionary.validation.CharacterLevelValidationPattern#extendExportMap(org.kuali.rice.kns.datadictionary.exporter.ExportMap)
 51  
          */
 52  
         @Override
 53  
         public void extendExportMap(ExportMap exportMap) {
 54  0
         exportMap.set("type", "broaderAnyCharacter");
 55  
 
 56  0
         if (allowWhitespace) {
 57  0
             exportMap.set("allowWhitespace", "true");
 58  
         }
 59  0
         }
 60  
 
 61  
         /**
 62  
          * This overridden method ...
 63  
          * 
 64  
          * @see org.kuali.rice.kns.datadictionary.validation.ValidationPattern#getRegexString()
 65  
          */
 66  
         @Override
 67  
         protected String getRegexString() {
 68  0
                 StringBuffer regexString = new StringBuffer("[");
 69  
                 
 70  0
                 if(!allowWhitespace)
 71  0
                 regexString.append("[\\\u0000-\u10FFFF&&[^\\p{Space}]]");
 72  
                 
 73  
                 else{
 74  0
                         regexString.append("\\\u0000-\u10FFFF");
 75  
                 }
 76  
                 
 77  0
                 regexString.append("]");
 78  0
                 return regexString.toString();
 79  
         }
 80  
         
 81  
         @Override
 82  
         protected String getValidationErrorMessageKeyOptions() {
 83  0
                 if (getAllowWhitespace()) {
 84  0
                         return ".allowWhitespace";
 85  
                 }
 86  0
                 return KNSConstants.EMPTY_STRING;
 87  
         }
 88  
 
 89  
 }