Open source framework for developing RSS aggregation

xiaoxiao2021-04-03  209

Rome Basic Introduction

Recently, companies have to develop a base with Java's RSS reader, but time is tight, find an open source framework Rome, Rome does not refer to Rome. Don't misunderstand, the Rome here is an open source Java framework, you can find it on www.java.net, which is a framework developed for RSS aggregation, allowing you to quickly develop Java-based RSS reading, publisher, stand by

RSS 0.91 Netscape

RSS 0.91 Userland

RSS 0.92

RSS 0.93

RSS 0.94

RSS 1.0

RSS 2.0

Atom 0.3

Atom 1.0

Waiting for standards. You can also extend his Module yourself, let him parse your own defined XML format. It can be said that it is a very wide framework that uses it. You must download the JDOM development package because it is parsing XML with JDom.

In the Rome, the main packages are wrapped below several packages.

com.sun.syndication.feed

com.sun.syndication.feed.atom

Data with each node in Atom

com.sun.syndication.feed.module

Modeule is a layer of data model. Can expand your own

com.sun.syndication.feed.rss

Use the value in the XML node corresponding to each of the RSS

com.sun.syndication.feed.sse com.sun.syndication.Feed.Synd

This package is the attribute com.sun.syndication.io of XML set a node in the RSS format.

This package is input and output stream.

Its UML map

figure 1

Below is an example, the function is to generate XML in the RSS format

Public class feedwriter {

Private static final string Date_Format = "YYYY-MM-DD";

Public static void main (String [] args) {

Boolean OK = FALSE;

IF (args.length == 2) {

Try {

String feedtype = args [0];

String filename = args [1];

DateFormat DateParser = New SimpleDateFormat (Date_Format);

SYNDFEED feed = new syndfeedimpl (); // feed stream

Feed.setfeedType (feedty); // Set the RSS version

Feed.SetTitle ("Sample feed (create with rome)); // Setting title</p> <p>Feed.SetLink</p> <p>http://www.9cbs.net); // <link></p> <p>Feed.SetDescription ("this feed has been createding rome; java syndication utilities");</p> <p>List entries = new arraylist ();</p> <p>SyndEntry Entry;</p> <p>SyndContent description;</p> <p>Entry = new syndiffiMPL (); // child node</p> <p>Entry.SetTitle ("Rome V1.0");</p> <p>Entry.SetLink</p> <p>http://www.9cbs.net);</p> <p>Entry.SetPublishedDate ("2004-06-08"); Description = new syndcontentImpl ();</p> <p>Description.SetType ("text / place");</p> <p>Description.SetValue ("Initial Release of Rome");</p> <p>Entry.setdescription (Description); DESCRIPTION</p> <p>Entries.Add (entry);</p> <p>Entry = new syndiffnessImpl ();</p> <p>Entry.SetTitle ("Rome V2.0");</p> <p>Entry.SetLink</p> <p>http://ww.9cbs.net);</p> <p>Entry.setpublishedDate (DateParser.Parse ("2004-06-16"));</p> <p>Description = new syndContentImpl (); // Description</p> <p>Description.SetType ("text / xml");</p> <p>Description.SetValue ("Bug Fixes, <XML> XML </ XML> Minor API Changes and Some New Features");</p> <p>Entry.setdescription (Description); DESCRIPTION</p> <p>Entries.Add (entry);</p> <p>Entry = new syndiffnessImpl ();</p> <p>Entry.SetTitle ("Rome V3.0");</p> <p>Entry.SetLink ("http://www.9cbs.net");</p> <p>Entry.SetPublisheddate (DateParser.Parse ("2004-07-27");</p> <p>Description = New SyndContentImpl ();</p> <p>Description.SetType ("text / html");</p> <p>Description.SetValue ("<p> more bug fixes, mor api changes, some new features and some unit testing </ p>" </p> <p>"<p> for details check the <a href=/"http://www.9cbs.net/"> Changes Log </a> </ p>);</p> <p>Entry.setdescription (Description); DESCRIPTION</p> <p>Entries.Add (entry);</p> <p>Feed.sentries (Entries); // Set child node</p> <p>Writer Writer = New FileWriter (FileName);</p> <p>SYNDFEEDOUTPUT OUTPUT = New Syndfeedoutput ();</p> <p>Output.output (feed, write); // Write to the file</p> <p>Writer.close ();</p> <p>System.out.println ("The Feed Has Been Written to The File");</p> <p>OK = true;</p> <p>}</p> <p>Catch (Exception EX) {</p> <p>EX.PrintStackTrace ();</p> <p>System.out.println ("Error:" ex.getMessage ());}</p> <p>}</p> <p>IF (! ok) {</p> <p>System.out.println ();</p> <p>System.out.println ("FeedWriter Creates A RSS / Atom Feed and Writes It To A File.");</p> <p>System.out.println ("The First Parameter Must Be The Syndication Format for the Feed";</p> <p>System.out.println ("(RSS_0.90, RSS_0.91, RSS_0.92, RSS_0.93, RSS_0.94, RSS_1.0 RSS_2.0 OR Atom_0.3)");</p> <p>System.out.println ("The Second Parameter Must Be the File Name for the feed";</p> <p>System.out.println ();</p> <p>}</p> <p>}</p> <p>}</p> <p>That's all. The first time I wrote blog written bad. Don't take a brick :)</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-131454.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="131454" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.035</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'w_2BYVkW02r1WWgqCCtAMYnlGfUCJ8zytbK35XvzZnTBPTDZ_2FV_2Bop3PWcv1gd8J6vr8S85gqyAn9NPP7YlUlorIQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>