1 28 29 package com.caucho.server.connection; 30 31 import com.caucho.util.NullEnumeration; 32 import com.caucho.vfs.ReadStream; 33 34 import javax.servlet.RequestDispatcher ; 35 import javax.servlet.ServletInputStream ; 36 import java.io.BufferedReader ; 37 import java.util.Collections ; 38 import java.util.Enumeration ; 39 import java.util.HashMap ; 40 import java.util.Locale ; 41 import java.util.Map ; 42 43 47 public class StubServletRequest extends AbstractHttpRequest { 48 private HashMap _attributes; 49 50 public StubServletRequest() 51 { 52 super(null, null); 53 54 try { 55 start(); 56 } catch (Throwable e) { 57 } 58 } 59 60 public Object getAttribute(String name) 61 { 62 if (_attributes != null) 63 return _attributes.get(name); 64 else 65 return null; 66 } 67 68 public Enumeration<String > getAttributeNames() 69 { 70 if (_attributes != null) 71 return Collections.enumeration(_attributes.keySet()); 72 else 73 return (Enumeration) NullEnumeration.create(); 74 } 75 76 public void setAttribute(String name, Object value) 77 { 78 if (_attributes == null) 79 _attributes = new HashMap (); 80 81 _attributes.put(name, value); 82 } 83 84 public void removeAttribute(String name) 85 { 86 if (_attributes != null) 87 _attributes.remove(name); 88 } 89 90 public boolean initStream(ReadStream rawStream, ReadStream realStream) 91 { 92 return false; 93 } 94 95 public String getCharacterEncoding() { return "UTF-8"; } 96 public void setCharacterEncoding(String encoding) { } 97 public int getContentLength() { return -1; } 98 public String getContentType() { return "application/octet-stream"; } 99 public ServletInputStream getInputStream() 100 { 101 throw new IllegalStateException (); 102 } 103 public String getParameter(String name) { return null; } 104 public Enumeration<String > getParameterNames() 105 { 106 return (Enumeration) NullEnumeration.create(); 107 } 108 public String []getParameterValues(String name) { return null; } 109 public Map <String ,String []> getParameterMap() { return null; } 110 public String getProtocol() { return "none"; } 111 112 public BufferedReader getReader() 113 { 114 throw new IllegalStateException (); 115 } 116 public String getRemoteAddr() { return "127.0.0.1"; } 117 public String getRemoteHost() { return "127.0.0.1"; } 118 public String getScheme() { return "cron"; } 119 public String getServerName() { return "127.0.0.1"; } 120 public int getServerPort() { return 0; } 121 122 public String getRealPath(String path) { return null; } 123 public Locale getLocale() { return null; } 124 public Enumeration<Locale > getLocales() 125 { return (Enumeration) NullEnumeration.create(); } 126 public boolean isSecure() { return true; } 127 public RequestDispatcher getRequestDispatcher(String uri) { return null; } 128 129 public String getMethod() { return "GET"; } 130 public String getServletPath() { return null; } 131 public String getContextPath() { return null; } 132 public String getPathInfo() { return null; } 133 public String getPathTranslated() { return null; } 134 public String getRequestURI () { return null; } 135 public StringBuffer getRequestURL () 136 { 137 return new StringBuffer ("http://localhost"); 138 } 139 public int getUriLength() { return 0; } 140 public byte []getUriBuffer() { return null; } 141 142 public String getQueryString() { return null; } 143 144 public String getHeader(String header) { return null; } 145 public int getIntHeader(String header) { return 0; } 146 public long getDateHeader(String header) { return 0; } 147 public Enumeration getHeaders(String header) { return null; } 148 public Enumeration getHeaderNames() { return null; } 149 150 public String getAuthType() { return null; } 151 public String getRemoteUser() { return null; } 152 public java.security.Principal getUserPrincipal() { return null; } 153 154 public boolean isUserInRole(String str) { return false; } 155 } 156 157 | Popular Tags |