|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  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 |     | 
     | 
  |  21 |     | 
     | 
  |  22 |     | 
     | 
  |  23 |     | 
     | 
  |  24 |     | 
     | 
  |  25 |     | 
     | 
  |  26 |    0 |    public class AlphaNumericValidationPattern extends CharacterLevelValidationPattern { | 
  |  27 |    0 |        protected boolean allowWhitespace = false;  | 
  |  28 |    0 |        protected boolean allowUnderscore = false;  | 
  |  29 |    0 |        protected boolean allowPeriod = false;  | 
  |  30 |     | 
     | 
  |  31 |    0 |        protected boolean allowParenthesis = false;  | 
  |  32 |    0 |        protected boolean allowDollar = false;  | 
  |  33 |    0 |        protected boolean allowForwardSlash = false;  | 
  |  34 |    0 |        protected boolean lowerCase = false;  | 
  |  35 |     | 
         | 
  |  36 |     | 
         | 
  |  37 |     | 
     | 
  |  38 |     | 
     | 
  |  39 |     | 
       public boolean getAllowPeriod() { | 
  |  40 |    0 |            return allowPeriod;  | 
  |  41 |     | 
       }  | 
  |  42 |     | 
     | 
  |  43 |     | 
         | 
  |  44 |     | 
     | 
  |  45 |     | 
     | 
  |  46 |     | 
       public void setAllowPeriod(boolean allowPeriod) { | 
  |  47 |    0 |            this.allowPeriod = allowPeriod;  | 
  |  48 |    0 |        }      | 
  |  49 |     | 
         | 
  |  50 |     | 
         | 
  |  51 |     | 
     | 
  |  52 |     | 
     | 
  |  53 |     | 
           public boolean isAllowPeriod() { | 
  |  54 |    0 |                    return allowPeriod;  | 
  |  55 |     | 
           }  | 
  |  56 |     | 
         | 
  |  57 |     | 
         | 
  |  58 |     | 
     | 
  |  59 |     | 
     | 
  |  60 |     | 
           public boolean isAllowParenthesis() { | 
  |  61 |    0 |                    return allowParenthesis;  | 
  |  62 |     | 
           }  | 
  |  63 |     | 
     | 
  |  64 |     | 
             | 
  |  65 |     | 
     | 
  |  66 |     | 
     | 
  |  67 |     | 
           public void setAllowParenthesis(boolean allowParenthesis) { | 
  |  68 |    0 |                    this.allowParenthesis = allowParenthesis;  | 
  |  69 |    0 |            }  | 
  |  70 |     | 
             | 
  |  71 |     | 
             | 
  |  72 |     | 
     | 
  |  73 |     | 
     | 
  |  74 |     | 
           public boolean isAllowDollar() { | 
  |  75 |    0 |                    return allowDollar;  | 
  |  76 |     | 
           }  | 
  |  77 |     | 
     | 
  |  78 |     | 
             | 
  |  79 |     | 
     | 
  |  80 |     | 
     | 
  |  81 |     | 
           public void setAllowDollar(boolean allowDollar) { | 
  |  82 |    0 |                    this.allowDollar = allowDollar;  | 
  |  83 |    0 |            }  | 
  |  84 |     | 
     | 
  |  85 |     | 
             | 
  |  86 |     | 
     | 
  |  87 |     | 
     | 
  |  88 |     | 
           public boolean isAllowForwardSlash() { | 
  |  89 |    0 |                    return allowForwardSlash;  | 
  |  90 |     | 
           }  | 
  |  91 |     | 
     | 
  |  92 |     | 
             | 
  |  93 |     | 
     | 
  |  94 |     | 
     | 
  |  95 |     | 
           public void setAllowForwardSlash(boolean allowForwardSlash) { | 
  |  96 |    0 |                    this.allowForwardSlash = allowForwardSlash;  | 
  |  97 |    0 |            }  | 
  |  98 |     | 
         | 
  |  99 |     | 
         | 
  |  100 |     | 
     | 
  |  101 |     | 
     | 
  |  102 |     | 
       public boolean getAllowWhitespace() { | 
  |  103 |    0 |            return allowWhitespace;  | 
  |  104 |     | 
       }  | 
  |  105 |     | 
     | 
  |  106 |     | 
         | 
  |  107 |     | 
     | 
  |  108 |     | 
     | 
  |  109 |     | 
       public void setAllowWhitespace(boolean allowWhitespace) { | 
  |  110 |    0 |            this.allowWhitespace = allowWhitespace;  | 
  |  111 |    0 |        }  | 
  |  112 |     | 
     | 
  |  113 |     | 
     | 
  |  114 |     | 
         | 
  |  115 |     | 
     | 
  |  116 |     | 
     | 
  |  117 |     | 
       public boolean getAllowUnderscore() { | 
  |  118 |    0 |            return allowUnderscore;  | 
  |  119 |     | 
       }  | 
  |  120 |     | 
     | 
  |  121 |     | 
         | 
  |  122 |     | 
     | 
  |  123 |     | 
     | 
  |  124 |     | 
       public void setAllowUnderscore(boolean allowUnderscore) { | 
  |  125 |    0 |            this.allowUnderscore = allowUnderscore;  | 
  |  126 |    0 |        }  | 
  |  127 |     | 
        | 
  |  128 |     | 
         | 
  |  129 |     | 
     | 
  |  130 |     | 
     | 
  |  131 |     | 
           public boolean isLowerCase() { | 
  |  132 |    0 |                    return this.lowerCase;  | 
  |  133 |     | 
           }  | 
  |  134 |     | 
     | 
  |  135 |     | 
             | 
  |  136 |     | 
     | 
  |  137 |     | 
     | 
  |  138 |     | 
           public void setLowerCase(boolean lowerCase) { | 
  |  139 |    0 |                    this.lowerCase = lowerCase;  | 
  |  140 |    0 |            }  | 
  |  141 |     | 
         | 
  |  142 |     | 
         | 
  |  143 |     | 
     | 
  |  144 |     | 
     | 
  |  145 |     | 
       protected String getRegexString() { | 
  |  146 |    0 |                StringBuilder regexString = new StringBuilder("[A-Za-z0-9"); | 
  |  147 |     | 
                 | 
  |  148 |     | 
                 | 
  |  149 |     | 
     | 
  |  150 |     | 
     | 
  |  151 |    0 |                if(lowerCase){ | 
  |  152 |    0 |                        regexString = new StringBuilder("[a-z0-9"); | 
  |  153 |     | 
               }  | 
  |  154 |     | 
     | 
  |  155 |    0 |            if (allowWhitespace) { | 
  |  156 |    0 |                regexString.append("\\s"); | 
  |  157 |     | 
           }  | 
  |  158 |    0 |            if (allowUnderscore) { | 
  |  159 |    0 |                regexString.append("_"); | 
  |  160 |     | 
           }  | 
  |  161 |    0 |            if (allowPeriod) { | 
  |  162 |    0 |                regexString.append("."); | 
  |  163 |     | 
           }  | 
  |  164 |    0 |            if(allowParenthesis) { | 
  |  165 |    0 |                    regexString.append("("); | 
  |  166 |    0 |                    regexString.append(")"); | 
  |  167 |     | 
           }  | 
  |  168 |    0 |            if(allowDollar) { | 
  |  169 |    0 |                    regexString.append("$"); | 
  |  170 |     | 
           }  | 
  |  171 |    0 |            if(allowForwardSlash) { | 
  |  172 |    0 |                    regexString.append("/"); | 
  |  173 |     | 
           }  | 
  |  174 |    0 |            regexString.append("]"); | 
  |  175 |     | 
     | 
  |  176 |    0 |            return regexString.toString();  | 
  |  177 |     | 
       }  | 
  |  178 |     | 
     | 
  |  179 |     | 
     | 
  |  180 |     | 
         | 
  |  181 |     | 
     | 
  |  182 |     | 
     | 
  |  183 |     | 
       public void extendExportMap(ExportMap exportMap) { | 
  |  184 |    0 |            exportMap.set("type", "alphaNumeric"); | 
  |  185 |     | 
     | 
  |  186 |    0 |            if (lowerCase) { | 
  |  187 |    0 |                exportMap.set("allowUpperCase", "true"); | 
  |  188 |     | 
           }  | 
  |  189 |    0 |            if (allowWhitespace) { | 
  |  190 |    0 |                exportMap.set("allowWhitespace", "true"); | 
  |  191 |     | 
           }  | 
  |  192 |    0 |            if (allowUnderscore) { | 
  |  193 |    0 |                exportMap.set("allowUnderscore", "true"); | 
  |  194 |     | 
           }  | 
  |  195 |    0 |            if (allowPeriod) { | 
  |  196 |    0 |                    exportMap.set("allowPeriod", "true"); | 
  |  197 |     | 
           }  | 
  |  198 |    0 |            if(allowParenthesis) { | 
  |  199 |    0 |                exportMap.set("allowParenthesis", "true"); | 
  |  200 |     | 
     | 
  |  201 |     | 
           }  | 
  |  202 |    0 |            if(allowDollar) { | 
  |  203 |    0 |                exportMap.set("allowDollar", "true"); | 
  |  204 |     | 
     | 
  |  205 |     | 
           }  | 
  |  206 |    0 |            if(allowForwardSlash) { | 
  |  207 |    0 |                exportMap.set("allowForwardSlash", "true"); | 
  |  208 |     | 
     | 
  |  209 |     | 
           }  | 
  |  210 |    0 |        }  | 
  |  211 |     | 
     | 
  |  212 |     | 
           @Override  | 
  |  213 |     | 
           protected String getValidationErrorMessageKeyOptions() { | 
  |  214 |    0 |                    final StringBuilder opts = new StringBuilder();  | 
  |  215 |     | 
     | 
  |  216 |    0 |                    if (lowerCase) { | 
  |  217 |    0 |                            opts.append(".lowerCase"); | 
  |  218 |     | 
                   }  | 
  |  219 |    0 |                    if (allowWhitespace) { | 
  |  220 |    0 |                            opts.append(".allowWhitespace"); | 
  |  221 |     | 
                   }  | 
  |  222 |    0 |                    if (allowUnderscore) { | 
  |  223 |    0 |                            opts.append(".allowUnderscore"); | 
  |  224 |     | 
                   }  | 
  |  225 |    0 |                    if (allowPeriod) { | 
  |  226 |    0 |                            opts.append(".allowPeriod"); | 
  |  227 |     | 
                   }  | 
  |  228 |    0 |                    if(allowParenthesis) { | 
  |  229 |    0 |                            opts.append(".allowParenthesis"); | 
  |  230 |     | 
                   }  | 
  |  231 |    0 |                    if(allowDollar) { | 
  |  232 |    0 |                            opts.append(".allowDollar"); | 
  |  233 |     | 
                   }  | 
  |  234 |    0 |                    if(allowForwardSlash) { | 
  |  235 |    0 |                            opts.append(".allowForwardSlash"); | 
  |  236 |     | 
                   }  | 
  |  237 |     | 
     | 
  |  238 |    0 |                    return opts.toString();  | 
  |  239 |     | 
           }  | 
  |  240 |     | 
   }  |