diff --git a/project.properties b/project.properties index 3e06a5c..e7d8533 100644 --- a/project.properties +++ b/project.properties @@ -1,6 +1,6 @@ -#Tue, 27 Nov 2012 08:38:33 -0600 +#Thu, 14 Mar 2013 04:49:38 -0500 name=jdb-util -version=1.8 +version=1.9 lib.local=true -build.number=2 +build.number=1 diff --git a/src/main/com/jdbernard/io/NonBlockingStreamReader.groovy b/src/main/com/jdbernard/io/NonBlockingStreamReader.groovy new file mode 100644 index 0000000..a9d712b --- /dev/null +++ b/src/main/com/jdbernard/io/NonBlockingStreamReader.groovy @@ -0,0 +1,21 @@ +package com.jdbernard.io; + +public class NonBlockingReader implements Runnable { + + private Reader rin + private LinkedList buffer = [] + + public void run() { + String line = null + try { + while((line = rin.readLine()) != null && + !Thread.currentThread().isInterrupted()) + storeLine(line) } + catch (InterruptedException ie) { Thread.currentThread().interrupt() } } + + public synchronized String readLine() { return buffer.poll() } + private synchronized void storeLine(String line) { buffer << line } + + public NonBlockingReader(def sin) { + this.rin = new InputStreamReader(sin) } +} diff --git a/src/main/com/jdbernard/util/NullOutputStream.java b/src/main/com/jdbernard/io/NullOutputStream.java similarity index 64% rename from src/main/com/jdbernard/util/NullOutputStream.java rename to src/main/com/jdbernard/io/NullOutputStream.java index 59f708f..e270c0a 100644 --- a/src/main/com/jdbernard/util/NullOutputStream.java +++ b/src/main/com/jdbernard/io/NullOutputStream.java @@ -1,7 +1,12 @@ +/** # NullOutputStream + * @author Jonathan Bernard (jdbernard@gmail.com) + * @copyright 2011 Jonathan Bernard + */ package com.jdbernard.util; import java.io.OutputStream; +/** This implementation of OutputStream drops all data sent to it. */ public class NullOutputStream extends OutputStream { public NullOutputStream() {} diff --git a/src/main/com/jdbernard/util/WrappedPrinter.java b/src/main/com/jdbernard/io/WrappedPrinter.java similarity index 100% rename from src/main/com/jdbernard/util/WrappedPrinter.java rename to src/main/com/jdbernard/io/WrappedPrinter.java diff --git a/src/main/com/jdbernard/net/HttpContext.groovy b/src/main/com/jdbernard/net/HttpContext.groovy index 3fa7106..5b1e078 100644 --- a/src/main/com/jdbernard/net/HttpContext.groovy +++ b/src/main/com/jdbernard/net/HttpContext.groovy @@ -1,4 +1,5 @@ -/** @author Jonathan Bernard (jdbernard@gmail.com) +/** # HTTP Context + * @author Jonathan Bernard (jdbernard@gmail.com) * @copyright 2013 Jonathan Bernard. */ package com.jdbernard.net