Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ValidCharactersPatternConstraint |
|
| 1.6666666666666667;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 | /** | |
38 | * @see org.kuali.rice.kns.datadictionary.validation.constraint.ValidCharactersConstraint#getValue() | |
39 | */ | |
40 | @Override | |
41 | public String getValue() { | |
42 | 0 | if(StringUtils.isEmpty(value)){ |
43 | 0 | return "^" + getRegexString() + "*$"; |
44 | } | |
45 | 0 | return value; |
46 | ||
47 | } | |
48 | ||
49 | /** | |
50 | * This method returns a string representing a regex with characters to match, this string should not | |
51 | * include the start(^) and end($) symbols or any length related symbols (*, {0,}, etc) | |
52 | * | |
53 | * @return | |
54 | */ | |
55 | abstract protected String getRegexString(); | |
56 | ||
57 | } |