001    package railo.runtime.tag;
002    
003    import railo.runtime.exp.ApplicationException;
004    import railo.runtime.exp.PageException;
005    import railo.runtime.ext.tag.TagImpl;
006    
007    /**
008    * Tests for a parameter's existence, tests its data type, and provides a default value if one 
009    *   is not assigned.
010    *
011    *
012    *
013    **/
014    public final class Param extends TagImpl {
015    
016            /** The type of parameter that is required. The default is 'any'. */
017            private String type="any";
018    
019            /** Default value to set the parameter to if it does not exist. */
020            private Object _default;
021    
022            /** The name of the parameter to test, such as Client.Email or Cookie.BackgroundColor. If 
023            **              you omit the DEFAULT attribute, an error occurs if the specified parameter does not exist */
024            private String name;
025    
026            private double min;
027            private double max;
028            private String pattern;
029            
030            /**
031            * @see javax.servlet.jsp.tagext.Tag#release()
032            */
033            public void release()   {
034                    super.release();
035                    type="any";
036                    _default=null;
037                    name=null;
038                    
039                    min=-1;
040                    max=-1;
041                    pattern=null;
042            }
043            
044            public Param() throws ApplicationException {
045                    throw new ApplicationException("this Tag Implemenation is deprecated and replaced with a Translation Time Transformer");
046            }
047    
048    
049    
050            /** set the value type
051            *  The type of parameter that is required. The default is 'any'.
052            * @param type value to set
053            **/
054            public void setType(String type)        {
055                    this.type=type.trim().toLowerCase();
056            }
057    
058            /** set the value default
059            *  Default value to set the parameter to if it does not exist.
060            * @param _default value to set
061            **/
062            public void setDefault(Object _default) {
063                    this._default=_default;
064            }
065    
066            /**
067             * @param max the max to set
068             */
069            public void setMax(double max) {
070                    this.max = max;
071            }
072    
073            /**
074             * @param min the min to set
075             */
076            public void setMin(double min) {
077                    this.min = min;
078            }
079    
080            /**
081             * @param pattern the pattern to set
082             */
083            public void setPattern(String pattern) {
084                    this.pattern = pattern;
085            }
086    
087            /** set the value name
088            *  The name of the parameter to test, such as Client.Email or Cookie.BackgroundColor. If 
089            *               you omit the DEFAULT attribute, an error occurs if the specified parameter does not exist
090            * @param name value to set
091            **/
092            public void setName(String name)        {
093                    this.name=name;
094            }
095    
096    
097            /**
098            * @see javax.servlet.jsp.tagext.Tag#doStartTag()
099            */
100            public int doStartTag() throws PageException    {
101                    if("range".equals(type))
102                            pageContext.param(type, name, _default,min,max);
103                    else if("regex".equals(type) || "regular_expression".equals(type))
104                            pageContext.param(type, name, _default,pattern);
105                    else 
106                            pageContext.param(type, name, _default);
107                    return SKIP_BODY;
108            }
109            
110    }