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

colesico.framework.weblet.ContentResponse Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
package colesico.framework.weblet;

import colesico.framework.http.HttpCookie;

import java.util.*;

abstract public class ContentResponse {

    public static final int DEFAULT_STATUS_CODE = 200;

    /**
     * Http response content type
     */
    protected final String contentType;

    /**
     * Http response status code
     */
    protected final int statusCode;

    private Map> headers = new HashMap<>();

    private Set cookies = new HashSet<>();

    public ContentResponse(String contentType, int statusCode) {
        this.contentType = contentType;
        this.statusCode = statusCode;
    }

    public void setHeader(String name, String vale) {
        List hValues = headers.computeIfAbsent(name, n -> new ArrayList<>());
        hValues.add(vale);
    }

    public void setCookie(HttpCookie cookie) {
        cookies.add(cookie);
    }

    public String getContentType() {
        return contentType;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public Map> getHeaders() {
        return headers;
    }

    public Set getCookies() {
        return cookies;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy