org.clapper.curn
Class CurnConfig

java.lang.Object
  extended by Configuration
      extended by org.clapper.curn.CurnConfig

public class CurnConfig
extends Configuration

CurnConfig uses the Configuration class (part of the clapper.org Java Utility library) to parse and validate the curn configuration file, holding the results in memory for easy access.

Version:
$Revision$

Field Summary
static java.lang.String CFG_ALLOW_EMBEDDED_HTML
          Configuration variable: allow embedded HTML.
static int DEF_DAYS_TO_CACHE
          Default values
static int DEF_MAX_THREADS
           
static boolean DEF_NO_CACHE_UPDATE
           
static java.lang.String DEF_PARSER_CLASS_NAME
           
static boolean DEF_SAVE_ONLY
           
static boolean DEF_SHOW_RSS_VERSION
           
static java.lang.String MAIN_SECTION
          Main section name
static java.lang.String NO_LIMIT_VALUE
          Others
static java.lang.String VAR_CLASS
           
static java.lang.String VAR_DAYS_TO_CACHE
           
static java.lang.String VAR_DISABLED
           
static java.lang.String VAR_FEED_URL
           
static java.lang.String VAR_FORCE_CHAR_ENCODING
           
static java.lang.String VAR_FORCE_ENCODING
           
static java.lang.String VAR_MAIL_SUBJECT
           
static java.lang.String VAR_MAX_THREADS
           
static java.lang.String VAR_NO_CACHE_UPDATE
          Variable names
static java.lang.String VAR_PARSER_CLASS_NAME
           
static java.lang.String VAR_SHOW_RSS_VERSION
           
 
Method Summary
 java.lang.String getDeprecatedParamMessage(java.lang.String badParam, java.lang.String goodParam)
          Utility method that retrieves a "deprecated parameter" warning.
 java.util.Map<java.net.URL,FeedInfo> getFeedInfoMap()
          Get the FeedInfo map.
 java.util.Collection<FeedInfo> getFeeds()
          Get the configured RSS feeds.
 int getMaxThreads()
          Get the maximum number of concurrent threads to spawn when retrieving RSS feeds.
 java.util.Collection<ConfiguredOutputHandler> getOutputHandlers()
          Gets the list of output handlers from the configuration, in the order they appeared in the configuration.
 java.lang.String getRSSParserClassName()
          Get the name of the RSS parser class to use.
 boolean hasFeed(java.net.URL url)
          Determine whether the specified URL is one of the configured RSS feeds.
 void load(java.io.File file)
          Load configuration from a file.
 void load(java.io.InputStream iStream)
          Load configuration from an open InputStream.
 void load(java.lang.String path)
          Load configuration from a path.
 void load(java.net.URL url)
          Load configuration from a URL.
 boolean mustUpdateFeedMetadata()
          Determine whether the cache should be updated.
 void setMaxThreads(int newValue)
          Set the maximum number of concurrent threads to spawn when retrieving RSS feeds.
 void setMustUpdateFeedMetadata(boolean val)
          Change the "update cache" flag.
 void setShowRSSVersionFlag(boolean val)
          Set the value of the "show RSS version" flag.
 boolean showRSSVersion()
          Return the value of "show RSS version" flag.
 int totalOutputHandlers()
          Return the total number of configured output handlers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VAR_NO_CACHE_UPDATE

public static final java.lang.String VAR_NO_CACHE_UPDATE
Variable names

See Also:
Constant Field Values

VAR_MAIL_SUBJECT

public static final java.lang.String VAR_MAIL_SUBJECT
See Also:
Constant Field Values

VAR_DAYS_TO_CACHE

public static final java.lang.String VAR_DAYS_TO_CACHE
See Also:
Constant Field Values

VAR_PARSER_CLASS_NAME

public static final java.lang.String VAR_PARSER_CLASS_NAME
See Also:
Constant Field Values

VAR_SHOW_RSS_VERSION

public static final java.lang.String VAR_SHOW_RSS_VERSION
See Also:
Constant Field Values

VAR_FEED_URL

public static final java.lang.String VAR_FEED_URL
See Also:
Constant Field Values

VAR_CLASS

public static final java.lang.String VAR_CLASS
See Also:
Constant Field Values

VAR_MAX_THREADS

public static final java.lang.String VAR_MAX_THREADS
See Also:
Constant Field Values

VAR_FORCE_ENCODING

public static final java.lang.String VAR_FORCE_ENCODING
See Also:
Constant Field Values

VAR_FORCE_CHAR_ENCODING

public static final java.lang.String VAR_FORCE_CHAR_ENCODING
See Also:
Constant Field Values

VAR_DISABLED

public static final java.lang.String VAR_DISABLED
See Also:
Constant Field Values

CFG_ALLOW_EMBEDDED_HTML

public static final java.lang.String CFG_ALLOW_EMBEDDED_HTML
Configuration variable: allow embedded HTML. Not used here. Used by a plug-in and by output handlers.

See Also:
Constant Field Values

DEF_DAYS_TO_CACHE

public static final int DEF_DAYS_TO_CACHE
Default values

See Also:
Constant Field Values

DEF_NO_CACHE_UPDATE

