1 16 19 package servlet; 20 21 import java.net.MalformedURLException ; 22 import javax.servlet.*; 23 import javax.servlet.http.*; 24 25 36 37 public class ApplyXSLTProperties { 38 39 42 private final String DEFAULT_URL; 43 44 47 private final String DEFAULT_xslURL; 48 49 52 private final boolean DEFAULT_debug; 53 54 57 private final boolean DEFAULT_noCW; 58 59 62 public ApplyXSLTProperties() 63 { 64 DEFAULT_URL = null; 65 DEFAULT_xslURL = null; 66 DEFAULT_debug = false; 67 DEFAULT_noCW = false; 68 } 69 70 74 public ApplyXSLTProperties(ServletConfig config) 75 { 76 String xm = config.getInitParameter("URL"), 77 xu = config.getInitParameter("xslURL"), 78 db = config.getInitParameter("debug"), 79 cw = config.getInitParameter("noConflictWarnings"); 80 81 if (xm != null) DEFAULT_URL = xm; 82 else DEFAULT_URL = null; 83 if (xu != null) DEFAULT_xslURL = xu; 84 else DEFAULT_xslURL = null; 85 if (db != null) DEFAULT_debug = new Boolean (db).booleanValue(); 86 else DEFAULT_debug = false; 87 if (cw != null) DEFAULT_noCW = new Boolean (cw).booleanValue(); 88 else DEFAULT_noCW = false; 89 } 90 91 98 public String getRequestParmString(HttpServletRequest request, String param) 99 { 100 if (request != null) { 101 String [] paramVals = request.getParameterValues(param); 102 if (paramVals != null) 103 return paramVals[0]; 104 } 105 return null; 106 } 107 108 114 public String getXMLurl(HttpServletRequest request) 115 throws MalformedURLException 116 { 117 String temp = getRequestParmString(request, "URL"); 118 if (temp != null) 119 return temp; 120 return DEFAULT_URL; 121 } 122 123 129 public String getXSLurl(HttpServletRequest request) 130 throws MalformedURLException 131 { 132 String temp = getRequestParmString(request, "xslURL"); 133 if (temp != null) 134 return temp; 135 return DEFAULT_xslURL; 136 } 137 138 143 public boolean isDebug(HttpServletRequest request) 144 { 145 String temp = getRequestParmString(request, "debug"); 146 if (temp != null) 147 return new Boolean (temp).booleanValue(); 148 return DEFAULT_debug; 149 } 150 151 156 boolean isNoCW(HttpServletRequest request) 157 { 158 String temp = getRequestParmString(request, "noConflictWarnings"); 159 if (temp != null) 160 return new Boolean (temp).booleanValue(); 161 return DEFAULT_noCW; 162 } 163 } 164 | Popular Tags |