+ try {
+ return (String) send(out, line, true);
+ } catch (NoSuchFieldException e) {
+ // Cannot happen
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // Cannot happen
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // Cannot happen
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * Reserved for the server (externally): flush the data to the client and
+ * retrieve its answer.
+ * <p>
+ * Also used internally for the client (only do something if there is
+ * contentToSend).
+ * <p>
+ * Will only flush the data if there is contentToSend.
+ *
+ * @return the answer (which can be NULL if no more content)
+ *
+ * @throws IOException
+ * in case of I/O error
+ * @throws SSLException
+ * in case of crypt error
+ */
+ protected String recString() throws IOException {
+ try {
+ return (String) rec(true);
+ } catch (NoSuchFieldException e) {
+ // Cannot happen
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // Cannot happen
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // Cannot happen
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // Should happen
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * Serialise and send the given object to the counter part (and, only for
+ * client, return the deserialised answer -- the server will always receive
+ * NULL).
+ *
+ * @param out
+ * the stream to write to
+ * @param data
+ * the data to write
+ * @param asString
+ * TRUE to write it as a String, FALSE to write it as an Object
+ *
+ * @return the answer (which can be NULL if no answer, or NULL for an answer
+ * which is NULL) if this action is a client, always NULL if it is a
+ * server
+ *
+ * @throws IOException
+ * in case of I/O error
+ * @throws SSLException
+ * in case of crypt error
+ * @throws IOException
+ * in case of I/O error
+ * @throws NoSuchFieldException
+ * if the serialised data contains information about a field
+ * which does actually not exist in the class we know of
+ * @throws NoSuchMethodException
+ * if a class described in the serialised data cannot be created
+ * because it is not compatible with this code
+ * @throws ClassNotFoundException
+ * if a class described in the serialised data cannot be found
+ */
+ private Object send(BufferedOutputStream out, Object data, boolean asString)
+ throws IOException, NoSuchFieldException, NoSuchMethodException,
+ ClassNotFoundException, java.lang.NullPointerException {
+