| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| NumericPatternConstraint |
|
| 2.0;2 |
| 1 | /** | |
| 2 | * Copyright 2005-2011 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.krad.datadictionary.validation.constraint; | |
| 17 | ||
| 18 | import org.apache.commons.lang.StringUtils; | |
| 19 | import org.kuali.rice.krad.uif.UifConstants; | |
| 20 | ||
| 21 | import javax.xml.bind.annotation.XmlAccessType; | |
| 22 | import javax.xml.bind.annotation.XmlAccessorType; | |
| 23 | ||
| 24 | /** | |
| 25 | * Pattern for matching numeric characters, difference between NumericPatternConstraint and IntegerPatternConstraint | |
| 26 | * is that a numeric pattern constraint is for matching numeric characters and can be mixed with other characters | |
| 27 | * by setting allow flags on, while integer is for only positive/negative numbers | |
| 28 | * | |
| 29 | * | |
| 30 | */ | |
| 31 | @XmlAccessorType(XmlAccessType.FIELD) | |
| 32 | 0 | public class NumericPatternConstraint extends AllowCharacterConstraint { |
| 33 | ||
| 34 | /** | |
| 35 | * @see org.kuali.rice.krad.datadictionary.validation.ValidationPattern#getRegexString() | |
| 36 | */ | |
| 37 | protected String getRegexString() { | |
| 38 | 0 | StringBuilder regexString = new StringBuilder("[0-9"); |
| 39 | 0 | regexString.append(this.getAllowedCharacterRegex()); |
| 40 | 0 | regexString.append("]"); |
| 41 | ||
| 42 | 0 | return regexString.toString(); |
| 43 | } | |
| 44 | ||
| 45 | /** | |
| 46 | * This overridden method ... | |
| 47 | * | |
| 48 | * @see org.kuali.rice.krad.datadictionary.validation.constraint.BaseConstraint#getLabelKey() | |
| 49 | */ | |
| 50 | @Override | |
| 51 | public String getLabelKey() { | |
| 52 | 0 | String labelKey = super.getLabelKey(); |
| 53 | 0 | if (StringUtils.isNotEmpty(labelKey)) { |
| 54 | 0 | return labelKey; |
| 55 | } | |
| 56 | 0 | return UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "numericPattern"; |
| 57 | } | |
| 58 | ||
| 59 | } |