org.clapper.curn
Class Tool

java.lang.Object
  extended by org.clapper.util.cmdline.CommandLineUtility
      extended by org.clapper.curn.Tool
All Implemented Interfaces:
PlugIn, PostConfigPlugIn

public class Tool
extends org.clapper.util.cmdline.CommandLineUtility
implements PostConfigPlugIn

curn: Customizable Utilitarian RSS Notifier.

curn is an RSS reader. It scans a configured set of URLs, each one representing an RSS feed, and summarizes the results in an easy-to-read text format. curn keeps track of URLs it's seen before, using an on-disk cache; when using the cache, it will suppress displaying URLs it has already reported (though that behavior can be disabled). curn can be extended to use any RSS parser; by default, it uses the ROME parser.

This class is a command-line wrapper for curn. Run it with no parameters for a usage summary.

Version:
$Revision: 6586 $

Method Summary
protected  void getCustomUsageInfo(org.clapper.util.cmdline.UsageInfo info)
          Called by parseParams() to get the custom command-line options and parameters handled by the subclass.
 java.lang.String getPlugInName()
          Get a displayable name for the plug-in.
 java.lang.String getPlugInSortKey()
          Get the sort key for this plug-in.
 void initPlugIn()
          Initialize the plug-in.
static void main(java.lang.String[] args)
           
protected  void parseCustomOption(char shortOption, java.lang.String longOption, java.util.Iterator<java.lang.String> it)
          Called by parseParams() to handle any option it doesn't recognize.
protected  void processPostOptionCommandLine(java.util.Iterator<java.lang.String> it)
          Called by parseParams() once option parsing is complete, this method must handle any additional parameters on the command line.
protected  void runCommand()
          Run the curn tool.
 void runPostConfigPlugIn(CurnConfig config)
          Called after the entire configuration has been read and parsed, but before any feeds are processed.
 
Methods inherited from class org.clapper.util.cmdline.CommandLineUtility
execute, parseDoubleOptionArgument, parseDoubleOptionArgument, parseDoubleParameter, parseDoubleParameter, parseFloatOptionArgument, parseFloatOptionArgument, parseFloatParameter, parseFloatParameter, parseIntOptionArgument, parseIntOptionArgument, parseIntParameter, parseIntParameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)

getPlugInName

public java.lang.String getPlugInName()
Description copied from interface: PlugIn
Get a displayable name for the plug-in.

Specified by:
getPlugInName in interface PlugIn
Returns:
the name

getPlugInSortKey

public java.lang.String getPlugInSortKey()
Description copied from interface: PlugIn
Get the sort key for this plug-in.

Specified by:
getPlugInSortKey in interface PlugIn
Returns:
the sort key string.

initPlugIn

public void initPlugIn()
                throws CurnException
Description copied from interface: PlugIn
Initialize the plug-in. This method is called before any of the plug-in methods are called.

Specified by:
initPlugIn in interface PlugIn
Throws:
CurnException - on error

runPostConfigPlugIn

public void runPostConfigPlugIn(CurnConfig config)
                         throws CurnException
Description copied from interface: PostConfigPlugIn
Called after the entire configuration has been read and parsed, but before any feeds are processed. Intercepting this event is useful for plug-ins that want to adjust the configuration. For instance, the curn command-line wrapper intercepts this plug-in event so it can adjust the configuration to account for command line options.

Specified by:
runPostConfigPlugIn in interface PostConfigPlugIn
Parameters:
config - the parsed CurnConfig object
Throws:
CurnException - on error
See Also:
CurnConfig

parseCustomOption

protected void parseCustomOption(char shortOption,
                                 java.lang.String longOption,
                                 java.util.Iterator<java.lang.String> it)
                          throws org.clapper.util.cmdline.CommandLineUsageException,
                                 java.util.NoSuchElementException
Called by parseParams() to handle any option it doesn't recognize. If the option takes any parameters, the overridden method must extract the parameter by advancing the supplied Iterator (which returns String objects). This default method simply throws an exception.

Overrides:
parseCustomOption in class org.clapper.util.cmdline.CommandLineUtility
Parameters:
shortOption - the short option character, or UsageInfo.NO_SHORT_OPTION if there isn't one (i.e., if this is a long-only option).
longOption - the long option string, without any leading "-" characters, or null if this is a short-only option
it - the Iterator for the remainder of the command line, for extracting parameters.
Throws:
org.clapper.util.cmdline.CommandLineUsageException - on error
java.util.NoSuchElementException - overran the iterator (i.e., missing parameter)

processPostOptionCommandLine

protected void processPostOptionCommandLine(java.util.Iterator<java.lang.String> it)
                                     throws org.clapper.util.cmdline.CommandLineUsageException,
                                            java.util.NoSuchElementException

Called by parseParams() once option parsing is complete, this method must handle any additional parameters on the command line. It's not necessary for the method to ensure that the iterator has the right number of strings left in it. If you attempt to pull too many parameters from the iterator, it'll throw a NoSuchElementException, which parseParams() traps and converts into a suitable error message. Similarly, if there are any parameters left in the iterator when this method returns, parseParams() throws an exception indicating that there are too many parameters on the command line.

This method is called unconditionally, even if there are no parameters left on the command line, so it's a useful place to do post-option consistency checks, as well.

Overrides:
processPostOptionCommandLine in class org.clapper.util.cmdline.CommandLineUtility
Parameters:
it - the Iterator for the remainder of the command line
Throws:
org.clapper.util.cmdline.CommandLineUsageException - on error
java.util.NoSuchElementException - attempt to iterate past end of args; parseParams() automatically handles this exception, so it's safe for subclass implementations of this method not to handle it

getCustomUsageInfo

protected void getCustomUsageInfo(org.clapper.util.cmdline.UsageInfo info)
Called by parseParams() to get the custom command-line options and parameters handled by the subclass. This list is used solely to build a usage message. The overridden method must fill the supplied UsageInfo object: That information will be combined with the common options supported by the base class, and used to build a usage message.

Overrides:
getCustomUsageInfo in class org.clapper.util.cmdline.CommandLineUtility
Parameters:
info - The UsageInfo object to fill.

runCommand

protected void runCommand()
                   throws org.clapper.util.cmdline.CommandLineException
Run the curn tool. This method parses the command line arguments, storing the results in an internal configuration; then, it instantiates a Curn object and calls its run() method.

Specified by:
runCommand in class org.clapper.util.cmdline.CommandLineUtility
Throws:
org.clapper.util.cmdline.CommandLineException - error occurred


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