// Path: src/main/java/org/jraf/irondad/Constants.java
// public class Constants {
//     public static final String TAG = "irondad/";
// 
//     public static final String PROJECT_FULL_NAME = "BoD irondad";
//     public static final String PROJECT_URL = "https://github.com/BoD/irondad";
//     public static final String VERSION_NAME = "v1.11.1"; // xxx When updating this, don't forget to update the version in pom.xml as well
// }
// 
// Path: src/main/java/org/jraf/irondad/util/Log.java
// public class Log {
//     public static void w(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " W " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void w(String tag, String msg) {
//         System.out.print(getDate() + " W " + tag + " " + msg + "\n");
//     }
// 
//     public static void e(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " E " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void e(String tag, String msg) {
//         System.out.print(getDate() + " E " + tag + " " + msg + "\n");
//     }
// 
//     public static void d(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " D " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void d(String tag, String msg) {
//         System.out.print(getDate() + " D " + tag + " " + msg + "\n");
//     }
// 
//     public static void i(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " I " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void i(String tag, String msg) {
//         System.out.print(getDate() + " I " + tag + " " + msg + "\n");
//     }
// 
//     private static String getDate() {
//         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss");
//         return sdf.format(new Date());
//     }
// 
//     private static String getStackTraceString(Throwable tr) {
//         if (tr == null) {
//             return "";
//         }
// 
//         StringWriter sw = new StringWriter();
//         PrintWriter pw = new PrintWriter(sw);
//         tr.printStackTrace(pw);
//         return sw.toString();
//     }
// }


import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.jraf.irondad.Constants;
import org.jraf.irondad.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
/*
 * This source is part of the
 *      _____  ___   ____
 *  __ / / _ \/ _ | / __/___  _______ _
 * / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
 * \___/_/|_/_/ |_/_/ (_)___/_/  \_, /
 *                              /___/
 * repository.
 *
 * Copyright (C) 2013 Benoit 'BoD' Lubek (BoD@JRAF.org)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see
 * <http://www.gnu.org/licenses/>.
 */
package org.jraf.irondad.protocol;



public class Connection {
    private static final String TAG = Constants.TAG + Connection.class.getSimpleName();
    private static final String CR_LF = "\r\n";

    private Client mClient;
    private final BufferedReader mBufferedReader;
    private final OutputStream mOutputStream;

    public Connection(Client client, Socket socket) throws IOException {
        mClient = client;
        mBufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
        mOutputStream = socket.getOutputStream();
    }

    public void send(String line) throws IOException {
// Path: src/main/java/org/jraf/irondad/Constants.java
// public class Constants {
//     public static final String TAG = "irondad/";
// 
//     public static final String PROJECT_FULL_NAME = "BoD irondad";
//     public static final String PROJECT_URL = "https://github.com/BoD/irondad";
//     public static final String VERSION_NAME = "v1.11.1"; // xxx When updating this, don't forget to update the version in pom.xml as well
// }
// 
// Path: src/main/java/org/jraf/irondad/util/Log.java
// public class Log {
//     public static void w(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " W " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void w(String tag, String msg) {
//         System.out.print(getDate() + " W " + tag + " " + msg + "\n");
//     }
// 
//     public static void e(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " E " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void e(String tag, String msg) {
//         System.out.print(getDate() + " E " + tag + " " + msg + "\n");
//     }
// 
//     public static void d(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " D " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void d(String tag, String msg) {
//         System.out.print(getDate() + " D " + tag + " " + msg + "\n");
//     }
// 
//     public static void i(String tag, String msg, Throwable t) {
//         System.out.print(getDate() + " I " + tag + " " + msg + "\n" + getStackTraceString(t));
//     }
// 
//     public static void i(String tag, String msg) {
//         System.out.print(getDate() + " I " + tag + " " + msg + "\n");
//     }
// 
//     private static String getDate() {
//         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss");
//         return sdf.format(new Date());
//     }
// 
//     private static String getStackTraceString(Throwable tr) {
//         if (tr == null) {
//             return "";
//         }
// 
//         StringWriter sw = new StringWriter();
//         PrintWriter pw = new PrintWriter(sw);
//         tr.printStackTrace(pw);
//         return sw.toString();
//     }
// }


// Path: src/main/java/org/jraf/irondad/protocol/Connection.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.jraf.irondad.Constants;
import org.jraf.irondad.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

/*
 * This source is part of the
 *      _____  ___   ____
 *  __ / / _ \/ _ | / __/___  _______ _
 * / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
 * \___/_/|_/_/ |_/_/ (_)___/_/  \_, /
 *                              /___/
 * repository.
 *
 * Copyright (C) 2013 Benoit 'BoD' Lubek (BoD@JRAF.org)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see
 * <http://www.gnu.org/licenses/>.
 */
package org.jraf.irondad.protocol;



public class Connection {
    private static final String TAG = Constants.TAG + Connection.class.getSimpleName();
    private static final String CR_LF = "\r\n";

    private Client mClient;
    private final BufferedReader mBufferedReader;
    private final OutputStream mOutputStream;

    public Connection(Client client, Socket socket) throws IOException {
        mClient = client;
        mBufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
        mOutputStream = socket.getOutputStream();
    }

    public void send(String line) throws IOException {
        Log.d(TAG, "SND " + line);