Logo Search packages:      
Sourcecode: jabref version File versions  Download package

gnu::dtools::ritopt::NotifyOption Class Reference

Inheritance diagram for gnu::dtools::ritopt::NotifyOption:

gnu::dtools::ritopt::Option gnu::dtools::ritopt::OptionNotifier gnu::dtools::ritopt::OptionModifiable

List of all members.


Detailed Description

The NotifyOption class is used to register options that when invoked notify a listener. This provides an interface for event-driven options processing. In order for a class to be notified, it must implement the OptionListener interface.

When the option is invoked, the corresponding short, long, and option values are put in an OptionEvent object, and passed to all registered listeners.

A class must implement the OptionListener interface in order to receive notification of option events.

For a more detailed explanation please refer to the tutorial. The following is a simple example of how a NotifyOption is used.

 import gnu.dtools.ritopt.*;

 public class TellMe implements OptionListener {

    public static void main( String args[] ) {
       TellMe m = new TellMe();
       Options processor = new Options();
       NotifyOption say = new NotifyOption( m );
       processor.register( "say", 's', say );
       processor.process();
    }

    public void optionInvoked( OptionEvent e ) {
       if ( e.getCommand().equals( "say" ) ) {
           String say = e.getValue();
           if ( Utility.trim( say ).length() == 0 ) say = "nothing";
           System.err.println( "You told me to say " + nothing + "." );
       }
    }
 }

 cookies$ javac TellMe.java
 cookies$ java TellMe
 cookies$ java TellMe
 cookies$ java TellMe --say -s
 You told me to say nothing.
 You told me to say nothing.
 cookies$ java TellMe --say hello
 You told me to say hello.
 cookies$ java TellMe --say "I'm sorry"
 You told me to say I'm sorry.
 cookies$ java TellMe --say="not until tomorrow" -s "I'm crazy"
 You told me to say not until tomorrow.
 You told me to say I'm crazy.
 


 Copyright (C) Damian Ryan Eads, 2001. All Rights Reserved.

 ritopt is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 ritopt is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with ritopt; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 

Author:
Damian Eads

Definition at line 79 of file NotifyOption.java.


Public Member Functions

void action ()
void addOptionListener (OptionListener listener)
void deprecate ()
String getDescription ()
String getHashKey ()
String getHelp ()
String getHelpDeprecated ()
String getHelpDescription ()
String getHelpOptionSpecification ()
String getHelpTypeName ()
String getLongOption ()
String getName ()
Object getObject ()
String getOptionFileLine ()
char getShortOption ()
String getStringValue ()
String getTypeName ()
String getValue ()
boolean isDeprecated ()
boolean isInvoked ()
void modify (String value) throws OptionModificationException
 NotifyOption (String value, String longOption, char shortOption)
 NotifyOption (String value, char shortOption)
 NotifyOption (String value, String longOption)
 NotifyOption (String value)
 NotifyOption (NotifyOption op)
 NotifyOption (OptionListener listener, String command, String value)
 NotifyOption (OptionListener listener, String command)
 NotifyOption (OptionListener listener)
 NotifyOption ()
void removeOptionListener (OptionListener listener)
void setDeprecated (boolean deprecated)
void setDescription (String description)
void setInvoked (boolean b)
void setKey (char shortOption)
void setKey (String longOption)
void setLongOption (String longOption)
void setOptionCommand (String command)
void setShortOption (char shortOption)
void setValue (String value) throws OptionModificationException
String toString ()

Static Public Member Functions

static int getFileCommentSize ()
static int getFileCompleteOptionSize ()
static String getHashKey (String longOption, char shortOption)
static String getHashKey (char shortOption)
static String getHashKey (String longOption)
static int getHelpDeprecatedSize ()
static int getHelpDescriptionSize ()
static String getHelpHeader ()
static int getHelpOptionSpecificationSize ()
static int getHelpTypenameSize ()
static int getMenuDeprecatedSize ()
static int getMenuDescriptionSize ()
static int getMenuOptionSpecificationSize ()
static int getMenuTypenameSize ()
static void setFileCommentSize (int newSize)
static void setFileCompleteOptionSize (int newSize)
static void setHelpDeprecatedSize (int newSize)
static void setHelpDescriptionSize (int newSize)
static void setHelpOptionSpecificationSize (int newSize)
static void setHelpTypenameSize (int newSize)
static void setMenuDeprecatedSize (int newSize)
static void setMenuDescriptionSize (int newSize)
static void setMenuOptionSpecificationSize (int newSize)
static void setMenuTypenameSize (int newSize)

Static Public Attributes

static final int DEFAULT_FILE_COMMENT_SIZE = 16
static final int DEFAULT_FILE_COMPLETE_OPTION_SIZE = 60
static final int DEFAULT_HELP_DEPRECATED_SIZE = 3
static final int DEFAULT_HELP_DESCRIPTION_SIZE = 48
static final int DEFAULT_HELP_OPTION_SIZE = 22
static final int DEFAULT_HELP_TYPENAME_SIZE = 10
static final int DEFAULT_MENU_DEPRECATED_SIZE = 3
static final int DEFAULT_MENU_DESCRIPTION_SIZE = 48
static final int DEFAULT_MENU_OPTION_SIZE = 15
static final int DEFAULT_MENU_TYPENAME_SIZE = 10

Protected Attributes

boolean invoked

Private Attributes

String command = "Default"
java.util.List< OptionListenerlisteners
String value = ""

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index