abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r429786 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/Entry.java examples/src/main/java/org/apache/abdera/examples/simple/Create.java parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
Date Tue, 08 Aug 2006 19:16:03 GMT
Author: jmsnell
Date: Tue Aug  8 12:16:03 2006
New Revision: 429786

URL: http://svn.apache.org/viewvc?rev=429786&view=rev
Log:
>From Ugo Cei...

  * add setContent(URI uri, String mediaType) to Entry
  * impl setContent(URI uri, String mediaType) in FOMEntry
  * add example of setContent(URI uri, String mediaType) to the simple example

Thanks Ugo!

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java?rev=429786&r1=429785&r2=429786&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Entry.java Tue
Aug  8 12:16:03 2006
@@ -214,6 +214,17 @@
   Content setContent(String value, String mediatype) throws MimeTypeParseException;
   
   /**
+   * Sets the content for this entry as out of line.
+   * 
+   * @param uri URI of the content (value of the "src" attribute).
+   * @param mediatype Type of the content.
+   * @return The new content element.
+   * @throws MimeTypeParseException if the mime type is invalid.
+   * @throws URISyntaxException if the URI is invalid.
+   */
+  Content setContent(URI uri, String mediatype) throws MimeTypeParseException, URISyntaxException;
+  
+  /**
    * Returns the text of the content element
    */
   String getContent();

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java?rev=429786&r1=429785&r2=429786&view=diff
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java
(original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/Create.java
Tue Aug  8 12:16:03 2006
@@ -17,6 +17,7 @@
 */
 package org.apache.abdera.examples.simple;
 
+import java.net.URI;
 import java.util.Date;
 
 import org.apache.abdera.factory.Factory;
@@ -63,6 +64,14 @@
     entry3.setSummaryAsHtml("<p><a href=\"foo\">Test</a></p>").setBaseUri("http://example.org/site/");
     entry3.setSource(feed.getAsSource());
     
+    // Out-of-line content
+    Entry entry4 = feed.addEntry();
+    entry4.setTitle("re: Atom-Powered Robots Run Amok");
+    entry4.addLink("/2003/12/13/atom03/3");
+    entry4.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-cafebabecafe");
+    entry4.setUpdated(new Date());
+    entry4.setSummary("An entry with out-of-line content");
+    entry4.setContent(new URI("http://example.org/0xcafebabe"), "text/html");
     feed.getDocument().writeTo(System.out);
   }
 

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java?rev=429786&r1=429785&r2=429786&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
Tue Aug  8 12:16:03 2006
@@ -259,6 +259,19 @@
     setContentElement(content);
     return content;
   }
+  
+  /**
+   * Sets the content for this entry
+   * @throws MimeTypeParseException 
+ * @throws URISyntaxException 
+   */
+  public Content setContent(URI uri, String mediatype) throws MimeTypeParseException, URISyntaxException
{
+    FOMFactory factory = (FOMFactory) this.factory;
+    Content content = factory.newContent(new MimeType(mediatype));
+    content.setSrc(uri.toString());
+    setContentElement(content);
+    return content;
+  }
 
   
   public List<Person> getContributors() {



Mime
View raw message