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 @Override 031 public void release() { 032 super.release(); 033 type="any"; 034 _default=null; 035 name=null; 036 037 min=-1; 038 max=-1; 039 pattern=null; 040 } 041 042 public Param() throws ApplicationException { 043 throw new ApplicationException("this Tag Implemenation is deprecated and replaced with a Translation Time Transformer"); 044 } 045 046 047 048 /** set the value type 049 * The type of parameter that is required. The default is 'any'. 050 * @param type value to set 051 **/ 052 public void setType(String type) { 053 this.type=type.trim().toLowerCase(); 054 } 055 056 /** set the value default 057 * Default value to set the parameter to if it does not exist. 058 * @param _default value to set 059 **/ 060 public void setDefault(Object _default) { 061 this._default=_default; 062 } 063 064 /** 065 * @param max the max to set 066 */ 067 public void setMax(double max) { 068 this.max = max; 069 } 070 071 /** 072 * @param min the min to set 073 */ 074 public void setMin(double min) { 075 this.min = min; 076 } 077 078 /** 079 * @param pattern the pattern to set 080 */ 081 public void setPattern(String pattern) { 082 this.pattern = pattern; 083 } 084 085 /** set the value name 086 * The name of the parameter to test, such as Client.Email or Cookie.BackgroundColor. If 087 * you omit the DEFAULT attribute, an error occurs if the specified parameter does not exist 088 * @param name value to set 089 **/ 090 public void setName(String name) { 091 this.name=name; 092 } 093 094 095 @Override 096 public int doStartTag() throws PageException { 097 if("range".equals(type)) 098 pageContext.param(type, name, _default,min,max); 099 else if("regex".equals(type) || "regular_expression".equals(type)) 100 pageContext.param(type, name, _default,pattern); 101 else 102 pageContext.param(type, name, _default); 103 return SKIP_BODY; 104 } 105 106 }