1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* ***************************************************************************** */ /* Example of a syndication feed reader using the Project Rome API with */ /* BSF4ooRexx */ /* current version (2009) of Rome: rome1.0.jar https://rome.dev.java.net/ */ /* You need to implement this API plus the JDOM API */ /* jdom.jar, you can find this at https://jdom.org/ */ /* This class retrieves a syndfeed from the web and prints some */ /* information about the feed using */ /* "com.sun.syndication.io.SyndFeedInput" methods */ /* created by Martin Stoppacher date: 26.12.2009 */ /* ***************************************************************************** */ say hello this reads a syndfeed --say please type in the url /* possible input statement for the feed URL */ --pull url --parse arg url /* optional input via arguments */ /* The url String is predefined in this example, to change the feed url */ /* replace to String in this file or use one of the above methods */ url= "http://rss.orf.at/fm4.xml" feedUrl=.bsf~new("java.net.URL", url) /* create an instance of java.net.URL */ say connecting__ || feedUrl~getAuthority() input=.bsf~new("com.sun.syndication.io.SyndFeedInput")/* creates a SyndFeedInput */ xmlr=.bsf~new("com.sun.syndication.io.XmlReader", feedUrl) /* Figures out the charset encoding of the XML document within the stream */ feed= input~build(xmlr) /* Builds a SyndFeedImpl from an Reader , also possible with SAX or DOM */ say bb~getDefaultEncoding() say feed /* returns the feed object */ ::requires BSF.cls /* get the Java support */ |
Category Archives: Code
Syndication feed reader using the Project Rome API – (1_FeedReader.java)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
/* ***************************************************************************** */ /* Example of a syndication feed reader using the Project Rome API */ /* current version of Rome: rome1.0.jar (2009) https://rome.dev.java.net/ */ /* You need to implement this API plus the JDOM API */ /* jdom.jar , you can find this at https://jdom.org/ */ /* Parts of this example are taken from the PRome Web Page tutorials */ /* https://rome.dev.java.net/ author: Alejandro Abdelnur */ /* */ /* This class retrieves a syndfeed from the web and prints its */ /* pure content to the system */ /* created by Martin Stoppacher date: 26.12.2009 */ /* ***************************************************************************** */ import java.net.URL; /* Class URL represents a Uniform Resource Locator, a pointer to a "resource" */ /* on the World Wide Web */ import java.io.InputStreamReader; /* An InputStreamReader is a bridge from byte streams to character streams */ import com.sun.syndication.feed.synd.SyndFeed; /* This is the Bean interface for all types of feeds. */ import com.sun.syndication.io.SyndFeedInput; /* Parses an XML document (File, InputStream, Reader, W3C SAX InputSource, W3C*/ /* DOM Document or JDom DOcument) into an WireFeed (RSS/Atom). */ import com.sun.syndication.io.XmlReader; /* Character stream that handles (or at least attemtps to) all the necessary */ /* Voodo to figure out the charset encoding of the XML document within */ /* the stream. */ public class 1_FeedReader { public static void main(String[] args) { boolean ok = false; if (args.length==1) { try { URL feedUrl = new URL(args[0]); /*creates a string with the URL*/ SyndFeedInput input = new SyndFeedInput(); /* new input object*/ SyndFeed feed = input.build(new XmlReader(feedUrl)); /* reads feed from URL and puts it into feed*/ System.out.println(feed); /* outputs file to system */ ok = true; } catch (Exception ex) { ex.printStackTrace(); System.out.println("ERROR: "+ex.getMessage()); } } if (!ok) { System.out.println(); System.out.println("FeedReader reads and prints any RSS/Atom feed type."); System.out.println("The first parameter must be the" +"URL of the feed to read."); System.out.println(); } } } |
- the Open Object Rexx (ooRexx) web site
- ROME is a set of RSS and Atom Utilities for Java
- Introduction to REXX and ooRexx – Flatscher Rony G.
- http://wi.wu-wien.ac.at:8002/rgf/
- http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2010/201001_Stoppacher/Project_Rome_in_combination_with_BSF4ooRexx_Presentation.pdf