package org.apache.struts.action;

import java.io.Serializable;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.upload.MultipartRequestHandler;

public abstract class ActionForm implements Serializable {
  protected transient ActionServlet servlet = null;
  
  protected transient MultipartRequestHandler multipartRequestHandler;
  
  protected ActionServlet getServlet() {
    return this.servlet;
  }
  
  public ActionServletWrapper getServletWrapper() {
    return new ActionServletWrapper(getServlet());
  }
  
  public MultipartRequestHandler getMultipartRequestHandler() {
    return this.multipartRequestHandler;
  }
  
  public void setServlet(ActionServlet servlet) {
    this.servlet = servlet;
  }
  
  public void setMultipartRequestHandler(MultipartRequestHandler multipartRequestHandler) {
    this.multipartRequestHandler = multipartRequestHandler;
  }
  
  public void reset(ActionMapping mapping, ServletRequest request) {
    try {
      reset(mapping, (HttpServletRequest)request);
    } catch (ClassCastException e) {}
  }
  
  public void reset(ActionMapping mapping, HttpServletRequest request) {}
  
  public ActionErrors validate(ActionMapping mapping, ServletRequest request) {
    try {
      return validate(mapping, (HttpServletRequest)request);
    } catch (ClassCastException e) {
      return null;
    } 
  }
  
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return null;
  }
}
