Package com.oorian.rss
Class RssFeed
java.lang.Object
com.oorian.HttpFile
com.oorian.rss.RssFeed
public abstract class RssFeed
extends com.oorian.HttpFile
Abstract base class for serving RSS 2.0 feeds from an Oorian application.
Extend this class and annotate with @Page to expose an RSS feed endpoint.
Implement the single abstract method createChannel() to build the channel
with items.
RssFeed handles the HTTP content type (application/rss+xml), XML declaration,
RSS root element with version and namespace attributes, and serialization to the response.
Supported RSS Extensions:
content:encoded— Full HTML content in CDATA (viaRssItem.setContentEncoded(String))atom:link— Self-referencing feed URL (viaRssChannel.setAtomSelfLink(String))
Namespace declarations are only added when the corresponding features are used.
Usage:
@Page("/feed")
public class BlogFeed extends RssFeed
{
@Override
protected RssChannel createChannel()
{
RssChannel channel = new RssChannel("My Blog", "https://example.com", "Latest posts");
channel.setLanguage("en-us")
.setAtomSelfLink("https://example.com/feed");
channel.addItem(new RssItem("First Post", "https://example.com/post-1", "Summary text"));
return channel;
}
}
- Since:
- 0.1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract RssChannelCreates and returns the RSS channel for this feed.protected voidBuilds the RSS XML document from the channel returned bycreateChannel().protected voidAppends the RSS XML document to the output buffer.Methods inherited from class com.oorian.HttpFile
addResponseHeader, create, getCacheControl, getDocumentUrl, getFullUrl, getHost, getHttpRequest, getOriginalParameters, getParameter, getParameterAsFloat, getParameterAsInt, getParameterAsLong, getParameterAsShort, getParameters, getParametersAFloat, getParametersAsInt, getParametersAsLong, getParametersAsShort, getParameterValues, getPath, getServletPath, getSessionId, getUrl, getUrlParameters, getWebResponse, hasParameter, hasUrlParams, initializeFile, isWritten, onCreated, onWriteComplete, setCacheControl, setCharacterEncoding, setContentType, setResponseHeader, setUrlParameters, toString, toString, write
-
Constructor Details
-
RssFeed
public RssFeed()Creates a new RssFeed instance.
-
-
Method Details
-
createFile
protected void createFile()Builds the RSS XML document from the channel returned bycreateChannel().Constructs the
<rss>root element with version 2.0 and conditionally adds theatomandcontentnamespace declarations based on usage.- Specified by:
createFilein classcom.oorian.HttpFile
-
toString
Appends the RSS XML document to the output buffer.- Specified by:
toStringin classcom.oorian.HttpFile- Parameters:
sb- The StringBuilder to append XML content to.
-
createChannel
Creates and returns the RSS channel for this feed.Subclasses must implement this method to build the channel, set its metadata, and add items. This method is called once per request during
createFile().- Returns:
- The configured RssChannel for this feed.
-