Client for handlersocket server I wrote a simple client for handlersocket server, but I'm not a professional Java programmer and would like to know the opinion of Java developers on my code.

Well I have not yet decided how to implement a class HSResult.

My project is here

HSResult store initial query and answer as List of ChannelBuffers, where each ChannelBuffer it chunk of response according to the protocol.

package kom.handlersocket.result;

import org.jboss.netty.buffer.ChannelBuffer;
import kom.handlersocket.query.HSQuery;
import kom.handlersocket.core.SafeByteStream;

import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class HSResult {
    private final HashMap&lt;HSQuery, List&lt;ChannelBuffer&gt;&gt; resultSet = 
        new LinkedHashMap&lt;HSQuery, List&lt;ChannelBuffer&gt;&gt;();
    private final Charset charset;

    public HSResult(Charset charset) {
        this.charset = charset;
    }

    public void add(HSQuery query, List&lt;ChannelBuffer&gt; result) {
        resultSet.put(query, result);
    }

    public void debug() {
        SafeByteStream output = new SafeByteStream(1024, 65536, charset);

        for (Map.Entry&lt;HSQuery, List&lt;ChannelBuffer&gt;&gt; entry: resultSet.entrySet()) {
            entry.getKey().encode(output);
            System.out.print(new String(output.toByteArray(), charset));
            output.reset();

            for (ChannelBuffer buffer : entry.getValue()) {
                System.out.print(buffer.toString(charset));
                System.out.print("-");
            }

            System.out.println();
        }
    }
}
The type of the resultSet reference could be simply Map&lt;...&gt;:

private final Map&lt;HSQuery, List&lt;ChannelBuffer&gt;&gt; resultSet


Reference: Effective Java, 2nd edition, Item 52: Refer to objects by their interfaces
Instead of the Map&lt;HSQuery, List&lt;ChannelBuffer&gt;&gt; I'd use Guava's Multimap. It was 
designed for this case.
Constructors and methods should validate their input parameters.

public HSResult(Charset charset) {
    this.charset = charset;
}


Does it make sense to have a charset with null? If not, check it and throw an NullPointerException. (Effective Java, Second Edition, Item 38: Check parameters for validity)