Class RssChannel

java.lang.Object
com.jalios.util.RssChannel

public class RssChannel extends Object
This class implements a RSS Channel parser/container.
  • Constructor Details

    • RssChannel

      public RssChannel(String url, long ufreq) throws RssException
      Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.
      Parameters:
      url - the URL of the RSS channel (a remote location using http or https)
      ufreq - the update frequency, in minutes
      Throws:
      RssException - if an error occured while getting or parsing the RSS
    • RssChannel

      public RssChannel(String url, long ufreq, int timeout) throws RssException
      Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.
      Parameters:
      url - the URL of the RSS channel (a remote location using http or https)
      ufreq - the update frequency, in minutes
      timeout - the time (in milliseconds) to wait for a connection to become available. Default value is 3000 (3 seconds). Default value will be used if zero or a negative value is specified.
      Throws:
      RssException - if an error occured while getting or parsing the RSS
    • RssChannel

      public RssChannel(File file) throws RssException
      Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.
      Parameters:
      file - the RSS XML file to read
      Throws:
      RssException - if an error occured while reading or parsing the RSS
    • RssChannel

      public RssChannel(String url, long ufreq, Set<RssEventListener> eventListeners) throws RssException
      Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.
      Parameters:
      url - the URL of the RSS channel (a remote location using http or https)
      ufreq - the update frequency, in minutes
      eventListeners - Set of RssEventListener
      Throws:
      RssException - if an error occured while getting or parsing the RSS
      Since:
      JCMS 6.3
    • RssChannel

      public RssChannel(String url, long ufreq, int timeout, Set<RssEventListener> eventListeners) throws RssException
      Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.
      Parameters:
      url - the URL of the RSS channel (a remote location using http or https)
      ufreq - the update frequency, in minutes
      timeout - the time (in milliseconds) to wait for a connection to become available. Default value is 3000 (3 seconds). Default value will be used if zero or a negative value is specified.
      eventListeners - Set of RssEventListener
      Throws:
      RssException - if an error occured while getting or parsing the RSS
      Since:
      JCMS 6.3
    • RssChannel

      public RssChannel(File file, Set<RssEventListener> eventListeners) throws RssException
      Create a new RssChannel. Fill this object with the data located at the given URI. Set the update frequency.
      Parameters:
      file - the RSS XML file to read
      eventListeners - Set of RssEventListener
      Throws:
      RssException - if an error occured while reading or parsing the RSS
      Since:
      JCMS 6.3
  • Method Details

    • needToRefresh

      public boolean needToRefresh()
      Determine if the channel must be refreshed
      Returns:
      true if the channel must be refreshed
    • getLastUpdate

      public Date getLastUpdate()
      Retrieve the Date at which this RssChannel was last build and parsed.
      Returns:
      the last update Date.
    • getNextUpdate

      public Date getNextUpdate()
      Retrieve the Date at which this RssChannel should be left and parsed again.
      Returns:
      the next update Date == last update + (ttl || ufreq).
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getVersion

      public String getVersion()
      Retrieve the RSS version of this channel (such as 0.91, 1.0 for rdf, 2.0, ...).
      Returns:
      the rss version.
    • setVersion

      public void setVersion(String version)
      Set the RSS version of this channel.
      Parameters:
      version - the rss version (such as 0.91, 1.0 for rdf, 2.0, ...)
    • getTitle

      public String getTitle()
      Retrieve the title of this RSS.
      Returns:
      the rss' title.
    • setTitle

      public void setTitle(String title)
      Set the title of this RSS.
      Parameters:
      title - the new title value
    • getLink

      public String getLink()
      Get the value of link.
      Returns:
      Value of link.
    • setLink

      public void setLink(String v)
      Set the value of link.
      Parameters:
      v - Value to assign to link.
    • getDescription

      public String getDescription()
      Get the value of description.
      Returns:
      Value of description.
    • setDescription

      public void setDescription(String v)
      Set the value of description.
      Parameters:
      v - Value to assign to description.
    • getRating

      public String getRating()
      Get the value of rating.
      Returns:
      Value of rating.
    • setRating

      public void setRating(String v)
      Set the value of rating.
      Parameters:
      v - Value to assign to rating.
    • getLanguage

      public String getLanguage()
      Get the value of language.
      Returns:
      Value of language.
    • setLanguage

      public void setLanguage(String v)
      Set the value of language.
      Parameters:
      v - Value to assign to language.
    • getCopyright

      public String getCopyright()
      Get the value of copyright.
      Returns:
      Value of copyright.
    • setCopyright

      public void setCopyright(String v)
      Set the value of copyright.
      Parameters:
      v - Value to assign to copyright.
    • getManagingEditor

      public String getManagingEditor()
      Get the value of managingEditor.
      Returns:
      Value of managingEditor.
    • setManagingEditor

      public void setManagingEditor(String v)
      Set the value of managingEditor.
      Parameters:
      v - Value to assign to managingEditor.
    • getWebMaster

      public String getWebMaster()
      Get the value of webMaster.
      Returns:
      Value of webMaster.
    • setWebMaster

      public void setWebMaster(String v)
      Set the value of webMaster.
      Parameters:
      v - Value to assign to webMaster.
    • getImageTitle

      public String getImageTitle()
      Get the value of imageTitle.
      Returns:
      Value of imageTitle.
    • setImageTitle

      public void setImageTitle(String v)
      Set the value of imageTitle.
      Parameters:
      v - Value to assign to imageTitle.
    • getImageUrl

      public String getImageUrl()
      Get the value of imageUrl.
      Returns:
      Value of imageUrl.
    • setImageUrl

      public void setImageUrl(String v)
      Set the value of imageUrl.
      Parameters:
      v - Value to assign to imageUrl.
    • getImageLink

      public String getImageLink()
      Get the value of imageLink.
      Returns:
      Value of imageLink.
    • setImageLink

      public void setImageLink(String val)
      Set the value of imageLink.
      Parameters:
      val - Value to assign to imageLink.
    • setImageWidthStr

      public void setImageWidthStr(String widthStr)
      Set the value of imageWidth.
      Parameters:
      widthStr - Value to assign to imageWidth.
    • getImageWidth

      public int getImageWidth()
      Get the value of imageWidth.
      Returns:
      Value of imageWidth.
    • setImageWidth

      public void setImageWidth(int v)
      Set the value of imageWidth.
      Parameters:
      v - Value to assign to imageWidth.
    • setImageHeightStr

      public void setImageHeightStr(String heightStr)
      Set the value of imageHeight.
      Parameters:
      heightStr - Value to assign to imageHeight.
    • getImageHeight

      public int getImageHeight()
      Get the value of imageHeight.
      Returns:
      Value of imageHeight.
    • setImageHeight

      public void setImageHeight(int v)
      Set the value of imageHeight.
      Parameters:
      v - Value to assign to imageHeight.
    • getImageDescription

      public String getImageDescription()
      Get the value of imageDescription.
      Returns:
      Value of imageDescription.
    • setImageDescription

      public void setImageDescription(String v)
      Set the value of imageDescription.
      Parameters:
      v - Value to assign to imageDescription.
    • getTextinputTitle

      public String getTextinputTitle()
      Get the value of textinputTitle.
      Returns:
      Value of textinputTitle.
    • setTextinputTitle

      public void setTextinputTitle(String v)
      Set the value of textinputTitle.
      Parameters:
      v - Value to assign to textinputTitle.
    • getTextinputDescription

      public String getTextinputDescription()
      Get the value of textinputDescription.
      Returns:
      Value of textinputDescription.
    • setTextinputDescription

      public void setTextinputDescription(String v)
      Set the value of textinputDescription.
      Parameters:
      v - Value to assign to textinputDescription.
    • getTextinputName

      public String getTextinputName()
      Get the value of textinputName.
      Returns:
      Value of textinputName.
    • setTextinputName

      public void setTextinputName(String v)
      Set the value of textinputName.
      Parameters:
      v - Value to assign to textinputName.
    • getTextinputLink

      public String getTextinputLink()
      Get the value of textinputLink.
      Returns:
      Value of textinputLink.
    • setTextinputLink

      public void setTextinputLink(String v)
      Set the value of textinputLink.
      Parameters:
      v - Value to assign to textinputLink.
    • getPubDate

      @Deprecated public String getPubDate()
      Deprecated.
      Get the value of pubDate. This method is deprecated. getPublicationDate must be use instead This method returns date in ISO 8601 format
      Returns:
      Value of pubDate.
    • setPubDate

      @Deprecated public void setPubDate(String v)
      Deprecated.
      Set the value of pubDate. This methos is deprecated and setPublication(Date date) must be use instead
      Parameters:
      v - Value to assign to pubDate.
    • getLastBuildDate

      @Deprecated public String getLastBuildDate()
      Deprecated.
      Get the value of lastBuildDate.This method is deprecated. getBuildDate must be use instead This method returns date in ISO 8601 format
      Returns:
      Value of lastBuildDate.
    • setLastBuildDate

      @Deprecated public void setLastBuildDate(String v)
      Deprecated.
      Set the value of lastBuildDate. This methos is deprecated and setBuildDate(Date date) must be use instead
      Parameters:
      v - Value to assign to lastBuildDate.
    • getBuildDate

      public Date getBuildDate()
      Returns:
      the buildDate
    • setBuildDate

      public void setBuildDate(Date buildDate)
      Parameters:
      buildDate - the buildDate to set
    • getDocs

      public String getDocs()
      Get the value of docs.
      Returns:
      Value of docs.
    • setDocs

      public void setDocs(String v)
      Set the value of docs.
      Parameters:
      v - Value to assign to docs.
    • getItemList

      public List<RssItem> getItemList()
      Retrieve the list of RssItem of this feed.
      Returns:
      a list of RssItem, never return null.
    • setItemList

      public void setItemList(List<RssItem> list)
      Set the list of RssItem of this feed.
      Parameters:
      list - a list list of RssItem, must not be null
    • getTtl

      public long getTtl()
      Retrieve the number of minutes indicating how long this channel can be cached before being refreshed from the source.
      Returns:
      the "time to live" in minutes.
    • setTtl

      public void setTtl(long ttl)
      Set the time to live of this RssChannel
      Parameters:
      ttl - time to live in minutes.
    • setTtl

      public void setTtl(String ttlStr)
      Set the time to live of this RssChannel
      Parameters:
      ttlStr - time to live in minutes.
    • getUfreq

      public long getUfreq()
      Retrieve the update frequency of this RssChannel.
      Returns:
      the update frequency in minutes.
    • setUfreq

      public void setUfreq(long ufreq)
      Set the update frequency of this RssChannel.
      Parameters:
      ufreq - the new update frequency value, in minutes.
    • getSource

      public String getSource()
      Retrieve the source of this RssChannel (used only for debugging purpose).
      Returns:
      source of the channel (url or file path)
    • getPublicationDate

      public Date getPublicationDate()
      Returns:
      the publicationDate
    • setPublicationDate

      public void setPublicationDate(Date publicationDate)
      Parameters:
      publicationDate - the publicationDate to set
    • getId

      public String getId()
      Returns:
      the id
    • setId

      public void setId(String id)
      Parameters:
      id - the id to set
    • convertDate

      public static Date convertDate(String date)
    • getListeners

      public Set<RssEventListener> getListeners()
      returns the RssEventListener Set
      Returns:
      the list
      Since:
      JCMS 9.0.1
    • setListeners

      public void setListeners(Set<RssEventListener> listeners)
      Parameters:
      listeners - the RssEventListener Set to set
      Since:
      JCMS 9.0.1
    • addListeners

      public void addListeners(Set<RssEventListener> listeners)
      Add RssEventListener list to existing listeners
      Parameters:
      listeners - the Set
      Since:
      JCMS 6.3
    • removeListeners

      public void removeListeners(List<RssEventListener> listeners)
      Remove RssEventListener from listener list
      Parameters:
      listeners - the RssEventListener to remove
      Since:
      JCMS 6.3
    • addListener

      public void addListener(RssEventListener listener)
      Parameters:
      listener - the RssEventListener
      Since:
      JCMS 6.3
    • removeListener

      public void removeListener(RssEventListener listener)
      Remove RssEventListener from existing listener
      Parameters:
      listener - the RssEventListener
      Since:
      JCMS 6.3
    • generateID

      public static String generateID(String id, int maxLength)
      compute a id from parameter. If the id length is less than maxLength parameter, the id is returned. Else the id is truncated and an MD5sum of id is added to the length of the string
      Parameters:
      id - the string which should be an id
      maxLength - the max length of the id
      Returns:
      the computed id