Package javango.http

Source Code of javango.http.HttpRequest$Listener

package javango.http;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;

import javango.contrib.sessions.Session;
import javango.core.AnonymousUser;
import javango.core.User;


public class HttpRequest {

  public interface Listener {
    public void closeRequest(HttpRequest request) throws HttpException;
  }
 
  protected String path;
  protected String context;
  protected User user;
  protected Map<String, String[]> parameterMap;
  protected String method;
  protected Session session;
  protected List<Listener> listeners = new ArrayList<Listener>();
  protected Map<String, FileItem> files = null;

  /**
   * Helper function to get the first value for a parameter
   *
   * @param key
   * @return
   */
  public String getParameter(String key) {
    String[] v = parameterMap.get(key);
    if (v == null) return null;
    if (v.length == 0) return null;
    return v[0];
  }
 
  public void addListener(Listener listener) {
    listeners.add(listener);
  }
  public void close() throws HttpException {
    for (Listener l : listeners) {
      l.closeRequest(this);
    }
  }
 
  public String getPath() {
    return path;
  }

  public void setPath(String path) {
    this.path = path;
  }

  public String getContext() {
    return context;
  }

  public void setContext(String context) {
    this.context = context;
  }

  public User getUser() {
    if (user == null) {
      user = new AnonymousUser();
    }
    return user;
  }

  public void setUser(User user) {
    this.user = user;
  }

  public Map<String, String[]> getParameterMap() {
    return parameterMap;
  }

  public void setParameterMap(Map<String, String[]> parameterMap) {
    this.parameterMap = parameterMap;
  }

  public String getMethod() {
    return method;
  }

  public void setMethod(String method) {
    this.method = method;
  }

  public Session getSession() {
    return session;
  }

  public void setSession(Session session) {
    this.session = session;
  }

  public Map<String, FileItem> getFiles() {
    return files;
  }

  public void setFiles(Map<String, FileItem> files) {
    this.files = files;
  }
 

}
TOP

Related Classes of javango.http.HttpRequest$Listener

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.