1 16 17 package org.apache.taglibs.standard.lang.jstl.test; 18 19 import java.util.Collections ; 20 import java.util.Enumeration ; 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 import javax.servlet.Servlet ; 25 import javax.servlet.ServletConfig ; 26 import javax.servlet.ServletContext ; 27 import javax.servlet.ServletRequest ; 28 import javax.servlet.ServletResponse ; 29 import javax.servlet.http.HttpSession ; 30 import javax.servlet.jsp.JspWriter ; 31 import javax.servlet.jsp.PageContext ; 32 import javax.servlet.jsp.el.ExpressionEvaluator ; 33 import javax.servlet.jsp.el.VariableResolver ; 34 35 43 44 public class PageContextImpl 45 extends PageContext 46 { 47 51 55 Map mPage = Collections.synchronizedMap (new HashMap ()); 56 Map mRequest = Collections.synchronizedMap (new HashMap ()); 57 Map mSession = Collections.synchronizedMap (new HashMap ()); 58 Map mApp = Collections.synchronizedMap (new HashMap ()); 59 60 65 public PageContextImpl () 66 { 67 } 68 69 public void initialize (Servlet servlet, 73 ServletRequest request, 74 ServletResponse response, 75 String errorPageURL, 76 boolean needSession, 77 int bufferSize, 78 boolean autoFlush) 79 { 80 } 81 82 public void release () 84 { 85 } 86 87 public void setAttribute (String name, 89 Object attribute) 90 { 91 mPage.put (name, attribute); 92 } 93 94 public void setAttribute (String name, 96 Object attribute, 97 int scope) 98 { 99 switch (scope) { 100 case PAGE_SCOPE: 101 mPage.put (name, attribute); 102 break; 103 case REQUEST_SCOPE: 104 mRequest.put (name, attribute); 105 break; 106 case SESSION_SCOPE: 107 mSession.put (name, attribute); 108 break; 109 case APPLICATION_SCOPE: 110 mApp.put (name, attribute); 111 break; 112 default: 113 throw new IllegalArgumentException ("Bad scope " + scope); 114 } 115 } 116 117 public Object getAttribute (String name) 119 { 120 return mPage.get (name); 121 } 122 123 public Object getAttribute (String name, 125 int scope) 126 { 127 switch (scope) { 128 case PAGE_SCOPE: 129 return mPage.get (name); 130 case REQUEST_SCOPE: 131 return mRequest.get (name); 132 case SESSION_SCOPE: 133 return mSession.get (name); 134 case APPLICATION_SCOPE: 135 return mApp.get (name); 136 default: 137 throw new IllegalArgumentException ("Bad scope " + scope); 138 } 139 } 140 141 public Object findAttribute (String name) 143 { 144 if (mPage.containsKey (name)) { 145 return mPage.get (name); 146 } 147 else if (mRequest.containsKey (name)) { 148 return mRequest.get (name); 149 } 150 else if (mSession.containsKey (name)) { 151 return mSession.get (name); 152 } 153 else if (mApp.containsKey (name)) { 154 return mApp.get (name); 155 } 156 else { 157 return null; 158 } 159 } 160 161 public void removeAttribute (String name) 163 { 164 if (mPage.containsKey (name)) { 165 mPage.remove (name); 166 } 167 else if (mRequest.containsKey (name)) { 168 mRequest.remove (name); 169 } 170 else if (mSession.containsKey (name)) { 171 mSession.remove (name); 172 } 173 else if (mApp.containsKey (name)) { 174 mApp.remove (name); 175 } 176 } 177 178 public void removeAttribute (String name, 180 int scope) 181 { 182 switch (scope) { 183 case PAGE_SCOPE: 184 mPage.remove (name); 185 break; 186 case REQUEST_SCOPE: 187 mRequest.remove (name); 188 break; 189 case SESSION_SCOPE: 190 mSession.remove (name); 191 break; 192 case APPLICATION_SCOPE: 193 mApp.remove (name); 194 break; 195 default: 196 throw new IllegalArgumentException ("Bad scope " + scope); 197 } 198 } 199 200 public int getAttributesScope (String name) 202 { 203 if (mPage.containsKey (name)) { 204 return PAGE_SCOPE; 205 } 206 else if (mRequest.containsKey (name)) { 207 return REQUEST_SCOPE; 208 } 209 else if (mSession.containsKey (name)) { 210 return SESSION_SCOPE; 211 } 212 else if (mApp.containsKey (name)) { 213 return APPLICATION_SCOPE; 214 } 215 else { 216 return 0; 217 } 218 } 219 220 public Enumeration getAttributeNamesInScope (int scope) 222 { 223 return null; 224 } 225 226 public JspWriter getOut () 228 { 229 return null; 230 } 231 232 public HttpSession getSession () 234 { 235 return null; 236 } 237 238 public Object getPage () 240 { 241 return null; 242 } 243 244 public ServletRequest getRequest () 246 { 247 return null; 248 } 249 250 public ServletResponse getResponse () 252 { 253 return null; 254 } 255 256 public Exception getException () 258 { 259 return null; 260 } 261 262 public ServletConfig getServletConfig () 264 { 265 return null; 266 } 267 268 public ServletContext getServletContext () 270 { 271 return null; 272 } 273 274 public void forward (String path) 276 { 277 } 278 279 public void include (String path) 281 { 282 } 283 284 public void handlePageException (Exception exc) 286 { 287 } 288 289 public void handlePageException (Throwable exc) 291 { 292 } 293 294 296 public void include(java.lang.String relativeUrlPath, boolean flush) {} 298 public ExpressionEvaluator getExpressionEvaluator() { return null; } 299 public VariableResolver getVariableResolver() { return null; } 300 301 } 302 | Popular Tags |