hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r280899 - in /jakarta/httpclient/trunk/http-common/src: java/org/apache/http/impl/io/ test/org/apache/http/mockup/
Date Wed, 14 Sep 2005 18:11:36 GMT
Author: olegk
Date: Wed Sep 14 11:11:24 2005
New Revision: 280899

URL: http://svn.apache.org/viewcvs?rev=280899&view=rev
Log:
InputStreamHttpDataReceiver and OutputStreamHttpDataTransmitter made abstract

Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OutputStreamHttpDataTransmitter.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/InputStreamHttpDataReceiverMockup.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/OutputStreamHttpDataTransmitterMockup.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java?rev=280899&r1=280898&r2=280899&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java
Wed Sep 14 11:11:24 2005
@@ -44,13 +44,12 @@
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
  */
-public class InputStreamHttpDataReceiver implements HttpDataReceiver {
+public abstract class InputStreamHttpDataReceiver implements HttpDataReceiver {
 
     private static final int CR = 13;
     private static final int LF = 10;
     
-    private final InputStream instream;
-    
+    private InputStream instream;
     private byte[] buffer;
     private int bufferpos;
     private int bufferlen;
@@ -59,15 +58,14 @@
     
     private String charset = "US-ASCII";
     
-    protected InputStreamHttpDataReceiver(final InputStream instream) {
-        super();
+    protected void init(final InputStream instream, int buffersize) {
         if (instream == null) {
             throw new IllegalArgumentException("Input stream may not be null");
         }
+        if (buffersize <= 0) {
+            throw new IllegalArgumentException("Buffer size may not be negative or zero");
+        }
         this.instream = instream;
-    }
-
-    protected void initBuffer(int buffersize) {
         this.buffer = new byte[buffersize];
         this.bufferpos = 0;
         this.bufferlen = 0;

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java?rev=280899&r1=280898&r2=280899&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataReceiver.java
Wed Sep 14 11:11:24 2005
@@ -72,13 +72,16 @@
     private final Socket socket;
     
     public OldIOSocketHttpDataReceiver(final Socket socket) throws IOException {
-        super(socket.getInputStream());
+        super();
+        if (socket == null) {
+            throw new IllegalArgumentException("Socket may not be null");
+        }
         this.socket = socket;
         int buffersize = socket.getReceiveBufferSize();
         if (buffersize < 2048) {
             buffersize = 2048;
         }
-        initBuffer(buffersize);
+        init(socket.getInputStream(), buffersize);
     }
     
     public boolean isDataAvailable(int timeout) throws IOException {

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java?rev=280899&r1=280898&r2=280899&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OldIOSocketHttpDataTransmitter.java
Wed Sep 14 11:11:24 2005
@@ -45,12 +45,15 @@
 public class OldIOSocketHttpDataTransmitter extends OutputStreamHttpDataTransmitter {
 
     public OldIOSocketHttpDataTransmitter(final Socket socket) throws IOException {
-        super(socket.getOutputStream());
+        super();
+        if (socket == null) {
+            throw new IllegalArgumentException("Socket may not be null");
+        }
         int buffersize = socket.getSendBufferSize();
         if (buffersize < 2048) {
             buffersize = 2048;
         }
-        initBuffer(buffersize);
+        init(socket.getOutputStream(), buffersize);
     }
     
 }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OutputStreamHttpDataTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OutputStreamHttpDataTransmitter.java?rev=280899&r1=280898&r2=280899&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OutputStreamHttpDataTransmitter.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/OutputStreamHttpDataTransmitter.java
Wed Sep 14 11:11:24 2005
@@ -42,28 +42,26 @@
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
  */
-public class OutputStreamHttpDataTransmitter implements HttpDataTransmitter {
+public abstract class OutputStreamHttpDataTransmitter implements HttpDataTransmitter {
 
     private static final int CR = 13;
     private static final int LF = 10;
     private static final byte[] CRLF = new byte[] {CR, LF};
 
-    private final OutputStream outstream;
-    
+    private OutputStream outstream;
     private byte[] buffer;
     private int bufferlen;
         
     private String charset = "US-ASCII";
     
-    protected OutputStreamHttpDataTransmitter(final OutputStream outstream) {
-        super();
+    protected void init(final OutputStream outstream, int buffersize) {
         if (outstream == null) {
             throw new IllegalArgumentException("Input stream may not be null");
         }
+        if (buffersize <= 0) {
+            throw new IllegalArgumentException("Buffer size may not be negative or zero");
+        }
         this.outstream = outstream;
-    }
-
-    protected void initBuffer(int buffersize) {
         this.buffer = new byte[buffersize];
         this.bufferlen = 0;
     }

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/InputStreamHttpDataReceiverMockup.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/InputStreamHttpDataReceiverMockup.java?rev=280899&r1=280898&r2=280899&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/InputStreamHttpDataReceiverMockup.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/InputStreamHttpDataReceiverMockup.java
Wed Sep 14 11:11:24 2005
@@ -16,11 +16,8 @@
     public static int BUFFER_SIZE = 16;
     
     public InputStreamHttpDataReceiverMockup(final InputStream instream, int buffersize)
{
-        super(instream);
-        if (buffersize <= 0) {
-            throw new IllegalArgumentException("Buffer size may not be negative or zero");
-        }
-        initBuffer(buffersize);
+        super();
+        init(instream, buffersize);
     }
 
     public InputStreamHttpDataReceiverMockup(final byte[] bytes) {
@@ -28,8 +25,7 @@
     }
 
     public InputStreamHttpDataReceiverMockup(final byte[] bytes, int buffersize) {
-        super(new ByteArrayInputStream(bytes));
-        initBuffer(buffersize);
+        this(new ByteArrayInputStream(bytes), buffersize);
     }
 
     public InputStreamHttpDataReceiverMockup(final String s, final String charset, int buffersize)


Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/OutputStreamHttpDataTransmitterMockup.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/OutputStreamHttpDataTransmitterMockup.java?rev=280899&r1=280898&r2=280899&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/OutputStreamHttpDataTransmitterMockup.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/mockup/OutputStreamHttpDataTransmitterMockup.java
Wed Sep 14 11:11:24 2005
@@ -16,11 +16,8 @@
     public static int BUFFER_SIZE = 16;
     
     public OutputStreamHttpDataTransmitterMockup(final OutputStream outstream, int buffersize)
{
-        super(outstream);
-        if (buffersize <= 0) {
-            throw new IllegalArgumentException("Buffer size may not be negative or zero");
-        }
-        initBuffer(buffersize);
+        super();
+        init(outstream, buffersize);
     }
 
     public OutputStreamHttpDataTransmitterMockup(final ByteArrayOutputStream buffer) {



Mime
View raw message