- private void writeLine(OutputStreamWriter out, String line)
- throws IOException {
- if (crypt == null) {
- out.write(line);
- bytesSent += line.length();
- } else {
- // TODO: how NOT to create so many big Strings?
- String b64 = crypt.encrypt64(line, false);
- out.write(b64);
- bytesSent += b64.length();
+ private Object rec(boolean asString) throws IOException,
+ NoSuchFieldException, NoSuchMethodException,
+ ClassNotFoundException, java.lang.NullPointerException {
+
+ synchronized (lock) {
+ if (server || contentToSend) {
+ if (contentToSend) {
+ out.flush();
+ contentToSend = false;
+ }
+
+ if (in.next()) {
+ // TODO: could be possible to check for non-crypt and only
+ // do it for crypt
+ InputStream read = new ReplaceInputStream(in.open(), //
+ new String[] { "\\\\", "\\b" }, //
+ new String[] { "\\", "\b" });
+
+ try {
+ if (crypt != null) {
+ read = crypt.decrypt64(read);
+ }
+
+ if (asString) {
+ return IOUtils.readSmallStream(read);
+ }
+
+ return new Importer().read(read).getValue();
+ } finally {
+ read.close();
+ }
+ }
+
+ if (!asString) {
+ throw new NullPointerException();
+ }
+ }
+
+ return null;