StringUtils: NPE fix if bad arg for padding, tests
[nikiroo-utils.git] / src / be / nikiroo / utils / serial / server / ConnectActionClientString.java
1 package be.nikiroo.utils.serial.server;
2
3 import java.io.IOException;
4 import java.net.Socket;
5
6 import be.nikiroo.utils.Version;
7
8 /**
9 * Class used for the client basic handling.
10 * <p>
11 * It represents a single action: a client is expected to only execute one
12 * action.
13 *
14 * @author niki
15 */
16 public class ConnectActionClientString extends ConnectActionClient {
17 /**
18 * Create a new {@link ConnectActionClientString} with the current
19 * application version (see {@link Version#getCurrentVersion()}) as the
20 * client version.
21 *
22 * @param s
23 * the socket to bind to
24 */
25 public ConnectActionClientString(Socket s) {
26 super(s);
27 }
28
29 /**
30 * Create a new {@link ConnectActionClientString} with the current
31 * application version (see {@link Version#getCurrentVersion()}) as the
32 * client version.
33 *
34 * @param host
35 * the host to bind to
36 * @param port
37 * the port to bind to
38 * @param ssl
39 * TRUE for an SSL connection, FALSE for plain text
40 *
41 * @throws IOException
42 * in case of I/O error when creating the socket
43 */
44 public ConnectActionClientString(String host, int port, boolean ssl)
45 throws IOException {
46 super(host, port, ssl);
47 }
48
49 /**
50 * Create a new {@link ConnectActionClientString}.
51 *
52 * @param host
53 * the host to bind to
54 * @param port
55 * the port to bind to
56 * @param ssl
57 * TRUE for an SSL connection, FALSE for plain text
58 * @param version
59 * the client version
60 *
61 * @throws IOException
62 * in case of I/O error when creating the socket
63 */
64 public ConnectActionClientString(String host, int port, boolean ssl,
65 Version version) throws IOException {
66 super(host, port, ssl, version);
67 }
68
69 /**
70 * Create a new {@link ConnectActionClientString}.
71 *
72 * @param s
73 * the socket to bind to
74 * @param version
75 * the client version
76 */
77 public ConnectActionClientString(Socket s, Version version) {
78 super(s, version);
79 }
80
81 /**
82 * Send the given object to the server (and return the answer).
83 *
84 * @param data
85 * the data to send
86 *
87 * @return the answer, which can be NULL
88 *
89 * @throws IOException
90 * in case of I/O error
91 */
92 public String send(String data) throws IOException {
93 return action.sendString(data);
94 }
95 }