/*
 *  Copyright 2009 Carlos David González Abraham
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.openchronicles.feedreader;

import java.io.File;
import java.io.FileWriter;
import java.util.Date;
import java.net.URL;

import org.ujoframework.core.UjoManagerXML;

public class SampleFeedReader {
    public static void main(String args[]) {

       // TODO: convert this class into a useful example of the use of ujo-feedreader
       String path = SampleFeedReader.class.getPackage().getName().replace('.', '/');
       URL url = SampleFeedReader.class.getResource("/" + path + "/resources/sample.atom");
       File atomFile = new File(url.getPath());
       
       try {
           AtomFeed feed = UjoManagerXML.getInstance().parseXML(atomFile, AtomFeed.class, "Data Loading");
           FileWriter out = new FileWriter("first_output.xml");
           UjoManagerXML.getInstance().saveXML(out, "feed", feed, null, "Feed export");
           out.close();
       } catch (Exception e) {
           System.out.println(e.getMessage() + e.getCause());
       }

       try {
           AtomFeed feed = UjoManagerXML.getInstance().parseXML(atomFile, AtomFeed.class, "Data Loading");
           FileWriter out = new FileWriter("second_output.xml");
           UjoManagerXML.getInstance().saveXML(out, "feed", feed, null, "Feed export");
           out.close();
       } catch (Exception e) {
           System.out.println(e.getMessage() + e.getCause());
       }
    }
}

@@ -883,320 +883,304 @@
     
-// TODO: convert this class into a useful example of the use of ujo-feedreader%0A       String path = SampleFeedReader.class.getPackage().getName().replace('.', '/'
+ String url = args%5B0%5D;%0A%0A        try %7B%0A            // get feed%0A            AtomFeed feed = FeedManager.readFeed(url
 );%0A
+%0A
        
-URL url = SampleFeedReader.class.getResource(%22/%22 + path + %22/resources/sample.atom%22);%0A       File atomFile = new File(url.getPath());
+     // display feed's title%0A            System.out.println (%22%5Cn%22);%0A            System.err.println (%22=== %22 + AtomTitle.BODY.of(AtomFeed.TITLE.of(feed)) + %22 ===%22);%0A
 %0A       
 %0A   
@@ -1179,332 +1179,714 @@
     
-%0A
      
-  try %7B%0A           AtomFeed feed = UjoManagerXML.getInstance().parseXML(atomFile, AtomFeed.class, %22Data Loading%22);%0A           FileWriter out = new FileWriter(%22first_output.xml%22);%0A           UjoManagerXML.getInstance().saveXML(out, %22feed%22, feed, null, %22Feed export%22);%0A           out.close();%0A       %7D catch (Exception e
+// display feed's links%0A            for (AtomLink link : AtomFeed.LINKS.of(feed)) %7B%0A                System.err.println (%22* URL: %22 + AtomLink.HREF.of(link));%0A            %7D%0A%0A            for (AtomEntry item : AtomFeed.ENTRIES.of(feed)) %7B%0A%0A                //displays item's title%0A                System.out.println (%22%5Cn%22);%0A                System.out.println (AtomTitle.BODY.of ((AtomEntry.TITLE.of(item))) +%0A                    %22(%22 + AtomUpdated.BODY.of ((AtomEntry.UPDATED.of(item))) + %22)%22);%0A                System.out.println (%22-------------------------------------------------------------%22);%0A%0A                //displays item's authors%0A                for (AtomAuthor author : AtomEntry.AUTHORS.of(item)
 ) %7B%0A
@@ -1888,32 +1888,41 @@
 )) %7B%0A           
+ 
+        
 System.out.print
@@ -1927,41 +1927,130 @@
 ntln
-(e.getMessage() + e.getCause());%0A
+ (%22* Author: %22 + AtomAuthor.NAME.of(author) +%0A                        %22 %3C%22 + AtomAuthor.EMAIL.of(author) + %22%3E%22);%0A         
     
@@ -2062,30 +2062,25 @@
 %0A       
-try %7B%0A
+ 
         
    AtomF
@@ -2075,257 +2075,393 @@
     
-   AtomFeed feed = UjoManagerXML.getInstance().parseXML(atomFile, AtomFeed.class, %22Data Loading%22);%0A           FileWriter out = new FileWriter(%22second_output.xml%22);%0A           UjoManagerXML.getInstance().saveXML(out, %22feed%22, feed, null, %22Feed export%22
+//displays item's content (limit to 100 characters)%0A                System.out.println (%22%5Cn%22);%0A                System.out.println (AtomContent.BODY.of ((AtomEntry.CONTENT.of(item))).length() %3C= 100%0A                    ? AtomContent.BODY.of ((AtomEntry.CONTENT.of(item)))%0A                    : AtomContent.BODY.of ((AtomEntry.CONTENT.of(item))).substring(1,100) + %22...%22%0A                
 );%0A 
@@ -2474,21 +2474,13 @@
     
-out.close();%0A
+ %7D%0A%0A 
     
@@ -2513,34 +2513,99 @@
 %0A           
+ 
 System.
-out
+err.println(%22No se pudo iniciar el canal.%22);%0A            System.err
 .println(e.g
@@ -2619,26 +2619,12 @@
 ge()
- + e.getCause()
 );%0A
+ 
     

Rewrite of SampleFeedReader class (sample of use of ujo-feedreader library).