| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.krad.datadictionary.validation.constraint; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.kuali.rice.core.api.config.property.ConfigurationService; |
| 22 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
| 23 | |
import org.kuali.rice.krad.uif.UifConstants; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | 0 | public class FloatingPointPatternConstraint extends ConfigurationBasedRegexPatternConstraint { |
| 31 | |
|
| 32 | |
protected boolean allowNegative; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
@Override |
| 38 | |
protected String getRegexString() { |
| 39 | 0 | StringBuffer regex = new StringBuffer(); |
| 40 | |
|
| 41 | 0 | if (isAllowNegative()) { |
| 42 | 0 | regex.append("-?"); |
| 43 | |
} |
| 44 | 0 | regex.append(super.getRegexString()); |
| 45 | |
|
| 46 | 0 | return regex.toString(); |
| 47 | |
} |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
public boolean isAllowNegative() { |
| 53 | 0 | return this.allowNegative; |
| 54 | |
} |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
public void setAllowNegative(boolean allowNegative) { |
| 60 | 0 | this.allowNegative = allowNegative; |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
@Override |
| 69 | |
public List<String> getValidationMessageParams() { |
| 70 | 0 | if (validationMessageParams == null) { |
| 71 | 0 | validationMessageParams = new ArrayList<String>(); |
| 72 | 0 | ConfigurationService configService = KRADServiceLocator.getKualiConfigurationService(); |
| 73 | 0 | if (allowNegative) { |
| 74 | 0 | validationMessageParams.add(configService |
| 75 | |
.getPropertyValueAsString(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX |
| 76 | |
+ "positiveOrNegative")); |
| 77 | |
} else { |
| 78 | 0 | validationMessageParams.add(configService |
| 79 | |
.getPropertyValueAsString(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positive")); |
| 80 | |
} |
| 81 | |
} |
| 82 | 0 | return validationMessageParams; |
| 83 | |
} |
| 84 | |
} |