View Javadoc
1   /**
2    * Copyright 2005-2015 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.kns.datadictionary.validation.charlevel;
17  
18  import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
19  import org.kuali.rice.krad.datadictionary.validation.CharacterLevelValidationPattern;
20  import org.kuali.rice.krad.util.KRADConstants;
21  
22  /**
23   * Pattern for matching any printable character
24   * 
25   * @deprecated Use {@link org.kuali.rice.krad.datadictionary.validation.constraint.AnyCharacterPatternConstraint}.
26   */
27  @Deprecated
28  public class AnyCharacterValidationPattern extends CharacterLevelValidationPattern {
29      protected boolean allowWhitespace = false;
30  
31  
32      /**
33       * @return allowWhitespace
34       */
35      public boolean getAllowWhitespace() {
36          return allowWhitespace;
37      }
38  
39      /**
40       * @param allowWhitespace
41       */
42      public void setAllowWhitespace(boolean allowWhitespace) {
43          this.allowWhitespace = allowWhitespace;
44      }
45  
46  
47      /**
48       * @see org.kuali.rice.krad.datadictionary.validation.ValidationPattern#getRegexString()
49       */
50      protected String getRegexString() {
51          StringBuffer regexString = new StringBuffer("[");
52  
53  
54          regexString.append("\\p{Graph}");
55          if (allowWhitespace) {
56              regexString.append("\\p{Space}");
57          }
58          regexString.append("]");
59  
60          return regexString.toString();
61      }
62  
63  
64      /**
65       * @see org.kuali.rice.krad.datadictionary.validation.CharacterLevelValidationPattern#extendExportMap(org.kuali.rice.krad.datadictionary.exporter.ExportMap)
66       */
67      public void extendExportMap(ExportMap exportMap) {
68          exportMap.set("type", "anyCharacter");
69  
70          if (allowWhitespace) {
71              exportMap.set("allowWhitespace", "true");
72          }
73      }
74      
75  	@Override
76  	protected String getValidationErrorMessageKeyOptions() {
77  		if (getAllowWhitespace()) {
78  			return ".allowWhitespace";
79  		}
80  		return KRADConstants.EMPTY_STRING;
81  	}
82  }