<commit_before>package me.joshuamarquez.sails.io;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * The JWR (JSON WebSocket Response) received from a Sails server.
 */
public class JWR {

    private int statusCode;
    private Map<String, String> headers;
    private String body;

    private JSONObject jsonObjectResponse;

    /**
     * @param response {@link Object}
     *         => :statusCode
     *         => :body
     *         => :headers
     */
    public JWR(Object response) {
        jsonObjectResponse = (JSONObject) response;

        try {
            statusCode = jsonObjectResponse.getInt("statusCode");

            headers = new HashMap<String, String>();

            JSONObject jsonHeaders = jsonObjectResponse.getJSONObject("headers");
            Iterator<?> keys = jsonHeaders.keys();

            while (keys.hasNext()) {
                String key = (String) keys.next();
                headers.put(key, jsonHeaders.getString(key));
            }

            body = jsonObjectResponse.getString("body");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public int getStatusCode() {
        return statusCode;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public String getBody() {
        return body;
    }

    public JSONObject getJsonObjectResponse() {
        return jsonObjectResponse;
    }

    @Override
    public String toString() {
        return String.format("Status :: %d\nHeaders Count :: %d\nBody :: %s",
                statusCode, headers.size(), body);
    }
}<commit_msg>isError() added to JWR<commit_after>package me.joshuamarquez.sails.io;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * The JWR (JSON WebSocket Response) received from a Sails server.
 */
public class JWR {

    private int statusCode;
    private Map<String, String> headers;
    private String body;

    private JSONObject jsonObjectResponse;

    /**
     * @param response {@link Object}
     *         => :statusCode
     *         => :body
     *         => :headers
     */
    public JWR(JSONObject response) {
        jsonObjectResponse = response;

        try {
            statusCode = jsonObjectResponse.getInt("statusCode");

            headers = new HashMap<String, String>();

            JSONObject jsonHeaders = jsonObjectResponse.getJSONObject("headers");
            Iterator<?> keys = jsonHeaders.keys();

            while (keys.hasNext()) {
                String key = (String) keys.next();
                headers.put(key, jsonHeaders.getString(key));
            }

            body = jsonObjectResponse.getString("body");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public int getStatusCode() {
        return statusCode;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public String getBody() {
        return body;
    }

    public boolean isError() {
        return this.statusCode < 200 || this.statusCode >= 400;
    }

    public JSONObject getJsonObjectResponse() {
        return jsonObjectResponse;
    }

    @Override
    public String toString() {
        return String.format("Status :: %d\nHeaders Count :: %d\nBody :: %s",
                statusCode, headers.size(), body);
    }
}
{'fraction_non_alphanumeric': 0.11104783599088838, 'fraction_numerical': 0.0017084282460136675, 'mean_word_length': 2.1563342318059298, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1783141', 'n_tokens_mistral': 967, 'n_tokens_neox': 932, 'n_words': 234}