manjyurss (manjyu-rss-0.5.0) | 2012-11-29 23:05 |
Using ManjyuRss is very easy.
Put ManjyuRss jar file 'manjyu-rss-?.?.?.jar' in your java class path.
- import java.io.IOException;
- import java.util.Date;
- import org.manjyu.rss.ManjyuRssSerializer;
- import org.manjyu.rss.vo.ManjyuRss;
- import org.manjyu.rss.vo.ManjyuRssChannel;
- import org.manjyu.rss.vo.ManjyuRssItem;
- public class GettingStarted001 {
- public static final void main(final String[] args) throws IOException {
- final ManjyuRss rss = new ManjyuRss();
- final ManjyuRssChannel channel = rss.getChannel();
- channel.setTitle("Sample RSS.");
- channel.setLink("http://www.igapyon.com/");
- channel.setDescription("Description of sample RSS.");
- channel.setLanguage("en_US");
- channel.setCopyright("Copyright(C) Toshiki Iga");
- channel.setPubDate(new Date());
- new ManjyuRssSerializer() {
- @Override
- protected void processItems() throws IOException {
- {
- final ManjyuRssItem item = new ManjyuRssItem();
- item.setTitle("bsqlformatter: Free online SQL formatter");
- item.setLink("http://www.igapyon.com/bsqlformatter/");
- item.setDescription("bsqlformatter is a Free Online SQL Formatter.");
- item.setPubDate(new Date());
- serializeItem(item);
- }
- {
- final ManjyuRssItem item = new ManjyuRssItem();
- item.setTitle("Manjyu: classify URL system");
- item.setLink("http://www.igapyon.com/manjyu/");
- item.setDescription("Manjyu is URL management system for classify URL as you want.");
- item.setPubDate(new Date());
- serializeItem(item);
- }
- }
- }.serialize(rss, System.out);
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <rss version="2.0">
- <!-- Generated by ManjyuRss (0.0.2-201211142334) -->
- <channel>
- <title>Sample RSS.</title>
- <link>http://www.igapyon.com/</link>
- <description>Description of sample RSS.</description>
- <language>en_US</language>
- <copyright>Copyright(C) Toshiki Iga</copyright>
- <pubDate>Wed, 14 Nov 2012 23:43:32 +0900</pubDate>
- <generator>Manjyu RSS Library (0.0.2-201211142334)</generator>
- <docs>http://blogs.law.harvard.edu/tech/rss</docs>
- <item>
- <title>bsqlformatter: Free online SQL formatter</title>
- <link>http://www.igapyon.com/bsqlformatter/</link>
- <description>bsqlformatter is a Free Online SQL Formatter.</description>
- <pubDate>Wed, 14 Nov 2012 23:43:33 +0900</pubDate>
- </item>
- <item>
- <title>Manjyu: classify URL system</title>
- <link>http://www.igapyon.com/manjyu/</link>
- <description>Manjyu is URL management system for classify URL as you want.</description>
- <pubDate>Wed, 14 Nov 2012 23:43:33 +0900</pubDate>
- </item>
- </channel>
- </rss>
- import java.io.BufferedInputStream;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import org.manjyu.rss.ManjyuRssParser;
- import org.manjyu.rss.vo.ManjyuRssChannel;
- import org.manjyu.rss.vo.ManjyuRssItem;
- public class GettingStarted002 {
- public static final void main(final String[] args) throws IOException {
- final InputStream inStream = new BufferedInputStream(new FileInputStream("test/data/GettingStarted001.rss"));
- new ManjyuRssParser() {
- @Override
- protected void processChannel(final ManjyuRssChannel channel) throws IOException {
- System.out.println("Channel: " + channel.getTitle() + " [" + channel.getLink() + "]");
- System.out.println(" description: " + channel.getDescription());
- System.out.println(" pubDate : " + channel.getPubDate());
- }
- @Override
- protected void processItem(final ManjyuRssItem item) throws IOException {
- System.out.println(" Item: " + item.getTitle() + " [" + item.getLink() + "]");
- System.out.println(" description: " + item.getDescription());
- System.out.println(" pubDate : " + item.getPubDate());
- }
- }.parse(inStream);
- inStream.close();
- }
- }
- Channel: Sample RSS. [http://www.igapyon.com/]
- description: Description of sample RSS.
- pubDate : Wed Nov 14 23:43:32 JST 2012
- Item: bsqlformatter: Free online SQL formatter [http://www.igapyon.com/bsqlformatter/]
- description: bsqlformatter is a Free Online SQL Formatter.
- pubDate : Wed Nov 14 23:43:33 JST 2012
- Item: Manjyu: classify URL system [http://www.igapyon.com/manjyu/]
- description: Manjyu is URL management system for classify URL as you want.
- pubDate : Wed Nov 14 23:43:33 JST 2012