Coverage Report - org.kuali.rice.krad.datadictionary.validation.constraint.AnyCharacterPatternConstraint
 
Classes in this File Line Coverage Branch Coverage Complexity
AnyCharacterPatternConstraint
0%
0/19
0%
0/6
2
 
 1  
 /*
 2  
  * Copyright 2005-2008 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  
 
 20  
 
 21  
 /**
 22  
  * Pattern for matching any printable character
 23  
  * 
 24  
  * 
 25  
  */
 26  0
 public class AnyCharacterPatternConstraint extends ValidCharactersPatternConstraint {
 27  0
     protected boolean allowWhitespace = false;
 28  
 
 29  
 
 30  
     /**
 31  
      * @return allowWhitespace
 32  
      */
 33  
     public boolean getAllowWhitespace() {
 34  0
         return allowWhitespace;
 35  
     }
 36  
 
 37  
     /**
 38  
      * @param allowWhitespace
 39  
      */
 40  
     public void setAllowWhitespace(boolean allowWhitespace) {
 41  0
         this.allowWhitespace = allowWhitespace;
 42  0
     }
 43  
 
 44  
 
 45  
     /**
 46  
      * @see org.kuali.rice.krad.datadictionary.validation.ValidationPattern#getRegexString()
 47  
      */
 48  
     protected String getRegexString() {
 49  0
         StringBuffer regexString = new StringBuffer("[");
 50  
 
 51  
 
 52  0
         regexString.append("\\x21-\\x7E");
 53  0
         if (allowWhitespace) {
 54  0
             regexString.append("\\t\\r\\n\\v\\f");
 55  
         }
 56  0
         regexString.append("]");
 57  
 
 58  0
         return regexString.toString();
 59  
     }
 60  
 
 61  
         /**
 62  
          * 
 63  
          * @see org.kuali.rice.krad.datadictionary.validation.constraint.BaseConstraint#getLabelKey()
 64  
          */
 65  
         @Override
 66  
         public String getLabelKey() {
 67  0
                 String labelKey = super.getLabelKey();
 68  0
                 if (StringUtils.isNotEmpty(labelKey)) {
 69  0
                         return labelKey;
 70  
                 }
 71  0
                 StringBuilder key = new StringBuilder("");
 72  0
                 key.append("anyCharacterPattern,");
 73  0
                 if (getAllowWhitespace()) {
 74  0
                         key.append("whitespace");
 75  
                 }
 76  0
                 return key.toString();
 77  
         }
 78  
 
 79  
 //        @Override
 80  
 //        protected String getValidationErrorMessageKeyOptions() {
 81  
 //                if (getAllowWhitespace()) {
 82  
 //                        return ".allowWhitespace";
 83  
 //                }
 84  
 //                return KRADConstants.EMPTY_STRING;
 85  
 //        }
 86  
 
 87  
 }