Coverage Report - yarfraw.mapping.forward.impl.ToRss10ChannelImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ToRss10ChannelImpl
100% 
100% 
0
 
 1  
 package yarfraw.mapping.forward.impl;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import yarfraw.core.datamodel.ChannelFeed;
 6  
 import yarfraw.core.datamodel.ItemEntry;
 7  
 import yarfraw.core.datamodel.YarfrawException;
 8  
 import yarfraw.generated.rss10.elements.ObjectFactory;
 9  
 import yarfraw.generated.rss10.elements.RDF;
 10  
 import yarfraw.mapping.forward.ToRss10Channel;
 11  
 /**
 12  
  * Util methods for mapping Yarfraw core model to Rss10 Jaxb model
 13  
  * @author jliang
 14  
  *
 15  
  */
 16  15
 public class ToRss10ChannelImpl implements ToRss10Channel{
 17  12
   private static ToRss10Channel _instance = new ToRss10ChannelImpl();
 18  12
   private static final ObjectFactory FACTORY = new ObjectFactory();
 19  
   
 20  
   public static final ToRss10Channel getInstance(){
 21  15
     return _instance;
 22  
   }
 23  12
   private ToRss10ChannelImpl(){}
 24  
   
 25  
   /**
 26  
    * Model: (channel, image?, item+, textinput?)
 27  
    */
 28  
   public RDF execute(ChannelFeed ch)
 29  
       throws YarfrawException {
 30  15
     RDF rdf = FACTORY.createRDF();
 31  15
     List<Object> elementList = rdf.getChannelOrImageOrItem();
 32  15
     elementList.add(Rss10MappingUtils.toChannel(ch));
 33  15
     if(ch.getImageOrIcon() != null){
 34  12
       elementList.add(Rss10MappingUtils.toRss10Image(ch.getImageOrIcon()));
 35  
     }
 36  
         
 37  15
     if(ch.getItems() != null){
 38  15
       for(ItemEntry item : ch.getItems()){
 39  54
         if(item != null){
 40  54
           elementList.add(ToRss10ChannelItemImpl.getInstance().execute(item));
 41  
         }
 42  
       }
 43  
     }
 44  
     
 45  15
     if(ch.getTexInput() != null){
 46  9
       elementList.add(Rss10MappingUtils.toRss10TextInput(ch.getTexInput()));
 47  
     }
 48  
 
 49  15
     return rdf;
 50  
   }
 51  
   
 52  
   
 53  
 }