All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cat.inspiracio.servlet.SetServletConfig Maven / Gradle / Ivy

Go to download

Dummy Servlet provides some implementations for the interfaces and classes of the Java Servlet spec that are useful for testing and simulation. Version 5.0.0 is for Servlet 5.0.0.

The newest version!
package cat.inspiracio.servlet;

import cat.inspiracio.util.CollectionEnumeration;
import jakarta.servlet.ServletContext;

import java.util.Enumeration;
import java.util.HashMap;

/** Servlet configuration, the fields of wich can be set.
 * Good for testing. */
public class SetServletConfig extends InitialServletConfig {

    private String name;

    private ServletContext context = new SetServletContext();

    private HashMap initParameters;

    /** Make one. */
    public SetServletConfig(){}

    /** Sets name
     * @param n to this.
     * @return this */
    public SetServletConfig setName(String n){name=n;return this;}
    @Override public String getServletName(){return name;}

    /** Sets servlet context
     * @param c to this.
     * @return this */
    public SetServletConfig setServletContext(ServletContext c){context=c;return this;}
    @Override public ServletContext getServletContext(){return context;}

    /** Sets init parameter
     * @param key this key
     * @param value to this value.
     * @return this */
    public SetServletConfig setInitParameter(String key,String value){initParameters.put(key,value);return this;}
    @Override public String getInitParameter(String key){return initParameters.get(key);}
    @Override public Enumeration getInitParameterNames(){return new CollectionEnumeration<>(initParameters.keySet());}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy