1 package org.apache.turbine.util.uri; 2 3 18 19 import java.util.Iterator ; 20 21 import org.apache.commons.lang.StringUtils; 22 23 import org.apache.turbine.util.RunData; 24 import org.apache.turbine.util.ServerData; 25 import org.apache.turbine.util.parser.ParameterParser; 26 27 38 39 public class TemplateURI 40 extends TurbineURI 41 { 42 46 public TemplateURI() 47 { 48 super(); 49 } 50 51 56 public TemplateURI(RunData runData) 57 { 58 super(runData); 59 } 60 61 67 public TemplateURI(RunData runData, boolean redirect) 68 { 69 super(runData, redirect); 70 } 71 72 78 public TemplateURI(RunData runData, String template) 79 { 80 super(runData); 81 setTemplate(template); 82 } 83 84 91 public TemplateURI(RunData runData, String template, boolean redirect) 92 { 93 super(runData, redirect); 94 setTemplate(template); 95 } 96 97 104 public TemplateURI(RunData runData, String template, String action) 105 { 106 this(runData, template); 107 setAction(action); 108 } 109 110 118 public TemplateURI(RunData runData, String template, String action, boolean redirect) 119 { 120 this(runData, template, redirect); 121 setAction(action); 122 } 123 124 129 public TemplateURI(ServerData serverData) 130 { 131 super(serverData); 132 } 133 134 140 public TemplateURI(ServerData serverData, boolean redirect) 141 { 142 super(serverData, redirect); 143 } 144 145 151 public TemplateURI(ServerData serverData, String template) 152 { 153 super(serverData); 154 setTemplate(template); 155 } 156 157 164 public TemplateURI(ServerData serverData, String template, boolean redirect) 165 { 166 super(serverData, redirect); 167 setTemplate(template); 168 } 169 170 177 public TemplateURI(ServerData serverData, String template, String action) 178 { 179 this(serverData, template); 180 setAction(action); 181 } 182 183 191 public TemplateURI(ServerData serverData, String template, String action, boolean redirect) 192 { 193 this(serverData, template, redirect); 194 setAction(action); 195 } 196 197 203 public TemplateURI(String template, String action) 204 { 205 this(); 206 setTemplate(template); 207 setAction(action); 208 } 209 210 219 public void setTemplate(String template) 220 { 221 if(StringUtils.isNotEmpty(template)) 222 { 223 add(PATH_INFO, CGI_TEMPLATE_PARAM, template); 224 } 225 else 226 { 227 clearTemplate(); 228 } 229 } 230 231 235 public void clearTemplate() 236 { 237 removePathInfo(CGI_TEMPLATE_PARAM); 238 } 239 240 248 249 262 protected void add(int type, 263 ParameterParser pp) 264 { 265 for(Iterator it = pp.keySet().iterator(); it.hasNext();) 266 { 267 String key = (String ) it.next(); 268 269 if (!key.equalsIgnoreCase(CGI_ACTION_PARAM) && 270 !key.equalsIgnoreCase(CGI_SCREEN_PARAM) && 271 !key.equalsIgnoreCase(CGI_TEMPLATE_PARAM)) 272 { 273 String [] values = pp.getStrings(key); 274 for (int i = 0; i < values.length; i++) 275 { 276 add(type, key, values[i]); 277 } 278 } 279 } 280 } 281 } 282 | Popular Tags |