Feed Host Object Guide

This document describes the set of host objects available for reading Atom and RSS feeds. These objects are capable of identifying feed types and handling them accordingly.

1.0 Introduction

The Feed implementation consists of three main host objects, namely Feed, Entry and FeedReader.

1.1 Feed and Entry

These host objects are capable of intelligently working with both Atom and RSS feeds. The underlying protocol implementation is kept transparent. However, some data might be lost due to this being an abstraction of both Atom and RSS feeds. The Feed host object is capable of persisting it's content to disk.

1.2 FeedReader

The FeedReader is a generic reader of Atom and RSS feeds.

1.3 MediaModule

Provides access to media extensions on an Entry.

2.0 Examples

                // Creating an RSS 2.0 feed and writing it to file.
                // Creating the Feed
                var feed = new Feed();
                feed.feedType = "rss_2.0";
                feed.title = "This is a test Feed";
                feed.description = "This feed demonsrates the use of Feed host object to create an RSS 2.0 feed.";
                feed.link = "http://mooshup.com/rss20.xml";

                // Creating Entries in the Feed
                var entry = new Entry();
                entry.title = "This is a test entry.";
                entry.description = "This is a sample entry demonstrating the use of the Entry host object.";
                feed.insertEntry(entry);
                
                var entry2 = new Entry();
                entry2.title = "This is another test entry.";
                entry2.description = "This is a sample entry demonstrating the use of the Entry host object.";
                
                // Adding a Media Module to the entry
                var mediaModule = new
                MediaModule("http://www.earthshots.org/photos/387.jpg");
                mediaModule.copyright = "2007 Tad Bowman";
                mediaModule.type = "image/jpeg";
                mediaModule.thumbnail = "http://www.earthshots.org/photos/387.thumb.jpg";
                entry2.addMediaModule(mediaModule);
                
                feed.insertEntry(entry2);

                // Writing the newly created Feed to a File
                var result = feed.writeTo("test-created-rss-feed.xml");
            

For a demonstration of this feature, please refer the TomatoTube sample in your WSO2 Mashup Server distribution.

3.0 API Documentation

3.1 Feed Host Object API Documentation

Member Description
Entry[] getEntries() Returns the complete set of entries contained in this feed.

var entries = feed.getEntries();
void insertEntry(newEntry) Adds a new Entry to the end of the Feeds collection of entries.

feed.insertEntry(newEntry);
void writeTo(fileName) Serializes the Feed to a given local file/

feed.writeTo("file-name.xml");
property String author The author of this feed.
property String category The category of this feed.
property String contributor The contributor of this feed.
property String description The description of this feed.
property String feedType The type of this feed ("atom", "rss_2.0", "rss_1.0").
property String link The location of this feed.
property String title The title of this feed.
property String updated The date when this feed was last updated.
readonly property XML XML Returns the E4X XML contents of this Feed object.

3.2 Entry Host Object API Documentation

Member Description
MediaModule[] getMediaModules() Returns the complete set of media modules assocated with this entry.

var mediamodules = feed.getMediaModules();
property String author The author of this entry.
property String category The category of this entry.
property String content The content of this entry.
property String contributor The contributor of this entry.
property String description The description of this entry.
property String[] link The location of this entry.
property String published The date this entry was published.
property String summary The summary of this entry.
property String title The title of this entry.
property String updated The date this entry was updated.
readonly property XML XML Returns the E4X XML contents of this Entry.

3.3 FeedReader Host Object API Documentation

Member Description
Feed get(url) Reads a RSS/Atom feed from a given url.

var reader = new FeedReader();

var feed = new Feed();

feed = reader.get("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml");

3.4 MediaModule Host Object API Documentation

Member Description
property Integer height The height of the media object.
property Float bitrate The kilobytes per second rate of media.
property Integer channels The number of audio channels in the media object.
property Object copyright Copyright information for media object.
property String description Short description describing the media object typically a sentence in length.
property Long duration The number of seconds the media object plays.
property Long fileSize The number of bytes of the media object.
property Float framerate The number of frames per second for the media object.
property String language The primary language encapsulated in the media object.
property Float samplingrate The number of samples per second taken to create the media object.
property String thumbnail Allows particular images to be used as representative images for the media object.
property Object type The standard MIME type of the object.
property Integer width The width of the media object.

4.0 References