Class RssChannel

java.lang.Object
com.oorian.rss.RssChannel

public class RssChannel extends Object
Represents an RSS <channel> element containing feed metadata and items.

The channel is the top-level container in an RSS 2.0 feed. It requires a title, link, and description. All other elements are optional.

Supports the atom:link extension for declaring a self-referencing feed URL, which is recommended for feed validation.

Usage:


 RssChannel channel = new RssChannel("My Blog", "https://example.com", "Latest posts");
 channel.setLanguage("en-us")
        .setAtomSelfLink("https://example.com/feed")
        .addItem(new RssItem("Post Title", "https://example.com/post-1", "Summary"));
 
Since:
0.1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • RssChannel

      public RssChannel(String title, String link, String description)
      Creates a channel with the required title, link, and description.
      Parameters:
      title - The name of the channel.
      link - The URL to the HTML website corresponding to this channel.
      description - A phrase or sentence describing the channel.
  • Method Details

    • setLanguage

      public RssChannel setLanguage(String language)
      Sets the language the channel is written in (e.g., "en-us").
      Parameters:
      language - The language code.
      Returns:
      This channel for method chaining.
    • setCopyright

      public RssChannel setCopyright(String copyright)
      Sets the copyright notice for the content of this channel.
      Parameters:
      copyright - The copyright notice text.
      Returns:
      This channel for method chaining.
    • setManagingEditor

      public RssChannel setManagingEditor(String managingEditor)
      Sets the email address for the managing editor of the channel content.
      Parameters:
      managingEditor - The editor email address.
      Returns:
      This channel for method chaining.
    • setWebMaster

      public RssChannel setWebMaster(String webMaster)
      Sets the email address for the webmaster responsible for technical issues.
      Parameters:
      webMaster - The webmaster email address.
      Returns:
      This channel for method chaining.
    • setPubDate

      public RssChannel setPubDate(Date pubDate)
      Sets the publication date for the content in this channel.
      Parameters:
      pubDate - The publication date.
      Returns:
      This channel for method chaining.
    • setLastBuildDate

      public RssChannel setLastBuildDate(Date lastBuildDate)
      Sets the last time the content of the channel changed.
      Parameters:
      lastBuildDate - The date of the last content change.
      Returns:
      This channel for method chaining.
    • setGenerator

      public RssChannel setGenerator(String generator)
      Sets the program used to generate the channel. Defaults to "Oorian Framework".
      Parameters:
      generator - The generator string, or null to omit the element.
      Returns:
      This channel for method chaining.
    • setDocs

      public RssChannel setDocs(String docs)
      Sets the URL that points to the documentation for the RSS format used.
      Parameters:
      docs - The documentation URL.
      Returns:
      This channel for method chaining.
    • setTtl

      public RssChannel setTtl(int ttl)
      Sets the time to live (TTL) in minutes, indicating how long a channel can be cached before refreshing from the source.
      Parameters:
      ttl - The number of minutes to cache.
      Returns:
      This channel for method chaining.
    • setImage

      public RssChannel setImage(RssImage image)
      Sets the channel image (logo).
      Parameters:
      image - The channel image.
      Returns:
      This channel for method chaining.
    • setAtomSelfLink

      public RssChannel setAtomSelfLink(String atomSelfLink)
      Sets the self-referencing Atom link for this feed. This is recommended for feed validation and discovery.

      When set, an <atom:link> element will be added to the channel, and the Atom namespace will be declared on the RSS root element.

      Parameters:
      atomSelfLink - The full URL of this feed.
      Returns:
      This channel for method chaining.
    • addItem

      public RssChannel addItem(RssItem item)
      Adds an item to this channel.
      Parameters:
      item - The item to add.
      Returns:
      This channel for method chaining.
    • addCategory

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

      public RssChannel addCategory(String value, String domain)
      Adds a category with a domain to this channel.
      Parameters:
      value - The category text value.
      domain - The domain URI identifying the categorization taxonomy.
      Returns:
      This channel for method chaining.
    • getTitle

      public String getTitle()
    • getLink

      public String getLink()
    • getDescription

      public String getDescription()
    • getLanguage

      public String getLanguage()
    • getCopyright

      public String getCopyright()
    • getManagingEditor

      public String getManagingEditor()
    • getWebMaster

      public String getWebMaster()
    • getPubDate

      public Date getPubDate()
    • getLastBuildDate

      public Date getLastBuildDate()
    • getGenerator

      public String getGenerator()
    • getDocs

      public String getDocs()
    • getTtl

      public int getTtl()
    • getImage

      public RssImage getImage()
    • getCategories

      public List<RssCategory> getCategories()
    • getItems

      public List<RssItem> getItems()
    • getAtomSelfLink

      public String getAtomSelfLink()
    • formatRfc822Date

      public static String formatRfc822Date(Date date)
      Formats a Date as an RFC 822 date string suitable for RSS date elements.
      Parameters:
      date - The date to format.
      Returns:
      The RFC 822 formatted date string (e.g., "Mon, 16 Feb 2026 12:00:00 +0000").
    • toXmlElement

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