Package gnu.dtools.ritopt
Class OptionEvent
- java.lang.Object
-
- gnu.dtools.ritopt.OptionEvent
-
public class OptionEvent extends java.lang.Object
An event indicating that an option has been invoked. When an OptionListener is notified by a NotifyOption, it passes an OptionEvent object to all registered listeners. This includes the target NotifyOption, a command (NotifyOption passes the long option by default), and the option value.
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
-
-
Constructor Summary
Constructors Constructor Description OptionEvent()
Constructs an option event with the command set to "Default", the value set to the empty string, and the target set to null.OptionEvent(Option option)
Constructs an option event with the command set to the long or short option (whichever exists), the value set to the current value of the option, and the target option set to the option passed.OptionEvent(java.lang.String command)
Constructs an option event with the command set to the value passed, the value set to the empty string, and the target set to null.OptionEvent(java.lang.String command, java.lang.String value)
Constructs an option event with the command and value set to the values passed, and the target set to null.OptionEvent(java.lang.String command, java.lang.String value, Option target)
Constructs an option event with the command, value, and target set to the values passed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getCommand()
Returns the command string associated with the option.Option
getTarget()
Returns the target option of the option processing event.java.lang.String
getValue()
Returns the value associated with the target option.void
setCommand(java.lang.String command)
Sets the command string to the value passed.void
setTarget(Option target)
Sets the target option of the option processing event.void
setValue(java.lang.String value)
Sets the value of this option event.
-
-
-
Constructor Detail
-
OptionEvent
public OptionEvent()
Constructs an option event with the command set to "Default", the value set to the empty string, and the target set to null.
-
OptionEvent
public OptionEvent(java.lang.String command)
Constructs an option event with the command set to the value passed, the value set to the empty string, and the target set to null.- Parameters:
command
- The value to set the command string.
-
OptionEvent
public OptionEvent(java.lang.String command, java.lang.String value)
Constructs an option event with the command and value set to the values passed, and the target set to null.- Parameters:
command
- The value to set the command string.value
- The value to set the option value.
-
OptionEvent
public OptionEvent(Option option)
Constructs an option event with the command set to the long or short option (whichever exists), the value set to the current value of the option, and the target option set to the option passed. If neither the short or long option exist, a value of "Default" is assigned.- Parameters:
option
- The option to initialize this OptionEvent.
-
OptionEvent
public OptionEvent(java.lang.String command, java.lang.String value, Option target)
Constructs an option event with the command, value, and target set to the values passed.- Parameters:
command
- The value to set the command string.value
- The value to set the option value.target
- The target option in which the option processing event occurred.
-
-
Method Detail
-
getCommand
public java.lang.String getCommand()
Returns the command string associated with the option.- Returns:
- The command string associated with the option.
-
getValue
public java.lang.String getValue()
Returns the value associated with the target option.- Returns:
- The value associated with the target option.
-
getTarget
public Option getTarget()
Returns the target option of the option processing event.- Returns:
- The target option.
-
setCommand
public void setCommand(java.lang.String command)
Sets the command string to the value passed.- Parameters:
command
- The value to set the command string.
-
setValue
public void setValue(java.lang.String value)
Sets the value of this option event. This value generally should be equal to the value of the target option.- Parameters:
value
- The value of the option event.
-
setTarget
public void setTarget(Option target)
Sets the target option of the option processing event.- Parameters:
target
- The target option.
-
-