001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.tag;
020
021import lucee.commons.lang.StringUtil;
022import lucee.runtime.exp.ExpressionException;
023
024
025/**
026 * 
027 */
028public final class InputBean {
029    private short type=Input.TYPE_TEXT;
030        private short validate=Input.VALIDATE_NONE;
031        private String name;
032        private boolean required;
033        private String onValidate;
034        private String onError;
035        private String pattern;
036        //private String passThrough;
037    private double range_min=Double.NaN;
038    private double range_max=Double.NaN;
039    private String message;
040    private int maxLength=-1;
041
042    /**
043     * @return Returns the message.
044     */
045    public String getMessage() {
046        return message;
047    }
048    /**
049     * @param message The message to set.
050     */
051    public void setMessage(String message) {
052        this.message = message;
053    }
054    /**
055     * @return Returns the name.
056     */
057    public String getName() {
058        return name;
059    }
060    /**
061     * @param name The name to set.
062     */
063    public void setName(String name) {
064        this.name = name;
065    }
066    /**
067     * @return Returns the onError.
068     */
069    public String getOnError() {
070        return onError;
071    }
072    /**
073     * @param onError The onError to set.
074     */
075    public void setOnError(String onError) {
076        this.onError = onError;
077    }
078    /**
079     * @return Returns the onValidate.
080     */
081    public String getOnValidate() {
082        return onValidate;
083    }
084    /**
085     * @param onValidate The onValidate to set.
086     */
087    public void setOnValidate(String onValidate) {
088        this.onValidate = onValidate;
089    }
090    
091    /**
092     * @return Returns the pattern.
093     */
094    public String getPattern() {
095        return pattern;
096    }
097    /**
098     * @param pattern The pattern to set.
099     * @throws ExpressionException 
100     */
101    public void setPattern(String pattern) throws ExpressionException {
102        // '
103        if(StringUtil.startsWith(pattern, '\'')) {
104                if(!StringUtil.endsWith(pattern, '\''))
105                        throw new ExpressionException("invalid pattern definition ["+pattern+", missing closing [']");
106                pattern=pattern.substring(1,pattern.length()-1);
107        }
108        // "
109        if(StringUtil.startsWith(pattern, '"')) {
110                if(!StringUtil.endsWith(pattern, '"'))
111                        throw new ExpressionException("invalid pattern definition ["+pattern+", missing closing [\"]");
112                pattern=pattern.substring(1,pattern.length()-1);
113        }
114        
115        if(!StringUtil.startsWith(pattern, '/'))        pattern="/".concat(pattern);
116        if(!StringUtil.endsWith(pattern, '/'))  pattern=pattern.concat("/");
117        this.pattern = pattern;
118    }
119    /**
120     * @return Returns the range_max.
121     */
122    public double getRangeMax() {
123        return range_max;
124    }
125    /**
126     * @param range_max The range_max to set.
127     */
128    public void setRangeMax(double range_max) {
129        this.range_max = range_max;
130    }
131    /**
132     * @return Returns the range_min.
133     */
134    public double getRangeMin() {
135        return range_min;
136    }
137    /**
138     * @param range_min The range_min to set.
139     */
140    public void setRangeMin(double range_min) {
141        this.range_min = range_min;
142    }
143    /**
144     * @return Returns the required.
145     */
146    public boolean isRequired() {
147        return required;
148    }
149    /**
150     * @param required The required to set.
151     */
152    public void setRequired(boolean required) {
153        this.required = required;
154    }
155    /**
156     * @return Returns the type.
157     */
158    public short getType() {
159        return type;
160    }
161    /**
162     * @param type The type to set.
163     */
164    public void setType(short type) {
165        this.type = type;
166    }
167    /**
168     * @return Returns the validate.
169     */
170    public short getValidate() {
171        return validate;
172    }
173    /**
174     * @param validate The validate to set.
175     */
176    public void setValidate(short validate) {
177        this.validate = validate;
178    }
179        public void setMaxLength(int maxLength) {
180                this.maxLength=maxLength;
181        }
182        public int getMaxLength() {
183                return maxLength;
184        }
185}