Package com.jalios.util
Class RssChannel
- java.lang.Object
-
- com.jalios.util.RssChannel
-
public class RssChannel extends java.lang.ObjectThis class implements a RSS Channel parser/container.
-
-
Constructor Summary
Constructors Constructor Description RssChannel(java.io.File file)Create a new RssChannel.RssChannel(java.io.File file, java.util.Set<RssEventListener> eventListeners)Create a new RssChannel.RssChannel(java.lang.String url, long ufreq)Create a new RssChannel.RssChannel(java.lang.String url, long ufreq, int timeout)Create a new RssChannel.RssChannel(java.lang.String url, long ufreq, int timeout, java.util.Set<RssEventListener> eventListeners)Create a new RssChannel.RssChannel(java.lang.String url, long ufreq, java.util.Set<RssEventListener> eventListeners)Create a new RssChannel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(RssEventListener listener)AddRssEventListenervoidaddListeners(java.util.Set<RssEventListener> listeners)AddRssEventListenerlist to existing listenersstatic java.util.DateconvertDate(java.lang.String date)static java.lang.StringgenerateID(java.lang.String id, int maxLength)compute a id from parameter.java.util.DategetBuildDate()java.lang.StringgetCopyright()Get the value of copyright.java.lang.StringgetDescription()Get the value of description.java.lang.StringgetDocs()Get the value of docs.java.lang.StringgetId()java.lang.StringgetImageDescription()Get the value of imageDescription.intgetImageHeight()Get the value of imageHeight.java.lang.StringgetImageLink()Get the value of imageLink.java.lang.StringgetImageTitle()Get the value of imageTitle.java.lang.StringgetImageUrl()Get the value of imageUrl.intgetImageWidth()Get the value of imageWidth.java.util.List<RssItem>getItemList()Retrieve the list of RssItem of this feed.java.lang.StringgetLanguage()Get the value of language.java.lang.StringgetLastBuildDate()Deprecated.java.util.DategetLastUpdate()Retrieve the Date at which this RssChannel was last build and parsed.java.lang.StringgetLink()Get the value of link.java.util.Set<RssEventListener>getListeners()returns theRssEventListenerSetjava.lang.StringgetManagingEditor()Get the value of managingEditor.java.util.DategetNextUpdate()Retrieve the Date at which this RssChannel should be left and parsed again.java.lang.StringgetPubDate()Deprecated.java.util.DategetPublicationDate()java.lang.StringgetRating()Get the value of rating.java.lang.StringgetSource()Retrieve the source of this RssChannel (used only for debugging purpose).java.lang.StringgetTextinputDescription()Get the value of textinputDescription.java.lang.StringgetTextinputLink()Get the value of textinputLink.java.lang.StringgetTextinputName()Get the value of textinputName.java.lang.StringgetTextinputTitle()Get the value of textinputTitle.java.lang.StringgetTitle()Retrieve the title of this RSS.longgetTtl()Retrieve the number of minutes indicating how long this channel can be cached before being refreshed from the source.longgetUfreq()Retrieve the update frequency of this RssChannel.java.lang.StringgetVersion()Retrieve the RSS version of this channel (such as 0.91, 1.0 for rdf, 2.0, ...).java.lang.StringgetWebMaster()Get the value of webMaster.booleanneedToRefresh()Determine if the channel must be refreshedvoidremoveListener(RssEventListener listener)RemoveRssEventListenerfrom existing listenervoidremoveListeners(java.util.List<RssEventListener> listeners)RemoveRssEventListenerfrom listener listvoidsetBuildDate(java.util.Date buildDate)voidsetCopyright(java.lang.String v)Set the value of copyright.voidsetDescription(java.lang.String v)Set the value of description.voidsetDocs(java.lang.String v)Set the value of docs.voidsetId(java.lang.String id)voidsetImageDescription(java.lang.String v)Set the value of imageDescription.voidsetImageHeight(int v)Set the value of imageHeight.voidsetImageHeightStr(java.lang.String heightStr)Set the value of imageHeight.voidsetImageLink(java.lang.String val)Set the value of imageLink.voidsetImageTitle(java.lang.String v)Set the value of imageTitle.voidsetImageUrl(java.lang.String v)Set the value of imageUrl.voidsetImageWidth(int v)Set the value of imageWidth.voidsetImageWidthStr(java.lang.String widthStr)Set the value of imageWidth.voidsetItemList(java.util.List<RssItem> list)Set the list of RssItem of this feed.voidsetLanguage(java.lang.String v)Set the value of language.voidsetLastBuildDate(java.lang.String v)Deprecated.voidsetLink(java.lang.String v)Set the value of link.voidsetListeners(java.util.Set<RssEventListener> listeners)voidsetManagingEditor(java.lang.String v)Set the value of managingEditor.voidsetPubDate(java.lang.String v)Deprecated.voidsetPublicationDate(java.util.Date publicationDate)voidsetRating(java.lang.String v)Set the value of rating.voidsetTextinputDescription(java.lang.String v)Set the value of textinputDescription.voidsetTextinputLink(java.lang.String v)Set the value of textinputLink.voidsetTextinputName(java.lang.String v)Set the value of textinputName.voidsetTextinputTitle(java.lang.String v)Set the value of textinputTitle.voidsetTitle(java.lang.String title)Set the title of this RSS.voidsetTtl(long ttl)Set the time to live of this RssChannelvoidsetTtl(java.lang.String ttlStr)Set the time to live of this RssChannelvoidsetUfreq(long ufreq)Set the update frequency of this RssChannel.voidsetVersion(java.lang.String version)Set the RSS version of this channel.voidsetWebMaster(java.lang.String v)Set the value of webMaster.java.lang.StringtoString()
-
-
-
Constructor Detail
-
RssChannel
public RssChannel(java.lang.String url, long ufreq) throws RssExceptionCreate 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(java.lang.String url, long ufreq, int timeout) throws RssExceptionCreate 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 minutestimeout- 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(java.io.File file) throws RssExceptionCreate 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(java.lang.String url, long ufreq, java.util.Set<RssEventListener> eventListeners) throws RssExceptionCreate 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 minuteseventListeners- Set ofRssEventListener- Throws:
RssException- if an error occured while getting or parsing the RSS- Since:
- JCMS 6.3
-
RssChannel
public RssChannel(java.lang.String url, long ufreq, int timeout, java.util.Set<RssEventListener> eventListeners) throws RssExceptionCreate 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 minutestimeout- 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 ofRssEventListener- Throws:
RssException- if an error occured while getting or parsing the RSS- Since:
- JCMS 6.3
-
RssChannel
public RssChannel(java.io.File file, java.util.Set<RssEventListener> eventListeners) throws RssExceptionCreate 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 readeventListeners- Set ofRssEventListener- Throws:
RssException- if an error occured while reading or parsing the RSS- Since:
- JCMS 6.3
-
-
Method Detail
-
needToRefresh
public boolean needToRefresh()
Determine if the channel must be refreshed- Returns:
- true if the channel must be refreshed
-
getLastUpdate
public java.util.Date getLastUpdate()
Retrieve the Date at which this RssChannel was last build and parsed.- Returns:
- the last update Date.
-
getNextUpdate
public java.util.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getVersion
public java.lang.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(java.lang.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 java.lang.String getTitle()
Retrieve the title of this RSS.- Returns:
- the rss' title.
-
setTitle
public void setTitle(java.lang.String title)
Set the title of this RSS.- Parameters:
title- the new title value
-
getLink
public java.lang.String getLink()
Get the value of link.- Returns:
- Value of link.
-
setLink
public void setLink(java.lang.String v)
Set the value of link.- Parameters:
v- Value to assign to link.
-
getDescription
public java.lang.String getDescription()
Get the value of description.- Returns:
- Value of description.
-
setDescription
public void setDescription(java.lang.String v)
Set the value of description.- Parameters:
v- Value to assign to description.
-
getRating
public java.lang.String getRating()
Get the value of rating.- Returns:
- Value of rating.
-
setRating
public void setRating(java.lang.String v)
Set the value of rating.- Parameters:
v- Value to assign to rating.
-
getLanguage
public java.lang.String getLanguage()
Get the value of language.- Returns:
- Value of language.
-
setLanguage
public void setLanguage(java.lang.String v)
Set the value of language.- Parameters:
v- Value to assign to language.
-
getCopyright
public java.lang.String getCopyright()
Get the value of copyright.- Returns:
- Value of copyright.
-
setCopyright
public void setCopyright(java.lang.String v)
Set the value of copyright.- Parameters:
v- Value to assign to copyright.
-
getManagingEditor
public java.lang.String getManagingEditor()
Get the value of managingEditor.- Returns:
- Value of managingEditor.
-
setManagingEditor
public void setManagingEditor(java.lang.String v)
Set the value of managingEditor.- Parameters:
v- Value to assign to managingEditor.
-
getWebMaster
public java.lang.String getWebMaster()
Get the value of webMaster.- Returns:
- Value of webMaster.
-
setWebMaster
public void setWebMaster(java.lang.String v)
Set the value of webMaster.- Parameters:
v- Value to assign to webMaster.
-
getImageTitle
public java.lang.String getImageTitle()
Get the value of imageTitle.- Returns:
- Value of imageTitle.
-
setImageTitle
public void setImageTitle(java.lang.String v)
Set the value of imageTitle.- Parameters:
v- Value to assign to imageTitle.
-
getImageUrl
public java.lang.String getImageUrl()
Get the value of imageUrl.- Returns:
- Value of imageUrl.
-
setImageUrl
public void setImageUrl(java.lang.String v)
Set the value of imageUrl.- Parameters:
v- Value to assign to imageUrl.
-
getImageLink
public java.lang.String getImageLink()
Get the value of imageLink.- Returns:
- Value of imageLink.
-
setImageLink
public void setImageLink(java.lang.String val)
Set the value of imageLink.- Parameters:
val- Value to assign to imageLink.
-
setImageWidthStr
public void setImageWidthStr(java.lang.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(java.lang.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 java.lang.String getImageDescription()
Get the value of imageDescription.- Returns:
- Value of imageDescription.
-
setImageDescription
public void setImageDescription(java.lang.String v)
Set the value of imageDescription.- Parameters:
v- Value to assign to imageDescription.
-
getTextinputTitle
public java.lang.String getTextinputTitle()
Get the value of textinputTitle.- Returns:
- Value of textinputTitle.
-
setTextinputTitle
public void setTextinputTitle(java.lang.String v)
Set the value of textinputTitle.- Parameters:
v- Value to assign to textinputTitle.
-
getTextinputDescription
public java.lang.String getTextinputDescription()
Get the value of textinputDescription.- Returns:
- Value of textinputDescription.
-
setTextinputDescription
public void setTextinputDescription(java.lang.String v)
Set the value of textinputDescription.- Parameters:
v- Value to assign to textinputDescription.
-
getTextinputName
public java.lang.String getTextinputName()
Get the value of textinputName.- Returns:
- Value of textinputName.
-
setTextinputName
public void setTextinputName(java.lang.String v)
Set the value of textinputName.- Parameters:
v- Value to assign to textinputName.
-
getTextinputLink
public java.lang.String getTextinputLink()
Get the value of textinputLink.- Returns:
- Value of textinputLink.
-
setTextinputLink
public void setTextinputLink(java.lang.String v)
Set the value of textinputLink.- Parameters:
v- Value to assign to textinputLink.
-
getPubDate
@Deprecated public java.lang.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(java.lang.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 java.lang.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(java.lang.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 java.util.Date getBuildDate()
- Returns:
- the buildDate
-
setBuildDate
public void setBuildDate(java.util.Date buildDate)
- Parameters:
buildDate- the buildDate to set
-
getDocs
public java.lang.String getDocs()
Get the value of docs.- Returns:
- Value of docs.
-
setDocs
public void setDocs(java.lang.String v)
Set the value of docs.- Parameters:
v- Value to assign to docs.
-
getItemList
public java.util.List<RssItem> getItemList()
Retrieve the list of RssItem of this feed.- Returns:
- a list of RssItem, never return null.
-
setItemList
public void setItemList(java.util.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(java.lang.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 java.lang.String getSource()
Retrieve the source of this RssChannel (used only for debugging purpose).- Returns:
- source of the channel (url or file path)
-
getPublicationDate
public java.util.Date getPublicationDate()
- Returns:
- the publicationDate
-
setPublicationDate
public void setPublicationDate(java.util.Date publicationDate)
- Parameters:
publicationDate- the publicationDate to set
-
getId
public java.lang.String getId()
- Returns:
- the id
-
setId
public void setId(java.lang.String id)
- Parameters:
id- the id to set
-
convertDate
public static java.util.Date convertDate(java.lang.String date)
-
getListeners
public java.util.Set<RssEventListener> getListeners()
returns theRssEventListenerSet- Returns:
- the list
- Since:
- JCMS 9.0.1
-
setListeners
public void setListeners(java.util.Set<RssEventListener> listeners)
- Parameters:
listeners- theRssEventListenerSet to set- Since:
- JCMS 9.0.1
-
addListeners
public void addListeners(java.util.Set<RssEventListener> listeners)
AddRssEventListenerlist to existing listeners- Parameters:
listeners- the Set- Since:
- JCMS 6.3
-
removeListeners
public void removeListeners(java.util.List<RssEventListener> listeners)
RemoveRssEventListenerfrom listener list- Parameters:
listeners- theRssEventListenerto remove- Since:
- JCMS 6.3
-
addListener
public void addListener(RssEventListener listener)
AddRssEventListener- Parameters:
listener- theRssEventListener- Since:
- JCMS 6.3
-
removeListener
public void removeListener(RssEventListener listener)
RemoveRssEventListenerfrom existing listener- Parameters:
listener- theRssEventListener- Since:
- JCMS 6.3
-
generateID
public static java.lang.String generateID(java.lang.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 idmaxLength- the max length of the id- Returns:
- the computed id
-
-