<commit_before>package com.example.myfirstapp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Queue;

/**
 * TCP Receiver Worker to handle established incoming connections.
 * @author <NAME> <<EMAIL>> ID#0906172
 * @version Apr 11, 2014
 */
public class TcpReceiverWorker implements Runnable {
    private Socket sender;
    private final Queue<String> uiMessageQueue;

    /**
     * Constructor for TcpReceiverWorker class.
     * @param sender the socket object that is connect to the sender
     * @param uiMessageQueue Queue which will take the received messages
     */
    public TcpReceiverWorker(Socket sender, Queue<String> uiMessageQueue) {
        this.sender = sender;
        this.uiMessageQueue = uiMessageQueue;
    }
    
    /**
     * Default method called by thread objects.
     */
    @Override
    public void run() {
        try(BufferedReader in = new BufferedReader(new InputStreamReader(
                sender.getInputStream()))) {
            String message = getWholeMessage(in);
            showMessage(sender.getInetAddress(), message);
        } catch (IOException e) {
            // TODO write error recovery code
            System.out.println(":: Can't retrieve message");
            e.printStackTrace();
        }
    }
    
    /**
     * Retrieve the whole message, rather than retrieving a line.
     * @param in BufferedReader instance to read from
     * @return the message in the specified BufferedReader instance
     * @throws IOException 
     */
    private String getWholeMessage(BufferedReader in) throws IOException {
        StringBuilder sb = new StringBuilder();
        String input = in.readLine();<commit_msg>Updated TcpReceiverWorker.java. Match specification for API 8.<commit_after>package com.example.myfirstapp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Queue;

/**
 * TCP Receiver Worker to handle established incoming connections.
 * @author <NAME> <<EMAIL>> ID#0906172
 * @version Apr 11, 2014
 */
public class TcpReceiverWorker implements Runnable {
    private Socket sender;
    private final Queue<String> uiMessageQueue;

    /**
     * Constructor for TcpReceiverWorker class.
     * @param sender the socket object that is connect to the sender
     * @param uiMessageQueue Queue which will take the received messages
     */
    public TcpReceiverWorker(Socket sender, Queue<String> uiMessageQueue) {
        this.sender = sender;
        this.uiMessageQueue = uiMessageQueue;
    }
    
    /**
     * Default method called by thread objects.
     */
    @Override
    public void run() {
        try {
        	BufferedReader in = new BufferedReader(
        			new InputStreamReader(
        					sender.getInputStream()));
            String message = getWholeMessage(in);
            showMessage(sender.getInetAddress(), message);
            in.close();
        } catch (IOException e) {
            // TODO write error recovery code
            System.out.println(":: Can't retrieve message");
            e.printStackTrace();
        }
    }
    
    /**
     * Retrieve the whole message, rather than retrieving a line.
     * @param in BufferedReader instance to read from
     * @return the message in the specified BufferedReader instance
     * @throws IOException 
     */
    private String getWholeMessage(BufferedReader in) throws IOException {
        StringBuilder sb = new StringBuilder();
        String input = in.readLine();
{'fraction_non_alphanumeric': 0.08522261677137394, 'fraction_numerical': 0.007375034143676591, 'mean_word_length': 2.7405515832482124, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 13, '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': '2361590', 'n_tokens_mistral': 971, 'n_tokens_neox': 933, 'n_words': 304}