Class RssItem

java.lang.Object
com.oorian.rss.RssItem

public class RssItem extends Object
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 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

      public RssItem(String title, String link, String description)
      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

      public RssItem setTitle(String title)
      Sets the title of this item.
      Parameters:
      title - The item title.
      Returns:
      This item for method chaining.
    • setLink

      public RssItem setLink(String link)
      Sets the URL of this item.
      Parameters:
      link - The item URL.
      Returns:
      This item for method chaining.
    • setDescription

      public RssItem setDescription(String description)
      Sets the description (synopsis) of this item.
      Parameters:
      description - The item description.
      Returns:
      This item for method chaining.
    • setAuthor

      public RssItem setAuthor(String author)
      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

      public RssItem setComments(String comments)
      Sets the URL for comments relating to this item.
      Parameters:
      comments - The comments URL.
      Returns:
      This item for method chaining.
    • setEnclosure

      public RssItem setEnclosure(RssEnclosure enclosure)
      Sets the enclosure (media attachment) for this item.
      Parameters:
      enclosure - The enclosure describing the attached media.
      Returns:
      This item for method chaining.
    • setEnclosure

      public RssItem setEnclosure(String url, long length, String mimeType)
      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

      public RssItem setGuid(String guid)
      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

      public RssItem setGuidIsPermaLink(boolean guidIsPermaLink)
      Sets whether the GUID is a permalink (a URL that can be opened in a browser).
      Parameters:
      guidIsPermaLink - true if the GUID is a permalink (default), false otherwise.
      Returns:
      This item for method chaining.
    • setPubDate

      public RssItem setPubDate(Date pubDate)
      Sets the publication date of this item.
      Parameters:
      pubDate - The publication date.
      Returns:
      This item for method chaining.
    • setSource

      public RssItem setSource(String source, String sourceUrl)
      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

      public RssItem setContentEncoded(String contentEncoded)
      Sets the full HTML content for this item using the content:encoded extension.

      The content will be wrapped in a CDATA section in the XML output. Using this extension requires the content namespace to be declared on the RSS root element, which RssFeed handles automatically.

      Parameters:
      contentEncoded - The full HTML content.
      Returns:
      This item for method chaining.
    • addCategory

      public RssItem addCategory(String value)
      Adds a category to this item.
      Parameters:
      value - The category text value.
      Returns:
      This item for method chaining.
    • addCategory

      public RssItem addCategory(String value, String domain)
      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

      public String getTitle()
    • getLink

      public String getLink()
    • getDescription

      public String getDescription()
    • getAuthor

      public String getAuthor()
    • getCategories

      public List<RssCategory> getCategories()
    • getComments

      public String getComments()
    • getEnclosure

      public RssEnclosure getEnclosure()
    • getGuid

      public String getGuid()
    • isGuidIsPermaLink

      public boolean isGuidIsPermaLink()
    • getPubDate

      public Date getPubDate()
    • getSource

      public String getSource()
    • getSourceUrl

      public String getSourceUrl()
    • getContentEncoded

      public String getContentEncoded()
    • toXmlElement

      public com.oorian.xml.XmlElement toXmlElement()
      Converts this item to an XmlElement.
      Returns:
      An XmlElement representing this <item> element with its sub-elements.