Coverage Report - org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersPatternConstraint
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidCharactersPatternConstraint
0%
0/11
0%
0/4
1.667
 
 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 org.apache.commons.lang.StringUtils;
 19  
 
 20  
 /**
 21  
  * 
 22  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 23  
  */
 24  0
 public abstract class ValidCharactersPatternConstraint extends ValidCharactersConstraint{
 25  
     /**
 26  
      * Warning: This value should NOT be set on ValidCharactersPatternConstraints as the value is built dynamically from the
 27  
      * flags set on the constraint - if this value IS set it will override any automatic generation and only
 28  
      * use that which was set through this method for server side validation
 29  
      * 
 30  
      * @see org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersConstraint#setValue(java.lang.String)
 31  
      */
 32  
     @Override
 33  
     public void setValue(String value) {
 34  0
             super.setValue(value);
 35  0
     }
 36  
     /**
 37  
      * Warning: This value should NOT be set on ValidCharactersPatternConstraints as the value is built dynamically from the
 38  
      * flags set on the constraint - if this value IS set it will override any automatic generation and only
 39  
      * use that which was set through this method for client side validation
 40  
      * 
 41  
      * @see org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersConstraint#setJsValue(java.lang.String)
 42  
      */
 43  
     @Override
 44  
     public void setJsValue(String jsValue) {
 45  0
             super.setJsValue(jsValue);
 46  0
     }
 47  
     
 48  
     /**
 49  
      * @see org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersConstraint#getValue()
 50  
      */
 51  
     @Override
 52  
     public String getValue() {
 53  0
             if(StringUtils.isEmpty(value)){
 54  0
                     return "regex:^" + getRegexString() + "*$";
 55  
             }
 56  0
             return value;
 57  
 
 58  
     }
 59  
     
 60  
     /**
 61  
      * @see org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersConstraint#getJsValue()
 62  
      */
 63  
     @Override
 64  
         public String getJsValue() {
 65  0
             if(StringUtils.isEmpty(jsValue)){
 66  0
                 return "/^" + getJsRegexString() + "*$/";
 67  
             }
 68  0
             return jsValue;
 69  
     }
 70  
     
 71  
         /**
 72  
          * This method returns a string representing a regex with characters to match, this string should not
 73  
          * include the start(^) and end($) symbols or any length related symbols (*, {0,}, etc)
 74  
          * 
 75  
          * @return
 76  
          */
 77  
         abstract protected String getRegexString();
 78  
         
 79  
         /**
 80  
          * This method returns a string representing a <b>js</b> regex with characters to match, this string should not
 81  
          * include the start(/^) and end($/) symbols or any length related symbols (*, {0,}, etc).
 82  
          * 
 83  
          * This may be the same value as getRegexString()
 84  
          * 
 85  
          * @return
 86  
          */
 87  
         abstract protected String getJsRegexString();
 88  
 }