Package com.oorian.rss
Class RssItem
java.lang.Object
com.oorian.rss.RssItem
Represents an RSS
<item> element in an RSS 2.0 feed.
An item may represent a blog post, news article, podcast episode, or any other piece of content. At least one of title or description must be present for a valid RSS item.
Supports the content:encoded extension for embedding full HTML content
within a CDATA section.
Usage:
RssItem item = new RssItem("Post Title", "https://example.com/post-1", "Summary text");
item.setAuthor("author@example.com")
.setPubDate(new Date())
.addCategory("Technology")
.setContentEncoded("<p>Full HTML content here</p>");
- Since:
- 0.1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCategory(String value) Adds a category to this item.addCategory(String value, String domain) Adds a category with a domain to this item.getGuid()getLink()getTitle()booleanSets the email address of the author of this item.setComments(String comments) Sets the URL for comments relating to this item.setContentEncoded(String contentEncoded) Sets the full HTML content for this item using thecontent:encodedextension.setDescription(String description) Sets the description (synopsis) of this item.setEnclosure(RssEnclosure enclosure) Sets the enclosure (media attachment) for this item.setEnclosure(String url, long length, String mimeType) Sets the enclosure by creating one from the given parameters.Sets the globally unique identifier for this item.setGuidIsPermaLink(boolean guidIsPermaLink) Sets whether the GUID is a permalink (a URL that can be opened in a browser).Sets the URL of this item.setPubDate(Date pubDate) Sets the publication date of this item.Sets the source feed that this item came from.Sets the title of this item.com.oorian.xml.XmlElementConverts this item to anXmlElement.
-
Constructor Details
-
RssItem
public RssItem()Creates an empty item. At least one of title or description must be set before the item is added to a channel. -
RssItem
Creates an item with the specified title, link, and description.- Parameters:
title- The title of the item.link- The URL of the item.description- A synopsis or summary of the item.
-
-
Method Details
-
setTitle
Sets the title of this item.- Parameters:
title- The item title.- Returns:
- This item for method chaining.
-
setLink
Sets the URL of this item.- Parameters:
link- The item URL.- Returns:
- This item for method chaining.
-
setDescription
Sets the description (synopsis) of this item.- Parameters:
description- The item description.- Returns:
- This item for method chaining.
-
setAuthor
Sets the email address of the author of this item.- Parameters:
author- The author email address (e.g., "author@example.com (Author Name)").- Returns:
- This item for method chaining.
-
setComments
Sets the URL for comments relating to this item.- Parameters:
comments- The comments URL.- Returns:
- This item for method chaining.
-
setEnclosure
Sets the enclosure (media attachment) for this item.- Parameters:
enclosure- The enclosure describing the attached media.- Returns:
- This item for method chaining.
-
setEnclosure
Sets the enclosure by creating one from the given parameters.- Parameters:
url- The URL of the enclosed media object.length- The size of the media object in bytes.mimeType- The MIME type of the media object.- Returns:
- This item for method chaining.
-
setGuid
Sets the globally unique identifier for this item.By default, the GUID is treated as a permalink. Use
setGuidIsPermaLink(boolean)to indicate otherwise.- Parameters:
guid- The unique identifier string.- Returns:
- This item for method chaining.
-
setGuidIsPermaLink
Sets whether the GUID is a permalink (a URL that can be opened in a browser).- Parameters:
guidIsPermaLink-trueif the GUID is a permalink (default),falseotherwise.- Returns:
- This item for method chaining.
-
setPubDate
Sets the publication date of this item.- Parameters:
pubDate- The publication date.- Returns:
- This item for method chaining.
-
setSource
Sets the source feed that this item came from.- Parameters:
source- The name of the source feed.sourceUrl- The URL of the source feed's XML.- Returns:
- This item for method chaining.
-
setContentEncoded
Sets the full HTML content for this item using thecontent:encodedextension.The content will be wrapped in a CDATA section in the XML output. Using this extension requires the
contentnamespace to be declared on the RSS root element, whichRssFeedhandles automatically.- Parameters:
contentEncoded- The full HTML content.- Returns:
- This item for method chaining.
-
addCategory
Adds a category to this item.- Parameters:
value- The category text value.- Returns:
- This item for method chaining.
-
addCategory
Adds a category with a domain to this item.- Parameters:
value- The category text value.domain- The domain URI identifying the categorization taxonomy.- Returns:
- This item for method chaining.
-
getTitle
-
getLink
-
getDescription
-
getAuthor
-
getCategories
-
getComments
-
getEnclosure
-
getGuid
-
isGuidIsPermaLink
public boolean isGuidIsPermaLink() -
getPubDate
-
getSource
-
getSourceUrl
-
getContentEncoded
-
toXmlElement
public com.oorian.xml.XmlElement toXmlElement()Converts this item to anXmlElement.- Returns:
- An XmlElement representing this
<item>element with its sub-elements.
-