Coverage Report - org.paneris.jammyjoes.controller.ParameterProvider
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterProvider
0%
0/18
0%
0/16
2.25
 
 1  
 package org.paneris.jammyjoes.controller;
 2  
 
 3  
 import org.melati.template.ServletTemplateContext;
 4  
 import org.melati.util.UTF8URLEncoder;
 5  
 
 6  
 public class ParameterProvider {
 7  
 
 8  
   ServletTemplateContext context;
 9  
   String[] pathInfo;
 10  
   
 11  0
   public ParameterProvider(ServletTemplateContext tc, String[] pathInfo) {
 12  0
     this.context = tc;
 13  0
     this.pathInfo = pathInfo;
 14  0
   }
 15  
 
 16  
   public String getParam(String param, int pos) {
 17  0
     String result = nulled(context.getForm(param));
 18  0
     if (result != null) {
 19  0
       return result;
 20  
     }
 21  0
     if (pos > -1 && pos < pathInfo.length) {
 22  0
       result = nulled(pathInfo[pos]);
 23  
     }
 24  0
     if (result != null) {
 25  0
       return UTF8URLEncoder.decode(result);
 26  
     }
 27  0
     return result;
 28  
   }
 29  
 
 30  
   public String nulled(String string) {
 31  0
     String result = string == null ? null : string;
 32  0
     result = "".equals(string) ? null : result;
 33  0
     result = "_".equals(string) ? null : result;
 34  0
     return result;
 35  
   }
 36  
 
 37  
   public Integer getParamAsInt(String param, int pos) {
 38  0
     String in = getParam(param, pos);
 39  0
     return in == null ? null : new Integer(in);
 40  
 
 41  
   }
 42  
 
 43  
 }