fable.io
Class FBMLManager

java.lang.Object
  extended by fable.io.FBMLManager

public class FBMLManager
extends java.lang.Object

FBML, or FaBle Markup Language, is an extension to XML that is able to store an entire Fable tree structure, complete with feed properties and preferences.

Articles may or may not be stored in an FBML structure.

A sample FBML document that shows all the required syntax is as follows:

 <?xml version="1.0"?>
 <fbml version="1.0">
                <password key="aX3875">
                        <keyword>Slash</keyword>
                        <url>Slashdot</url>
                </password>
                <folder name="Slashdot Feeds">
                        <folder name="Slashdot Feed 1">
                                <feed name="Slashdot 1" url="http://www.slashdot.org/index.rss"
                                        refreshrate="60" cachetime="7" lastrefreshed="0">
                                        <article author="ScuttleMonkey" date="0" url="http://rss.slashdot.org/Slashdot/slashdot?m=1819"
                                                isread="1" isstarred="1">
                                                <title>Water Vapor Causing Climate Warming</title>
                                                <summary>karvind writes "According to BBC, new studies suggest that water vapor rather than carbon dioxide in the atmosphere is the main reason why Europe's climate is warming. The scientists say that rising temperatures caused by greenhouse gases are increasing humidity, which in turn amplifies the temperature rise. This is potentially a positive feedback mechanism which could increase the impact of greenhouse gases such as CO2. Even though 2005 will probably be warmest year, climatologists still differ in opinion"</summary>
                                                <description></description>
                                        </article>
                                        <article author="ScuttleMonkey" date="0" url="http://rss.slashdot.org/Slashdot/slashdot?m=1818"
                                                isread="1" isstarred="0">
                                                <title>A Tool to Tally Podcast Listeners</title>
                                                <summary>Carl Bialik writes "The company Audible is making an effort to measure podcast audience, which could make the audio shows more attractive to advertisers. From the article: 'Currently in podcasts, "there's no measurability," says Matt Feinberg, a senior vice president for radio at Publicis Groupe SA's ZenithOptimedia. Advertisers have no idea if people are actually listening to podcasts, or if they're just downloading them and never playing them back, so there's no guidance for pricing the accompanying ads. "Prices -- people have been making them up," he says.' The service will cost podcasters: 'The company will charge three cents per downloaded podcast to report whether a downloader listened, and for how long. Audible will also offer tools that will stop the podcast from being emailed to others. It will charge five cents per download to track listening and attach the access restrictions. For half a cent per download, Audible will insert an ad relevant to the podcast.'"</summary>
                                                <description></description> 
                                        </article>
                                </feed>
                        </folder>
                        <folder name="Slashdot Feed 2">
                                <feed name="Slashdot 2" url="http://www.slashdot.org/index.rss"
                                        refreshrate="90" cachetime="14">
                                        <article author="ScuttleMonkey" date="0" url="http://rss.slashdot.org/Slashdot/slashdot?m=1817"
                                                isread="0" isstarred="0">
                                                <title>Wind-powered Wi-Fi Sensors</title>
                                                <summary>Glenn Fleishman writes "According to an article at Indolink a 10-centimeter diameter windmill can produce the 7.5 milliwatts needed for a wireless sensor. The paper was published earlier (available as a PDF), but Nature magazine has apparently picked up the tidbit. The process flexes piezoelectric crystals to create a current. Although flywheels aren't mentioned in this article, it seems like a windmill, a flywheel, and a solar cell could in combination produce effective power in a range of conditions for remote wireless devices, including network relays obviating batteries entirely."</summary>
                                                <description></description>
                                        </article>
                                </feed>
                        </folder>
                </folder>
</fbml>


The password attribute contains the password (hashed!), and the list of banned URLs and banned keywords The name attribute is required for folders. The name and url attributes is required for feeds. The url attribute is required for articles.

For feeds:

The refreshrate is in minutes, cachetime in days, and lastrefreshed is the last refreshed date, in the number of milliseconds after Jan, 1, 1970, 00:00:00 GMT. All other attributes are optional.

For articles:

Author field is self-explanatory, isread and isstarred are either "0" or "1" - to determine if the article has been read or starred.

Date is the number of milliseconds after Jan 1, 1970, 00:00:00 GMT when this feed was created.

The <title> tag refers to the title of the feed, <summary> the summary, and <description> the name of the FILE that contains the actual html content. All 3 are optional, but at most only one of each should be present. If there are multiple of these, the behavior of the procedures in interpreting this is unspecified.

Author:
Christopher Moh

Method Summary
static FBMLDuple readFBML(java.lang.String fileName)
          Reads an FBML file.
static boolean writeFBML(FBMLDuple duple, java.lang.String fileName, boolean includeAll)
          Exports Fable settings, file structure, hierachy etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readFBML

public static FBMLDuple readFBML(java.lang.String fileName)
Reads an FBML file. All top-level folders in this FBML file will be placed as children in the FableComponent returned, which is a folder with UID RSSManager.GenericUID.

This method is designed to "fail quietly". As much as possible of the FBML document will be read as possible. This may lead to incomplete FableComponents returned.

If nothing can be read at all, a FableComponent with no children is returned. that is named "Fable".

If there are multiple entries, all of them are read and collated together.

As the feeds are read, the articles are loaded ONLY if they are stored in the FBML file.

Parameters:
fileName - The FBML file to read
Returns:
A duple containing both the censor as well as the contents of this FBML file.
Requires:
fileName != null

writeFBML

public static boolean writeFBML(FBMLDuple duple,
                                java.lang.String fileName,
                                boolean includeAll)
Exports Fable settings, file structure, hierachy etc. to an FBML file

Parameters:
duple - FBMLDuple that contains Fable Root, as well as the Fable Censor. The ROOT is NOT exported (only its children are)!
fileName - File to export FBML to.
includeAll - true if ALL data is to be written, false if articles are not to be included
Returns:
true if FBML file can be written, false otherwise
Requires:
duple, fileName != null, duple.root, duple.censor != null