package be.ephec.nsjc.jws.model;

public class Response {

}

@@ -55,7 +55,3139 @@
 e %7B%0A
+    private HashMap%3CString, String%3E headers = new HashMap();%0A    private String body;%0A    private ReponseCode HTTPCode;%0A%0A    public Response(ResponseCode HTTPCode, HashMap%3CString, String%3E headers, String body) %7B%0A        /** Full constructor of Reponse%0A         * param code : the HTTP code%0A         * param headers : a list of HTTP headers%0A         * param body : the HTTP body%0A         */%0A        this.HTTPCode = HTTPCode;%0A        this.headers = headers;%0A        this.body = body;%0A    %7D%0A%0A    public Response(ResponseCode HTTPCode, char%5B%5D body) %7B%0A        /** Constructor of Response without any header%0A         * param code : the HTTP code%0A         * param body : the HTTP body%0A         */%0A        this.HTTPCode = HTTPCode;%0A        this.body = body;%0A    %7D%0A%0A    public Response(ResponseCode code) %7B%0A        /** Constructor of Reponse without any headers and withut body%0A         * param code: the HTTP code%0A         */%0A        this.code = code;%0A    %7D%0A%0A    public void addHeader(Header header) %7B%0A        /** Append a header to the current list of headers%0A         * param header : the header to append%0A         */%0A        this.headers.set(header.label, header.value);%0A    %7D%0A%0A    public Header delHeader(String label) %7B%0A        /** Remove a header from the current list of headers%0A         * param label : the header label to remove%0A         * return : a Header with the label and its value if it exists or null%0A         */%0A        if (this.headers.containsKey(label)) %7B%0A            return new Header(label, this.headers.remove(label));%0A        %7D%0A        return null;%0A    %7D%0A%0A    public boolean hasHeader(Header header) %7B%0A        /** Check if the header is in the list of headers%0A         * param header : the header that will be checked%0A         * return : whether the object is in the hashmap or not%0A         */%0A        return this.hasHeader(header.label);%0A    %7D%0A%0A    public boolean hasHeader(String headerLabel) %7B%0A        /** Check if the label is in the list of headers%0A         * param headerLabel : the label that will be checked%0A         * return : whether the label is in the hashmap or not%0A         */%0A        return this.headers.containsKey(headerLabel);%0A    %7D%0A%0A    public byte%5B%5D toByteArray() %7B%0A        /** Convert the response to a sendable format%0A         * return : a byte array of the current response%0A         */%0A        return this.toString().getBytes(StandardCharsets.UTF_8);%0A    %7D%0A%0A    public String toString() %7B%0A        /** Convert the response to a printable format%0A         * return : a string of the current response%0A         */%0A        String res = %22%22;%0A        res += %22HTTP1.1 %22 + this.HTTPCode.code + %22 %22 + this.HTTPCode.desc + %22%5Cr%5Cn%22;%0A        for (String label in this.headers) %7B%0A            res += label + %22 %22 + this.headers.get(label) + %22%5Cr%5Cn%22%0A        %7D%0A        res += this.body;%0A        return res;%0A    %7D%0A%0A    public void setBody(String body) %7B%0A        this.body = body;%0A    %7D%0A    public String getBody() %7B%0A        return this.body;%0A    %7D%0A%0A    public void setHTTPCode(ResponseCode HTTPCode) %7B%0A        this.HTTPCode = HTTPCode;%0A    %7D%0A    public ResponseCode getHTTPCode() %7B%0A        return this.HTTPCode;%0A    %7D
 %0A%7D
-%0A

Implement Response