Package com.jalios.util
Class RssChannel
java.lang.Object
com.jalios.util.RssChannel
This class implements a RSS Channel parser/container.
-
Constructor Summary
ConstructorsConstructorDescriptionRssChannel(File file) Create a new RssChannel.RssChannel(File file, Set<RssEventListener> eventListeners) Create a new RssChannel.RssChannel(String url, long ufreq) Create a new RssChannel.RssChannel(String url, long ufreq, int timeout) Create a new RssChannel.RssChannel(String url, long ufreq, int timeout, Set<RssEventListener> eventListeners) Create a new RssChannel.RssChannel(String url, long ufreq, Set<RssEventListener> eventListeners) Create a new RssChannel. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(RssEventListener listener) AddRssEventListenervoidaddListeners(Set<RssEventListener> listeners) AddRssEventListenerlist to existing listenersstatic DateconvertDate(String date) static StringgenerateID(String id, int maxLength) compute a id from parameter.Get the value of copyright.Get the value of description.getDocs()Get the value of docs.getId()Get the value of imageDescription.intGet the value of imageHeight.Get the value of imageLink.Get the value of imageTitle.Get the value of imageUrl.intGet the value of imageWidth.Retrieve the list of RssItem of this feed.Get the value of language.Deprecated.Retrieve the Date at which this RssChannel was last build and parsed.getLink()Get the value of link.returns theRssEventListenerSetGet the value of managingEditor.Retrieve the Date at which this RssChannel should be left and parsed again.Deprecated.Get the value of rating.Retrieve the source of this RssChannel (used only for debugging purpose).Get the value of textinputDescription.Get the value of textinputLink.Get the value of textinputName.Get the value of textinputTitle.getTitle()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.Retrieve the RSS version of this channel (such as 0.91, 1.0 for rdf, 2.0, ...).Get the value of webMaster.booleanDetermine if the channel must be refreshedvoidremoveListener(RssEventListener listener) RemoveRssEventListenerfrom existing listenervoidremoveListeners(List<RssEventListener> listeners) RemoveRssEventListenerfrom listener listvoidsetBuildDate(Date buildDate) voidSet the value of copyright.voidSet the value of description.voidSet the value of docs.voidvoidSet the value of imageDescription.voidsetImageHeight(int v) Set the value of imageHeight.voidsetImageHeightStr(String heightStr) Set the value of imageHeight.voidsetImageLink(String val) Set the value of imageLink.voidSet the value of imageTitle.voidSet the value of imageUrl.voidsetImageWidth(int v) Set the value of imageWidth.voidsetImageWidthStr(String widthStr) Set the value of imageWidth.voidsetItemList(List<RssItem> list) Set the list of RssItem of this feed.voidSet the value of language.voidDeprecated.voidSet the value of link.voidsetListeners(Set<RssEventListener> listeners) voidSet the value of managingEditor.voidsetPubDate(String v) Deprecated.voidsetPublicationDate(Date publicationDate) voidSet the value of rating.voidSet the value of textinputDescription.voidSet the value of textinputLink.voidSet the value of textinputName.voidSet the value of textinputTitle.voidSet the title of this RSS.voidsetTtl(long ttl) Set the time to live of this RssChannelvoidSet the time to live of this RssChannelvoidsetUfreq(long ufreq) Set the update frequency of this RssChannel.voidsetVersion(String version) Set the RSS version of this channel.voidSet the value of webMaster.toString()
-
Constructor Details
-
RssChannel
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
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 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
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
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 minuteseventListeners- Set ofRssEventListener- 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 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
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 readeventListeners- Set ofRssEventListener- 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
Retrieve the Date at which this RssChannel was last build and parsed.- Returns:
- the last update 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
-
getVersion
Retrieve the RSS version of this channel (such as 0.91, 1.0 for rdf, 2.0, ...).- Returns:
- the rss version.
-
setVersion
Set the RSS version of this channel.- Parameters:
version- the rss version (such as 0.91, 1.0 for rdf, 2.0, ...)
-
getTitle
Retrieve the title of this RSS.- Returns:
- the rss' title.
-
setTitle
Set the title of this RSS.- Parameters:
title- the new title value
-
getLink
Get the value of link.- Returns:
- Value of link.
-
setLink
Set the value of link.- Parameters:
v- Value to assign to link.
-
getDescription
Get the value of description.- Returns:
- Value of description.
-
setDescription
Set the value of description.- Parameters:
v- Value to assign to description.
-
getRating
Get the value of rating.- Returns:
- Value of rating.
-
setRating
Set the value of rating.- Parameters:
v- Value to assign to rating.
-
getLanguage
Get the value of language.- Returns:
- Value of language.
-
setLanguage
Set the value of language.- Parameters:
v- Value to assign to language.
-
getCopyright
Get the value of copyright.- Returns:
- Value of copyright.
-
setCopyright
Set the value of copyright.- Parameters:
v- Value to assign to copyright.
-
getManagingEditor
Get the value of managingEditor.- Returns:
- Value of managingEditor.
-
setManagingEditor
Set the value of managingEditor.- Parameters:
v- Value to assign to managingEditor.
-
getWebMaster
Get the value of webMaster.- Returns:
- Value of webMaster.
-
setWebMaster
Set the value of webMaster.- Parameters:
v- Value to assign to webMaster.
-
getImageTitle
Get the value of imageTitle.- Returns:
- Value of imageTitle.
-
setImageTitle
Set the value of imageTitle.- Parameters:
v- Value to assign to imageTitle.
-
getImageUrl
Get the value of imageUrl.- Returns:
- Value of imageUrl.
-
setImageUrl
Set the value of imageUrl.- Parameters:
v- Value to assign to imageUrl.
-
getImageLink
Get the value of imageLink.- Returns:
- Value of imageLink.
-
setImageLink
Set the value of imageLink.- Parameters:
val- Value to assign to imageLink.
-
setImageWidthStr
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
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
Get the value of imageDescription.- Returns:
- Value of imageDescription.
-
setImageDescription
Set the value of imageDescription.- Parameters:
v- Value to assign to imageDescription.
-
getTextinputTitle
Get the value of textinputTitle.- Returns:
- Value of textinputTitle.
-
setTextinputTitle
Set the value of textinputTitle.- Parameters:
v- Value to assign to textinputTitle.
-
getTextinputDescription
Get the value of textinputDescription.- Returns:
- Value of textinputDescription.
-
setTextinputDescription
Set the value of textinputDescription.- Parameters:
v- Value to assign to textinputDescription.
-
getTextinputName
Get the value of textinputName.- Returns:
- Value of textinputName.
-
setTextinputName
Set the value of textinputName.- Parameters:
v- Value to assign to textinputName.
-
getTextinputLink
Get the value of textinputLink.- Returns:
- Value of textinputLink.
-
setTextinputLink
Set the value of textinputLink.- Parameters:
v- Value to assign to textinputLink.
-
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.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.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.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
- Returns:
- the buildDate
-
setBuildDate
- Parameters:
buildDate- the buildDate to set
-
getDocs
Get the value of docs.- Returns:
- Value of docs.
-
setDocs
Set the value of docs.- Parameters:
v- Value to assign to docs.
-
getItemList
Retrieve the list of RssItem of this feed.- Returns:
- a list of RssItem, never return null.
-
setItemList
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
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
Retrieve the source of this RssChannel (used only for debugging purpose).- Returns:
- source of the channel (url or file path)
-
getPublicationDate
- Returns:
- the publicationDate
-
setPublicationDate
- Parameters:
publicationDate- the publicationDate to set
-
getId
- Returns:
- the id
-
setId
- Parameters:
id- the id to set
-
convertDate
-
getListeners
returns theRssEventListenerSet- Returns:
- the list
- Since:
- JCMS 9.0.1
-
setListeners
- Parameters:
listeners- theRssEventListenerSet to set- Since:
- JCMS 9.0.1
-
addListeners
AddRssEventListenerlist to existing listeners- Parameters:
listeners- the Set- Since:
- JCMS 6.3
-
removeListeners
RemoveRssEventListenerfrom listener list- Parameters:
listeners- theRssEventListenerto remove- Since:
- JCMS 6.3
-
addListener
AddRssEventListener- Parameters:
listener- theRssEventListener- Since:
- JCMS 6.3
-
removeListener
RemoveRssEventListenerfrom existing listener- Parameters:
listener- theRssEventListener- Since:
- JCMS 6.3
-
generateID
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
-