public static final boolean DEF_NO_CACHE_UPDATE
See Also:
Constant Field Values

DEF_SHOW_RSS_VERSION

public static final boolean DEF_SHOW_RSS_VERSION
See Also:
Constant Field Values

DEF_SAVE_ONLY

public static final boolean DEF_SAVE_ONLY
See Also:
Constant Field Values

DEF_PARSER_CLASS_NAME

public static final java.lang.String DEF_PARSER_CLASS_NAME
See Also:
Constant Field Values

DEF_MAX_THREADS

public static final int DEF_MAX_THREADS
See Also:
Constant Field Values

NO_LIMIT_VALUE

public static final java.lang.String NO_LIMIT_VALUE
Others

See Also:
Constant Field Values

MAIN_SECTION

public static final java.lang.String MAIN_SECTION
Main section name

See Also:
Constant Field Values
Method Detail

getRSSParserClassName

public java.lang.String getRSSParserClassName()
Get the name of the RSS parser class to use. The caller is responsible for loading the returned class name and verifying that it implements the appropriate interface(s).

Returns:
the full class name

getOutputHandlers

public java.util.Collection<ConfiguredOutputHandler> getOutputHandlers()
Gets the list of output handlers from the configuration, in the order they appeared in the configuration.

Returns:
an unmodifiable Collection of ConfiguredOutputHandler objects. The collection will be empty, but never null, if no output handlers were configured.

totalOutputHandlers

public int totalOutputHandlers()
Return the total number of configured output handlers.

Returns:
the total number of configured output handlers, or 0 if there aren't any

mustUpdateFeedMetadata

public boolean mustUpdateFeedMetadata()
Determine whether the cache should be updated.

Returns:
true if the cache should be updated, false if it should not.
See Also:
setMustUpdateFeedMetadata(boolean)

getMaxThreads

public int getMaxThreads()
Get the maximum number of concurrent threads to spawn when retrieving RSS feeds.

Returns:
the maximum number of threads
See Also:
setMaxThreads(int)

setMaxThreads

public void setMaxThreads(int newValue)
                   throws ConfigurationException
Set the maximum number of concurrent threads to spawn when retrieving RSS feeds.

Parameters:
newValue - the maximum number of threads
Throws:
ConfigurationException - bad value
See Also:
getMaxThreads()

setMustUpdateFeedMetadata

public void setMustUpdateFeedMetadata(boolean val)
Change the "update cache" flag.

Parameters:
val - true if the cache should be updated, false if it should not
See Also:
mustUpdateFeedMetadata()

showRSSVersion

public boolean showRSSVersion()
Return the value of "show RSS version" flag.

Returns:
true if flag is set, false if it isn't
See Also:
setShowRSSVersionFlag(boolean)

setShowRSSVersionFlag

public void setShowRSSVersionFlag(boolean val)
Set the value of the "show RSS version" flag.

Parameters:
val - true to set the flag, false to clear it
See Also:
showRSSVersion()

getFeeds

public java.util.Collection<FeedInfo> getFeeds()
Get the configured RSS feeds. The feeds are returned in the order they were specified in the configuration file.

Returns:
a Collection of FeedInfo objects.
See Also:
hasFeed(java.net.URL), getFeedInfoMap()

hasFeed

public boolean hasFeed(java.net.URL url)
Determine whether the specified URL is one of the configured RSS feeds.

Parameters:
url - the URL
Returns:
true if it's there, false if not
See Also:
getFeeds(), getFeedInfoMap()

getFeedInfoMap

public java.util.Map<java.net.URL,FeedInfo> getFeedInfoMap()
Get the FeedInfo map.

Returns:
A Map of FeedInfo objects, indexed by channel (or feed) URL.
See Also:
getFeeds(), hasFeed(java.net.URL), FeedInfo

getDeprecatedParamMessage

public java.lang.String getDeprecatedParamMessage(java.lang.String badParam,
                                                  java.lang.String goodParam)
Utility method that retrieves a "deprecated parameter" warning.

Parameters:
badParam - the deprecated parameter
goodParam - the parameter that should be used, or null for none
Returns:
the message

load

public void load(java.lang.String path)
          throws java.io.FileNotFoundException,
                 java.io.IOException,
                 ConfigurationException
Load configuration from a path. Any existing data is discarded.

Parameters:
path - the path
Throws:
java.io.IOException - read error
ConfigurationException - parse error
java.io.FileNotFoundException

load

public void load(java.io.InputStream iStream)
          throws java.io.IOException,
                 ConfigurationException
Load configuration from an open InputStream. Any existing data is discarded.

Parameters:
iStream - open input stream
Throws:
java.io.IOException - read error
ConfigurationException - parse error

load

public void load(java.net.URL url)
          throws java.io.IOException,
                 ConfigurationException
Load configuration from a URL. Any existing data is discarded.

Parameters:
url - the URL
Throws:
java.io.IOException - read error
ConfigurationException - parse error

load

public void load(java.io.File file)
          throws java.io.IOException,
                 ConfigurationException
Load configuration from a file. Any existing data is discarded.

Parameters:
file - the file
Throws:
java.io.IOException - read error
ConfigurationException - parse error


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.