abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r600722 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
Date Mon, 03 Dec 2007 23:19:31 GMT
Author: jmsnell
Date: Mon Dec  3 15:19:30 2007
New Revision: 600722

URL: http://svn.apache.org/viewvc?rev=600722&view=rev
Log:
A few utility constructors of MediaResponseContext accepting byte[] and ReadableByteChannel.

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java?rev=600722&r1=600721&r2=600722&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
Mon Dec  3 15:19:30 2007
@@ -17,13 +17,18 @@
 */
 package org.apache.abdera.protocol.server.impl;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
 import java.util.Date;
 
+import org.apache.abdera.util.EntityTag;
+
 
 /**
  * ResponseContext implementation for arbitrary media resources
@@ -32,6 +37,22 @@
   extends AbstractResponseContext {
 
   private InputStream in;
+
+  public MediaResponseContext(
+    InputStream in, 
+    EntityTag etag, 
+    int status) {
+      this.in = in;
+      this.status = status;
+      setEntityTag(etag);
+  }
+  
+  public MediaResponseContext(
+    InputStream in,  
+    int status) {
+      this.in = in;
+      this.status = status;
+  }
   
   public MediaResponseContext(
     InputStream in, 
@@ -41,6 +62,46 @@
       this.status = status;
       setLastModified(lastmodified);
   }
+
+  public MediaResponseContext(
+    byte[] bytes,
+    int status) {
+      this(new ByteArrayInputStream(bytes),status);
+  }
+  
+  public MediaResponseContext(
+    byte[] bytes,
+    Date lastmodified,
+    int status) {
+      this(new ByteArrayInputStream(bytes),lastmodified,status);
+  }
+
+  public MediaResponseContext(
+    byte[] bytes,
+    EntityTag etag,
+    int status) {
+      this(new ByteArrayInputStream(bytes),etag,status);
+  }
+
+  public MediaResponseContext(
+    ReadableByteChannel channel,
+    int status) {
+      this(Channels.newInputStream(channel),status);
+  }
+  
+  public MediaResponseContext(
+    ReadableByteChannel channel,
+    Date lastmodified,
+    int status) {
+      this(Channels.newInputStream(channel),lastmodified,status);
+  }
+
+  public MediaResponseContext(
+    ReadableByteChannel channel,
+    EntityTag etag,
+    int status) {
+      this(Channels.newInputStream(channel),etag,status);
+  }
   
   public boolean hasEntity() {
     return in != null;
@@ -50,7 +111,7 @@
     OutputStream out) 
       throws IOException {
     if (in != null) {
-      byte[] buf = new byte[100];
+      byte[] buf = new byte[500];
       int r = -1;
       while ((r = in.read(buf)) != -1) {
         out.write(buf,0,r);
@@ -64,7 +125,7 @@
       throws IOException {
     if (in != null) {
       InputStreamReader rdr = new InputStreamReader(in);
-      char[] buf = new char[100];
+      char[] buf = new char[500];
       int r = -1;
       while ((r = rdr.read(buf)) != -1) {
         out.write(buf,0,r);



Mime
View raw message