abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1177424 - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/extra/ core/src/main/java/org/apache/abdera2/parser/axiom/ examples/src/main/java/org/apache/abdera2/examples/activities/
Date Thu, 29 Sep 2011 20:38:34 GMT
Author: jmsnell
Date: Thu Sep 29 20:38:34 2011
New Revision: 1177424

URL: http://svn.apache.org/viewvc?rev=1177424&view=rev
Log:
use a different property for the base64 data in the binary object and fix a bug that was breaking
test cases

Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.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=1177424&r1=1177423&r2=1177424&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 20:38:34 2011
@@ -52,12 +52,12 @@ public class BinaryObject extends FileOb
     setDisplayName(displayName);
   }
     
-  public void setContent(DataHandler data, CompressionCodec... comps) throws IOException
{
-    setContent(data,(Hasher)null,comps);
+  public void setData(DataHandler data, CompressionCodec... comps) throws IOException {
+    setData(data,(Hasher)null,comps);
   }
   
-  public void setContent(byte[] data, Hasher hash, CompressionCodec... comps) throws IOException
{
-    setContent(new ByteArrayInputStream(data),hash,comps);
+  public void setData(byte[] data, Hasher hash, CompressionCodec... comps) throws IOException
{
+    setData(new ByteArrayInputStream(data),hash,comps);
   }
   
   /**
@@ -70,13 +70,13 @@ public class BinaryObject extends FileOb
    * and use a custom TypeAdapter for the BinaryObject to read and
    * consume the DataHandler during the actual Serialization.
    */
-  public void setContent(DataHandler data,Hasher hash, CompressionCodec... comps) throws
IOException {
-    setContent(data.getInputStream(),hash,comps);
+  public void setData(DataHandler data,Hasher hash, CompressionCodec... comps) throws IOException
{
+    setData(data.getInputStream(),hash,comps);
     setMimeType(data.getContentType());
   }
   
-  public void setContent(InputStream data) throws IOException {
-    setContent(data,null);
+  public void setData(InputStream data) throws IOException {
+    setData(data,null);
   }
   
   /**
@@ -102,7 +102,7 @@ public class BinaryObject extends FileOb
    * 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 {
+  public void setData(InputStream data, Hasher hash, CompressionCodec... comps) throws IOException
{
     ByteArrayOutputStream out = 
       new ByteArrayOutputStream();
     OutputStream bout = 
@@ -125,7 +125,7 @@ public class BinaryObject extends FileOb
     bout.close();
     setProperty("length",len);
     String c = new String(out.toByteArray(),"UTF-8");
-    super.setContent(c);
+    super.setProperty("data",c);
     if (hash != null)
       setProperty(
         hash.name(),
@@ -138,7 +138,7 @@ public class BinaryObject extends FileOb
    * only decoded as the InputStream is consumed.
    */
   public InputStream getInputStream() throws IOException {
-    String content = super.getContent();
+    String content = super.getProperty("data");
     if (content == null) return null;
     ByteArrayInputStream in = 
       new ByteArrayInputStream(
@@ -152,16 +152,16 @@ public class BinaryObject extends FileOb
     return bin;
   }
   
-  public void setContent(byte[] data, CompressionCodec... comps) throws IOException {
-    setContent(new ByteArrayInputStream(data),null,comps);
+  public void setData(byte[] data, CompressionCodec... comps) throws IOException {
+    setData(new ByteArrayInputStream(data),null,comps);
   }
   
-  public void setContent(byte[] data, int s, int e, CompressionCodec... comps) throws IOException
{
-    setContent(new ByteArrayInputStream(data,s,e),null,comps);
+  public void setData(byte[] data, int s, int e, CompressionCodec... comps) throws IOException
{
+    setData(new ByteArrayInputStream(data,s,e),null,comps);
   }
   
-  public void setContent(byte[] data, int s, int e, Hasher hash, CompressionCodec... comps)
throws IOException {
-    setContent(new ByteArrayInputStream(data,s,e),hash,comps);
+  public void setData(byte[] data, int s, int e, Hasher hash, CompressionCodec... comps)
throws IOException {
+    setData(new ByteArrayInputStream(data,s,e),hash,comps);
   }
   
 }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java?rev=1177424&r1=1177423&r2=1177424&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java Thu
Sep 29 20:38:34 2011
@@ -668,7 +668,7 @@ public class FOMFactory extends OMLinked
         if (conmap.containsKey(qname)) {
           if (is_text(qname)) {
             Text.Type type = (Text.Type)objecttype;
-            element = create(qname,qname.getLocalPart(),namespace,type,parent,factory);
+            element = create(qname,type,qname.getLocalPart(),namespace,parent,factory);
           } else if (is_content(qname)) {
             Content.Type type = (Content.Type)objecttype;
             element = create(qname,qname.getLocalPart(),namespace,type,parent,factory);

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java?rev=1177424&r1=1177423&r2=1177424&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
(original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
Thu Sep 29 20:38:34 2011
@@ -29,7 +29,8 @@ public class BinaryDataObjectExample {
     DataHandler dataHandler = new DataHandler(url); 
     
     BinaryObject dataObject = new BinaryObject();
-    dataObject.setContent(
+    // set the content.. md5 hash will be calculated and deflate compression used
+    dataObject.setData(
       dataHandler, 
       new HashHelper.Md5(), 
       CompressionCodec.DEFLATE);
@@ -47,6 +48,7 @@ public class BinaryDataObjectExample {
     String md5 = dataObject.getProperty("md5");
     HashHelper.Md5 check = new HashHelper.Md5();
     
+    // decompression will be applied automatically
     InputStream in = dataObject.getInputStream(); 
     byte[] buf = new byte[100];
     int r = -1;



Mime
View raw message