Creates a specific servlet request simulation from command line usage.
| Constructor: |
public CommandLineRequest(Environment env,
String contextPath,
String servletPath,
String pathInfo) {
this(env, contextPath, servletPath, pathInfo, null, null, null);
}
|
public CommandLineRequest(Environment env,
String contextPath,
String servletPath,
String pathInfo,
Map attributes) {
this(env, contextPath, servletPath, pathInfo, attributes, null, null);
}
|
public CommandLineRequest(Environment env,
String contextPath,
String servletPath,
String pathInfo,
Map attributes,
Map parameters) {
this(env, contextPath, servletPath, pathInfo, attributes, parameters, null);
}
|
public CommandLineRequest(Environment env,
String contextPath,
String servletPath,
String pathInfo,
Map attributes,
Map parameters,
Map headers) {
this.env = env;
this.contextPath = contextPath;
this.servletPath = servletPath;
this.pathInfo = pathInfo;
this.attributes = (attributes == null ? new HashMap() : attributes);
this.parameters = parameters;
this.headers = headers;
}
|
| Method from org.apache.cocoon.environment.commandline.CommandLineRequest Detail: |
public Object get(String name) {
String[] values = this.getParameterValues(name);
if (values == null || values.length == 0) {
return null;
} else if (values.length == 1) {
return values[0];
} else {
Vector vect = new Vector(values.length);
for (int i = 0; i < values.length; i++) {
vect.add(values[i]);
}
return vect;
}
}
|
public Object getAttribute(String name) {
return this.attributes.get(name);
}
|
public Enumeration getAttributeNames() {
return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
}
|
public String getAuthType() {
return null;
}
|
public String getCharacterEncoding() {
return characterEncoding;
}
|
public int getContentLength() {
return -1;
}
|
public String getContentType() {
return null;
}
|
public String getContextPath() {
return contextPath;
}
|
public Map getCookieMap() {
return Collections.unmodifiableMap(new HashMap());
}
|
public Cookie[] getCookies() {
return null;
}
|
public long getDateHeader(String name) {
//FIXME
return 0;
}
|
public String getHeader(String name) {
return (headers != null) ? (String) headers.get(name.toLowerCase()) : null;
}
|
public Enumeration getHeaderNames() {
if (headers != null) {
return IteratorUtils.asEnumeration(headers.keySet().iterator());
} else {
return new EmptyEnumeration();
}
}
|
public Enumeration getHeaders(String name) {
// FIXME
return new EmptyEnumeration();
}
|
public int getIntHeader(String name) {
String header = (headers != null) ? (String) headers.get(name.toLowerCase()) : null;
return (header != null) ? Integer.parseInt(header) : -1;
}
|
public Locale getLocale() {
return Locale.getDefault();
}
|
public Enumeration getLocales() {
// FIXME
throw new RuntimeException (getClass().getName() + ".getLocales() method not yet implemented!");
}
|
public String getMethod() {
return "get";
}
|
public String getParameter(String name) {
if (this.parameters == null) {
return null;
}
final Object value = this.parameters.get(name);
if (value instanceof String) {
return (String)value;
} else if (value == null) {
return null;
} else {
final String[] values = (String[]) value;
if (values.length == 0) {
return null;
}
return values[0];
}
}
|
public Map getParameterMap() {
return parameters;
}
|
public Enumeration getParameterNames() {
return (this.parameters != null) ? IteratorUtils.asEnumeration(this.parameters.keySet().iterator()) : null;
}
|
public String[] getParameterValues(String name) {
final Object value = this.parameters.get(name);
if (value instanceof String) {
return new String[] { (String)value };
} else {
return (String[]) value;
}
}
|
public String getPathInfo() {
return pathInfo;
}
|
public String getPathTranslated() {
return null;
}
|
public String getProtocol() {
return "cli";
}
|
public String getQueryString() {
return null;
}
|
public String getRemoteAddr() {
return "127.0.0.1";
}
|
public String getRemoteHost() {
return "localhost";
}
|
public String getRemoteUser() {
return SystemUtils.USER_NAME;
}
|
public String getRequestURI() {
StringBuffer buffer = new StringBuffer();
if (servletPath != null) buffer.append(servletPath);
if (contextPath != null) buffer.append(contextPath);
if (pathInfo != null) buffer.append(pathInfo);
return buffer.toString();
}
|
public StringBuffer getRequestURL() {
return null;
}
|
public String getRequestedSessionId() {
return (CommandLineSession.getSession(false) != null) ?
CommandLineSession.getSession(false).getId() : null;
}
Returns the session ID specified by the client. This may
not be the same as the ID of the actual session in use.
For example, if the request specified an old (expired)
session ID and the server has started a new session, this
method gets a new session with a new ID. If the request
did not specify a session ID, this method returns
null. |
public String getScheme() {
return "cli";
}
|
public String getServerName() {
return Constants.COMPLETE_NAME;
}
|
public int getServerPort() {
return -1;
}
|
public String getServletPath() {
return servletPath;
}
|
public Session getSession() {
return this.getSession(true);
}
Returns the current session associated with this request,
or if the request does not have a session, creates one. |
public Session getSession(boolean create) {
return CommandLineSession.getSession(create);
}
Returns the current Session
associated with this request or, if if there is no
current session and create is true, returns
a new session.
If create is false
and the request has no valid Session,
this method returns null.
To make sure the session is properly maintained,
you must call this method before
the response is committed. |
public String getSitemapURI() {
return this.env.getURI();
}
|
public String getSitemapURIPrefix() {
return this.env.getURIPrefix();
}
|
public Principal getUserPrincipal() {
return null;
}
|
public boolean isRequestedSessionIdFromCookie() {
return false;
}
Checks whether the requested session ID came in as a cookie. |
public boolean isRequestedSessionIdFromURL() {
return false;
}
Checks whether the requested session ID came in as part of the
request URL. |
public boolean isRequestedSessionIdValid() {
return (CommandLineSession.getSession(false) != null);
}
Checks whether the requested session ID is still valid. |
public boolean isSecure() {
return false;
}
|
public boolean isUserInRole(String role) {
return false;
}
|
public void removeAttribute(String name) {
this.attributes.remove(name);
}
|
public void setAttribute(String name,
Object value) {
this.attributes.put(name, value);
}
|
public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
characterEncoding = env;
}
|