001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kns.datadictionary.validation.charlevel;
017    
018    import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
019    import org.kuali.rice.krad.datadictionary.validation.CharacterLevelValidationPattern;
020    import org.kuali.rice.krad.util.KRADConstants;
021    
022    /**
023     * Pattern for matching any printable character
024     * 
025     * @deprecated Use {@link org.kuali.rice.krad.datadictionary.validation.constraint.AnyCharacterPatternConstraint}.
026     */
027    @Deprecated
028    public class AnyCharacterValidationPattern extends CharacterLevelValidationPattern {
029        protected boolean allowWhitespace = false;
030    
031    
032        /**
033         * @return allowWhitespace
034         */
035        public boolean getAllowWhitespace() {
036            return allowWhitespace;
037        }
038    
039        /**
040         * @param allowWhitespace
041         */
042        public void setAllowWhitespace(boolean allowWhitespace) {
043            this.allowWhitespace = allowWhitespace;
044        }
045    
046    
047        /**
048         * @see org.kuali.rice.krad.datadictionary.validation.ValidationPattern#getRegexString()
049         */
050        protected String getRegexString() {
051            StringBuffer regexString = new StringBuffer("[");
052    
053    
054            regexString.append("\\p{Graph}");
055            if (allowWhitespace) {
056                regexString.append("\\p{Space}");
057            }
058            regexString.append("]");
059    
060            return regexString.toString();
061        }
062    
063    
064        /**
065         * @see org.kuali.rice.krad.datadictionary.validation.CharacterLevelValidationPattern#extendExportMap(org.kuali.rice.krad.datadictionary.exporter.ExportMap)
066         */
067        public void extendExportMap(ExportMap exportMap) {
068            exportMap.set("type", "anyCharacter");
069    
070            if (allowWhitespace) {
071                exportMap.set("allowWhitespace", "true");
072            }
073        }
074        
075            @Override
076            protected String getValidationErrorMessageKeyOptions() {
077                    if (getAllowWhitespace()) {
078                            return ".allowWhitespace";
079                    }
080                    return KRADConstants.EMPTY_STRING;
081            }
082    }