abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1177401 - /abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
Date Thu, 29 Sep 2011 19:06:08 GMT
Author: jmsnell
Date: Thu Sep 29 19:06:08 2011
New Revision: 1177401

URL: http://svn.apache.org/viewvc?rev=1177401&view=rev
Log: (empty)

Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java?rev=1177401&r1=1177400&r2=1177401&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
Thu Sep 29 19:06:08 2011
@@ -98,6 +98,9 @@ public class BinaryObject extends FileOb
    * The getInputStream method will automatically search for the 
    * "compression" property and attempt to automatically decompress
    * the stream when reading.
+   * 
+   * This will also automatically set the "length" property equal 
+   * to the total number of uncompressed, unencoded octets.
    */
   public void setContent(InputStream data, Hasher hash, CompressionCodec... comps) throws
IOException {
     ByteArrayOutputStream out = 
@@ -111,14 +114,16 @@ public class BinaryObject extends FileOb
     }
     
     byte[] d = new byte[1024];
-    int r = -1;
+    int r = -1, len = 0;
     while((r = data.read(d)) > -1) { 
+      len += r;
       if (hash != null)
         hash.update(d, 0, r);
       bout.write(d, 0, r);
       bout.flush();
     }
     bout.close();
+    setProperty("length",len);
     String c = new String(out.toByteArray(),"UTF-8");
     super.setContent(c);
     if (hash != null)



Mime
View raw message