* Return the Connector through which this Request was received.
*/
public Connector getConnector() {
- return (this.connector);
+ return this.connector;
}
/**
* Return the Context within which this Request is being processed.
*/
public Context getContext() {
- return (this.context);
+ return this.context;
}
* Get filter chain associated with the request.
*/
public FilterChain getFilterChain() {
- return (this.filterChain);
+ return this.filterChain;
}
/**
* <code><description>/<version></code>.
*/
public String getInfo() {
- return (info);
+ return info;
}
* Return mapping data.
*/
public MappingData getMappingData() {
- return (mappingData);
+ return mappingData;
}
if (facade == null) {
facade = new RequestFacade(this);
}
- return (facade);
+ return facade;
}
* Return the Response with which this Request is associated.
*/
public org.apache.catalina.connector.Response getResponse() {
- return (this.response);
+ return this.response;
}
/**
* Return the Wrapper within which this Request is being processed.
*/
public Wrapper getWrapper() {
- return (this.wrapper);
+ return this.wrapper;
}
* @param name Name of the note to be returned
*/
public Object getNote(String name) {
- return (notes.get(name));
+ return notes.get(name);
}
* that exist for this request.
*/
public Iterator<String> getNoteNames() {
- return (notes.keySet().iterator());
+ return notes.keySet().iterator();
}
* Return the character encoding for this Request.
*/
public String getCharacterEncoding() {
- return (coyoteRequest.getCharacterEncoding());
+ return coyoteRequest.getCharacterEncoding();
}
* Return the content length for this Request.
*/
public int getContentLength() {
- return (coyoteRequest.getContentLength());
+ return coyoteRequest.getContentLength();
}
* Return the content type for this Request.
*/
public String getContentType() {
- return (coyoteRequest.getContentType());
+ return coyoteRequest.getContentType();
}
if (locales.size() > 0) {
return locales.get(0);
- } else {
- return (defaultLocale);
}
+ return defaultLocale;
}
return (new Enumerator<Locale>(locales));
ArrayList<Locale> results = new ArrayList<Locale>();
results.add(defaultLocale);
- return (new Enumerator<Locale>(results));
+ return new Enumerator<Locale>(results);
}
public String getRealPath(String path) {
if (context == null)
- return (null);
+ return null;
ServletContext servletContext = context.getServletContext();
- if (servletContext == null)
- return (null);
- else {
- try {
- return (servletContext.getRealPath(path));
- } catch (IllegalArgumentException e) {
- return (null);
- }
+ if (servletContext == null) {
+ return null;
}
+ try {
+ return (servletContext.getRealPath(path));
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
}
public RequestDispatcher getRequestDispatcher(String path) {
if (context == null)
- return (null);
+ return null;
// If the path is already context-relative, just pass it through
if (path == null)
- return (null);
+ return null;
else if (path.startsWith("/"))
return (context.getServletContext().getRequestDispatcher(path));
relative = requestPath + path;
}
- return (context.getServletContext().getRequestDispatcher(relative));
+ return context.getServletContext().getRequestDispatcher(relative);
}
* Return the scheme used to make this Request.
*/
public String getScheme() {
- return (coyoteRequest.scheme().toString());
+ return coyoteRequest.scheme().toString();
}
* Return the server name responding to this Request.
*/
public String getServerName() {
- return (coyoteRequest.serverName().toString());
+ return coyoteRequest.serverName().toString();
}
* Return the server port responding to this Request.
*/
public int getServerPort() {
- return (coyoteRequest.getServerPort());
+ return coyoteRequest.getServerPort();
}
* Was this request received on a secure connection?
*/
public boolean isSecure() {
- return (secure);
+ return secure;
}
return startAsync(getRequest(),response.getResponse());
}
- public AsyncContext startAsync(ServletRequest request, ServletResponse response) {
- if (!isAsyncSupported()) throw new IllegalStateException("Not supported.");
- if (asyncContext==null) asyncContext = new AsyncContextImpl(this);
- else if (asyncContext.isStarted()) throw new IllegalStateException("Already started.");
+ public AsyncContext startAsync(ServletRequest request,
+ ServletResponse response) {
+ if (!isAsyncSupported()) {
+ throw new IllegalStateException("Not supported.");
+ }
+
+ if (asyncContext==null) {
+ asyncContext = new AsyncContextImpl(this);
+ } else if (asyncContext.isStarted()) {
+ throw new IllegalStateException("Already started.");
+ }
+
asyncContext.setStarted(getContext());
asyncContext.init(request,response);
//TODO SERVLET3 - async - need to retrieve the ServletContext here
}
public boolean isAsyncStarted() {
- if (asyncContext==null) return false;
- else return asyncContext.isStarted();
+ if (asyncContext == null) {
+ return false;
+ }
+
+ return asyncContext.isStarted();
}
public boolean isAsyncDispatching() {
- if (asyncContext==null) return false;
- else return (asyncContext.getState()==AsyncContextImpl.AsyncState.DISPATCHING ||
- asyncContext.getState()==AsyncContextImpl.AsyncState.TIMING_OUT ||
- asyncContext.getState()==AsyncContextImpl.AsyncState.STARTED ||
- asyncContext.getState()==AsyncContextImpl.AsyncState.ERROR_DISPATCHING ||
- asyncContext.getState()==AsyncContextImpl.AsyncState.COMPLETING);
+ if (asyncContext == null) {
+ return false;
+ }
+
+ return (asyncContext.getState()==AsyncContextImpl.AsyncState.DISPATCHING ||
+ asyncContext.getState()==AsyncContextImpl.AsyncState.TIMING_OUT ||
+ asyncContext.getState()==AsyncContextImpl.AsyncState.STARTED ||
+ asyncContext.getState()==AsyncContextImpl.AsyncState.ERROR_DISPATCHING ||
+ asyncContext.getState()==AsyncContextImpl.AsyncState.COMPLETING);
}
public boolean isAsyncSupported() {
- // TODO SERVLET3 - async
- if (this.asyncSupported==null) {
+ if (this.asyncSupported == null) {
return true;
- } else {
- return asyncSupported.booleanValue();
}
+
+ return asyncSupported.booleanValue();
}
public AsyncContext getAsyncContext() {
}
public DispatcherType getDispatcherType() {
- // TODO SERVLET3 - dispatcher
- if (internalDispatcherType==null) {
+ if (internalDispatcherType == null) {
return DispatcherType.REQUEST;
- } else {
- return this.internalDispatcherType;
}
+
+ return this.internalDispatcherType;
}
// ---------------------------------------------------- HttpRequest Methods
* @return the URL decoded request URI
*/
public String getDecodedRequestURI() {
- return (coyoteRequest.decodedURI().toString());
+ return coyoteRequest.decodedURI().toString();
}
* @return the URL decoded request URI
*/
public MessageBytes getDecodedRequestURIMB() {
- return (coyoteRequest.decodedURI());
+ return coyoteRequest.decodedURI();
}
* Return the authentication type used for this Request.
*/
public String getAuthType() {
- return (authType);
+ return authType;
}
* of the Request.
*/
public String getContextPath() {
- return (mappingData.contextPath.toString());
+ return mappingData.contextPath.toString();
}
* @return the context path
*/
public MessageBytes getContextPathMB() {
- return (mappingData.contextPath);
+ return mappingData.contextPath;
}
String value = getHeader(name);
if (value == null) {
return (-1);
- } else {
- return (Integer.parseInt(value));
}
+ return Integer.parseInt(value);
}
* Return the path information associated with this Request.
*/
public String getPathInfo() {
- return (mappingData.pathInfo.toString());
+ return mappingData.pathInfo.toString();
}
* @return the path info
*/
public MessageBytes getPathInfoMB() {
- return (mappingData.pathInfo);
+ return mappingData.pathInfo;
}
public String getPathTranslated() {
if (context == null)
- return (null);
+ return null;
if (getPathInfo() == null) {
- return (null);
- } else {
- return (context.getServletContext().getRealPath(getPathInfo()));
+ return null;
}
+ return context.getServletContext().getRealPath(getPathInfo());
}
public String getQueryString() {
String queryString = coyoteRequest.queryString().toString();
if (queryString == null || queryString.equals("")) {
- return (null);
- } else {
- return queryString;
+ return null;
}
+
+ return queryString;
}
*/
public String getRemoteUser() {
- if (userPrincipal != null) {
- return (userPrincipal.getName());
- } else {
- return (null);
+ if (userPrincipal == null) {
+ return null;
}
-
+
+ return userPrincipal.getName();
}
* @return the request path
*/
public MessageBytes getRequestPathMB() {
- return (mappingData.requestPath);
+ return mappingData.requestPath;
}
* Return the session identifier included in this request, if any.
*/
public String getRequestedSessionId() {
- return (requestedSessionId);
+ return requestedSessionId;
}
}
url.append(getRequestURI());
- return (url);
-
+ return url;
}
* @return the servlet path
*/
public MessageBytes getServletPathMB() {
- return (mappingData.wrapperPath);
+ return mappingData.wrapperPath;
}
*/
public HttpSession getSession() {
Session session = doGetSession(true);
- if (session != null) {
- return session.getSession();
- } else {
+ if (session == null) {
return null;
}
+
+ return session.getSession();
}
*/
public HttpSession getSession(boolean create) {
Session session = doGetSession(create);
- if (session != null) {
- return session.getSession();
- } else {
+ if (session == null) {
return null;
}
+
+ return session.getSession();
}
*/
public boolean isRequestedSessionIdFromCookie() {
- if (requestedSessionId != null)
- return (requestedSessionCookie);
- else
- return (false);
-
+ if (requestedSessionId == null) {
+ return false;
+ }
+
+ return requestedSessionCookie;
}
*/
public boolean isRequestedSessionIdFromURL() {
- if (requestedSessionId != null)
- return (requestedSessionURL);
- else
- return (false);
-
+ if (requestedSessionId == null) {
+ return false;
+ }
+
+ return requestedSessionURL;
}
*/
public boolean isRequestedSessionIdValid() {
- if (requestedSessionId == null)
- return (false);
- if (context == null)
- return (false);
+ if (requestedSessionId == null) {
+ return false;
+ }
+
+ if (context == null) {
+ return false;
+ }
+
Manager manager = context.getManager();
- if (manager == null)
- return (false);
+ if (manager == null) {
+ return false;
+ }
+
Session session = null;
try {
session = manager.findSession(requestedSessionId);
} catch (IOException e) {
// Can't find the session
}
- if ((session != null) && session.isValid())
- return (true);
- else
- return (false);
+
+ if ((session == null) || !session.isValid()) {
+ return false;
+ }
+ return true;
}
// Have we got an authenticated principal at all?
if (userPrincipal == null)
- return (false);
+ return false;
// Identify the Realm we will use for checking role assignments
if (context == null)
- return (false);
+ return false;
+
Realm realm = context.getRealm();
if (realm == null)
- return (false);
+ return false;
// Check for a role alias defined in a <security-role-ref> element
if (wrapper != null) {
String realRole = wrapper.findSecurityReference(role);
- if ((realRole != null) &&
- realm.hasRole(userPrincipal, realRole))
- return (true);
+ if ((realRole != null) && realm.hasRole(userPrincipal, realRole))
+ return true;
}
// Check for a role defined directly as a <security-role>
return (realm.hasRole(userPrincipal, role));
-
}
* Return the principal that has been authenticated for this Request.
*/
public Principal getPrincipal() {
- return (userPrincipal);
+ return userPrincipal;
}
public Principal getUserPrincipal() {
if (userPrincipal instanceof GenericPrincipal) {
return ((GenericPrincipal) userPrincipal).getUserPrincipal();
- } else {
- return (userPrincipal);
}
+
+ return userPrincipal;
}
response.addSessionCookieInternal(cookie);
}
- if (session != null) {
- session.access();
- return (session);
- } else {
- return (null);
+ if (session == null) {
+ return null;
}
-
+
+ session.access();
+ return session;
}
protected String unescape(String s) {
byte[] result = new byte[length];
System.arraycopy(body.getBuffer(), 0, result, 0, length);
return result;
- } else {
- return body.getBuffer();
}
+
+ return body.getBuffer();
}
if ((ch != ' ') && (ch != '\t'))
sb.append(ch);
}
- value = sb.toString();
+ parser.setString(sb.toString());
+ } else {
+ parser.setString(value);
}
// Process each comma-delimited language specification
- parser.setString(value); // ASSERT: parser is available to us
int length = parser.getLength();
while (true) {