public final class RSSDoc extends Object implements Serializable
This class reads and writes RSS documents to and from xml files, objects or Strings. It contains all of the factory methods for building immutable copies of the object elements.
Here are some examples of how to use the RSSpect library in your application:
RSS myRSS = new RSSDoc().readRSSToBean(new File("/myPath/myRSS.xml");
RSS myRSS = new RSSDoc().readRSSToBean(new URL("http://www.abcdefg.net/myRSS.xml");
String myRssStr = myRSS.toString();
String myRssStr = new RSSDoc().readRSSToString(myRSS, "javanet.staxutils.IndentingXMLStreamWriter");
String myRssStr = new RSSDoc().writeRSSDoc(new File("/somewhere/myRSS.xml"), myRSS, "UTF-8", "1.0");
String myRssStr = new RSSDoc().writeRSSDoc(new javanet.staxutils.IndentingXMLStreamWriter( XMLOutputFactory.newInstance().createXMLStreamWriter( new FileOutputStream("/somewhere/myRSS.xml"), "UTF-8")), myRSS, "UTF-8", "1.0");
| Constructor and Description |
|---|
RSSDoc() |
RSSDoc(List<com.colorfulsoftware.rss.RSSDoc.ProcessingInstruction> processingInstructions) |
| Modifier and Type | Method and Description |
|---|---|
Attribute |
buildAttribute(String name,
String value) |
Author |
buildAuthor(String author) |
Category |
buildCategory(Attribute domain,
String category) |
Channel |
buildChannel(Title title,
Link link,
Description description,
Language language,
Copyright copyright,
ManagingEditor managingEditor,
WebMaster webMaster,
PubDate pubDate,
LastBuildDate lastBuildDate,
List<Category> categories,
Generator generator,
Docs docs,
Cloud cloud,
TTL ttl,
Image image,
Rating rating,
TextInput textInput,
SkipHours skipHours,
SkipDays skipDays,
List<Extension> extensions,
List<Item> items) |
Cloud |
buildCloud(List<Attribute> attributes) |
Comments |
buildComments(String comments) |
Copyright |
buildCopyright(String copyright) |
Day |
buildDay(String day) |
Description |
buildDescription(String description) |
Docs |
buildDocs(String docs) |
Enclosure |
buildEnclosure(List<Attribute> attributes) |
Extension |
buildExtension(String elementName,
List<Attribute> attributes,
String content) |
Generator |
buildGenerator(String text) |
GUID |
buildGUID(Attribute isPermaLink,
String guid) |
Height |
buildHeight(String height) |
Hour |
buildHour(String hour) |
Image |
buildImage(URL url,
Title title,
Link link,
Width width,
Height height,
Description description) |
Item |
buildItem(Title title,
Link link,
Description description,
Author author,
List<Category> categories,
Comments comments,
Enclosure enclosure,
GUID guid,
PubDate pubDate,
Source source,
List<Extension> extensions) |
Language |
buildLanguage(String language) |
LastBuildDate |
buildLastBuildDate(String lastBuildDate) |
Link |
buildLink(String link) |
ManagingEditor |
buildManagingEditor(String managingEditor) |
Name |
buildName(String name) |
PubDate |
buildPubDate(String pubDate) |
Rating |
buildRating(String rating) |
RSS |
buildRSS(Channel channel,
List<Attribute> attributes,
List<Extension> extensions) |
SkipDays |
buildSkipDays(List<Day> skipDays) |
SkipHours |
buildSkipHours(List<Hour> skipHours) |
Source |
buildSource(Attribute url,
String source) |
TextInput |
buildTextInput(Title title,
Description description,
Name name,
Link link) |
Title |
buildTitle(String title) |
TTL |
buildTTL(String ttl) |
URL |
buildURL(String url) |
WebMaster |
buildWebMaster(String webMaster) |
Width |
buildWidth(String width) |
String |
getEncoding() |
Generator |
getLibVersion() |
String |
getXmlVersion() |
RSS |
readRSSToBean(File file)
This method reads an xml File object into a Feed element.
|
RSS |
readRSSToBean(InputStream inputStream)
This method reads an rss file from an input stream into a RSS element.
|
RSS |
readRSSToBean(String xmlString)
This method reads an xml string into a Feed element.
|
RSS |
readRSSToBean(URL url)
This method reads an rss file from a URL into a Feed element.
|
String |
readRSSToString(RSS rss,
String xmlStreamWriter)
This method reads in a Feed element and returns the contents as an rss
feed string with formatting specified by the fully qualified
XMLStreamWriter class name (uses reflection internally).
|
void |
writeRSSDoc(File file,
RSS rss,
String encoding,
String version) |
void |
writeRSSDoc(OutputStream output,
RSS rss,
String encoding,
String version) |
void |
writeRSSDoc(XMLStreamWriter output,
RSS rss,
String encoding,
String version)
For example: to pass the TXW
com.sun.xml.txw2.output.IndentingXMLStreamWriter or the stax-utils
javanet.staxutils.IndentingXMLStreamWriter for indented printing do this:
|
public RSSDoc() throws Exception
Exception - if the rsspect.properties file cant be read.public Generator getLibVersion()
public void writeRSSDoc(OutputStream output, RSS rss, String encoding, String version) throws Exception
output - the target output stream for the rss document.rss - the rss object containing the content of the feedencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)Exception - thrown if the feed cannot be written to the outputpublic void writeRSSDoc(File file, RSS rss, String encoding, String version) throws Exception
file - the target output file for the document.rss - the rss object containing the content of the feedencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)Exception - thrown if the feed cannot be written to the outputpublic void writeRSSDoc(XMLStreamWriter output, RSS rss, String encoding, String version) throws Exception
XmlStreamWriter writer = new IndentingXMLStreamWriter(XMLOutputFactory
.newInstance().createXMLStreamWriter(
new FileOutputStream(outputFilePath), encoding));
RSSDoc.writeFeedDoc(writer, myFeed, null, null);
output - the target output for the feed.rss - the rss object containing the content of the feedencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)Exception - thrown if the feed cannot be written to the outputpublic String readRSSToString(RSS rss, String xmlStreamWriter) throws Exception
rss - the rss object to be converted to an rss document string.xmlStreamWriter - the fully qualified XMLStreamWriter class name.Exception - thrown if the feed cannot be returned as a Stringpublic RSS readRSSToBean(String xmlString) throws Exception
xmlString - the xml string to be transformed into a RSS element.Exception - if the string cannot be parsed into a RSS element.public RSS readRSSToBean(File file) throws Exception
file - the file object representing an rss feed.Exception - if the file cannot be parsed into a RSS element.public RSS readRSSToBean(URL url) throws Exception
url - the Internet network location of an rss file.Exception - if the URL cannot be parsed into a RSS element.public RSS readRSSToBean(InputStream inputStream) throws Exception
inputStream - the input stream containing an rss file.Exception - if the URL cannot be parsed into a RSS element.public RSS buildRSS(Channel channel, List<Attribute> attributes, List<Extension> extensions) throws RSSpectException
channel - the unique channel element (required)attributes - additional attributes (optional)extensions - additional extensions (optional)RSSpectException - if the format of the data is not valid.public Attribute buildAttribute(String name, String value) throws RSSpectException
name - the attribute name.value - the attribute value.RSSpectException - if the data is not valid.public Author buildAuthor(String author) throws RSSpectException
author - the author element. (required)RSSpectException - if the format of the data is not valid.public Category buildCategory(Attribute domain, String category) throws RSSpectException
domain - the domain attributecategory - the category textRSSpectException - if the format of the data is not valid.public Channel buildChannel(Title title, Link link, Description description, Language language, Copyright copyright, ManagingEditor managingEditor, WebMaster webMaster, PubDate pubDate, LastBuildDate lastBuildDate, List<Category> categories, Generator generator, Docs docs, Cloud cloud, TTL ttl, Image image, Rating rating, TextInput textInput, SkipHours skipHours, SkipDays skipDays, List<Extension> extensions, List<Item> items) throws RSSpectException
title - the title element.link - the link element.description - the description element.language - the language element.copyright - the copyright element.managingEditor - the managingEditor element.webMaster - the webMaster element.pubDate - the pubDate element.lastBuildDate - the lastBuildDate element.categories - the list of categoriesgenerator - the generator element.docs - the docs element.cloud - the cloud element.ttl - the ttl element.image - the image element.rating - the rating element.textInput - the textInput element.skipHours - the skipHours element.skipDays - the skipDays element.items - the list of items.extensions - the list of extensions.RSSpectException - if the format of the data is not valid.public Cloud buildCloud(List<Attribute> attributes) throws RSSpectException
attributes - the list of attributes.RSSpectException - if the format of the data is not valid.public Comments buildComments(String comments) throws RSSpectException
comments - the comments.RSSpectException - if the format of the data is not valid.public Copyright buildCopyright(String copyright) throws RSSpectException
copyright - the copyright.RSSpectException - if the format of the data is not valid.public Description buildDescription(String description) throws RSSpectException
description - the description.RSSpectException - if the format of the data is not valid.public Docs buildDocs(String docs) throws RSSpectException
docs - the documentation information.RSSpectException - if the format of the data is not valid.public Enclosure buildEnclosure(List<Attribute> attributes) throws RSSpectException
attributes - should contain url, length and typeRSSpectException - if the format of the data is not valid.public Extension buildExtension(String elementName, List<Attribute> attributes, String content) throws RSSpectException
elementName - the name of the extension element.attributes - additional attributes.content - the content of the extension element.RSSpectException - if the format of the data is not valid.public Generator buildGenerator(String text) throws RSSpectException
text - the text content.RSSpectException - if the format of the data is not valid.public GUID buildGUID(Attribute isPermaLink, String guid) throws RSSpectException
isPermaLink - the isPermaLink attributes.guid - the guid data.RSSpectException - if the format of the data is not valid.public Height buildHeight(String height) throws RSSpectException
height - should be a number 400 or lessRSSpectException - if the format of the data is not valid.public Image buildImage(URL url, Title title, Link link, Width width, Height height, Description description) throws RSSpectException
url - the url element.title - the title element.link - the link element.width - the width element.height - the height element.description - the description element.RSSpectException - if the format of the data is not valid.public Item buildItem(Title title, Link link, Description description, Author author, List<Category> categories, Comments comments, Enclosure enclosure, GUID guid, PubDate pubDate, Source source, List<Extension> extensions) throws RSSpectException
title - the title element.link - the link element.description - the description element.author - the author element.categories - the list of categories.comments - the comments element.enclosure - the enclosure element.guid - the guid element.pubDate - the published date element.source - the source element.extensions - the list of extensions.RSSpectException - if the format of the data is not valid.public Language buildLanguage(String language) throws RSSpectException
language - the language.RSSpectException - if the format of the data is not valid.public LastBuildDate buildLastBuildDate(String lastBuildDate) throws RSSpectException
lastBuildDate - the last build date.RSSpectException - if the format of the data is not valid.public Link buildLink(String link) throws RSSpectException
link - the link information.RSSpectException - if the format of the data is not valid.public ManagingEditor buildManagingEditor(String managingEditor) throws RSSpectException
managingEditor - the managing editor.RSSpectException - if the format of the data is not valid.public Name buildName(String name) throws RSSpectException
name - the name.RSSpectException - if the format of the data is not valid.public PubDate buildPubDate(String pubDate) throws RSSpectException
pubDate - the published date.RSSpectException - If the dateTime format is invalid.public Rating buildRating(String rating) throws RSSpectException
rating - the rating information.RSSpectException - if the format of the data is not valid.public SkipDays buildSkipDays(List<Day> skipDays) throws RSSpectException
skipDays - the days to skip.RSSpectException - if the format of the data is not valid.public SkipHours buildSkipHours(List<Hour> skipHours) throws RSSpectException
skipHours - the hours to skip.RSSpectException - if the format of the data is not valid.public Day buildDay(String day) throws RSSpectException
day - the day of the week.RSSpectException - if the format of the data is not valid.public Hour buildHour(String hour) throws RSSpectException
hour - the hour of the day.RSSpectException - if the format of the data is not valid.public Source buildSource(Attribute url, String source) throws RSSpectException
url - the url attribute.source - the source information.RSSpectException - if the format of the data is not valid.public TextInput buildTextInput(Title title, Description description, Name name, Link link) throws RSSpectException
title - the title element.description - the description element.name - the name element.link - the link element.RSSpectException - if the format of the data is not valid.public Title buildTitle(String title) throws RSSpectException
title - the title.RSSpectException - if the format of the data is not valid.public TTL buildTTL(String ttl) throws RSSpectException
ttl - the time to live.RSSpectException - if the format of the data is not valid.public URL buildURL(String url) throws RSSpectException
url - the url.RSSpectException - if the format of the data is not valid.public WebMaster buildWebMaster(String webMaster) throws RSSpectException
webMaster - the web master.RSSpectException - if the format of the data is not valid.public Width buildWidth(String width) throws RSSpectException
width - the width.RSSpectException - if the format of the data is not valid.public String getEncoding()
public String getXmlVersion()
Copyright © 2014. All rights reserved.