Package jmri.implementation
Class DefaultConditionalAction
- java.lang.Object
-
- jmri.implementation.DefaultConditionalAction
-
- All Implemented Interfaces:
ConditionalAction
public class DefaultConditionalAction extends java.lang.Object implements ConditionalAction
The consequent of the antecedent of the conditional proposition. The data for the action to be taken when a Conditional calculates to TrueThis is in the implementations package because of a Swing dependence via the times. Java 1.5 or Java 1.6 might make it possible to break that, which will simplify things.
-
-
Field Summary
Fields Modifier and Type Field Description protected NamedBeanHandleManager
nbhm
(package private) static java.util.ResourceBundle
rbx
-
Constructor Summary
Constructors Constructor Description DefaultConditionalAction()
DefaultConditionalAction(int option, Conditional.Action type, java.lang.String name, int actionData, java.lang.String actionStr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
description(boolean triggerType)
void
dispose()
Dispose this ConditionalAction.boolean
equals(java.lang.Object obj)
int
getActionData()
Integer data for action.java.lang.String
getActionDataString()
static java.lang.String
getActionDataString(Conditional.Action t, int data)
java.lang.String
getActionString()
String data for action.NamedBean
getBean()
java.lang.String
getDeviceName()
Name of the device or element that is affected.java.awt.event.ActionListener
getListener()
NamedBeanHandle<?>
getNamedBean()
int
getOption()
Options on when action is taken.java.lang.String
getOptionString(boolean type)
static java.lang.String
getOptionString(int opt, boolean type)
Convert consequent option to String.Sound
getSound()
Get Sound file.javax.swing.Timer
getTimer()
Conditional.Action
getType()
The consequent device or element type.java.lang.String
getTypeString()
int
hashCode()
boolean
isTimerActive()
void
setActionData(int actionData)
void
setActionData(java.lang.String actionData)
Set action data from user name for it.void
setActionString(java.lang.String actionString)
void
setDeviceName(java.lang.String deviceName)
void
setListener(java.awt.event.ActionListener listener)
void
setOption(int option)
protected void
setSound(Sound sound)
Set the sound file.void
setTimer(javax.swing.Timer timer)
void
setType(java.lang.String type)
Set type from user name for it.void
setType(Conditional.Action type)
void
startTimer()
void
stopTimer()
static int
stringToActionData(java.lang.String str)
Get action Data from a String.static Conditional.Action
stringToActionType(java.lang.String str)
Get action type from a String.
-
-
-
Field Detail
-
rbx
static final java.util.ResourceBundle rbx
-
nbhm
protected NamedBeanHandleManager nbhm
-
-
Constructor Detail
-
DefaultConditionalAction
public DefaultConditionalAction()
-
DefaultConditionalAction
public DefaultConditionalAction(int option, Conditional.Action type, java.lang.String name, int actionData, java.lang.String actionStr)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getType
public Conditional.Action getType()
The consequent device or element type.- Specified by:
getType
in interfaceConditionalAction
- Returns:
- the type
-
setType
public void setType(Conditional.Action type)
- Specified by:
setType
in interfaceConditionalAction
-
setType
public void setType(java.lang.String type)
Set type from user name for it.- Specified by:
setType
in interfaceConditionalAction
- Parameters:
type
- name of the type
-
getDeviceName
public java.lang.String getDeviceName()
Name of the device or element that is affected.- Specified by:
getDeviceName
in interfaceConditionalAction
- Returns:
- the name
-
setDeviceName
public void setDeviceName(java.lang.String deviceName)
- Specified by:
setDeviceName
in interfaceConditionalAction
-
getNamedBean
public NamedBeanHandle<?> getNamedBean()
- Specified by:
getNamedBean
in interfaceConditionalAction
-
getBean
public NamedBean getBean()
- Specified by:
getBean
in interfaceConditionalAction
-
getOption
public int getOption()
Options on when action is taken.- Specified by:
getOption
in interfaceConditionalAction
- Returns:
- the option
-
setOption
public void setOption(int option)
- Specified by:
setOption
in interfaceConditionalAction
-
getActionData
public int getActionData()
Integer data for action.- Specified by:
getActionData
in interfaceConditionalAction
- Returns:
- the data
-
setActionData
public void setActionData(int actionData)
- Specified by:
setActionData
in interfaceConditionalAction
-
setActionData
public void setActionData(java.lang.String actionData)
Set action data from user name for it.- Specified by:
setActionData
in interfaceConditionalAction
- Parameters:
actionData
- user name
-
getActionString
public java.lang.String getActionString()
String data for action.- Specified by:
getActionString
in interfaceConditionalAction
- Returns:
- the action String
-
setActionString
public void setActionString(java.lang.String actionString)
- Specified by:
setActionString
in interfaceConditionalAction
-
getTimer
public javax.swing.Timer getTimer()
- Specified by:
getTimer
in interfaceConditionalAction
-
setTimer
public void setTimer(javax.swing.Timer timer)
- Specified by:
setTimer
in interfaceConditionalAction
-
isTimerActive
public boolean isTimerActive()
- Specified by:
isTimerActive
in interfaceConditionalAction
-
startTimer
public void startTimer()
- Specified by:
startTimer
in interfaceConditionalAction
-
stopTimer
public void stopTimer()
- Specified by:
stopTimer
in interfaceConditionalAction
-
getListener
public java.awt.event.ActionListener getListener()
- Specified by:
getListener
in interfaceConditionalAction
-
setListener
public void setListener(java.awt.event.ActionListener listener)
- Specified by:
setListener
in interfaceConditionalAction
-
getSound
public Sound getSound()
Get Sound file.- Specified by:
getSound
in interfaceConditionalAction
- Returns:
- the sound
-
setSound
protected void setSound(Sound sound)
Set the sound file.- Parameters:
sound
- the new sound file
-
getTypeString
public java.lang.String getTypeString()
- Specified by:
getTypeString
in interfaceConditionalAction
- Returns:
- name of this consequent type
-
getOptionString
public java.lang.String getOptionString(boolean type)
- Specified by:
getOptionString
in interfaceConditionalAction
- Parameters:
type
- the type- Returns:
- name of the option for this consequent type
-
getActionDataString
public java.lang.String getActionDataString()
- Specified by:
getActionDataString
in interfaceConditionalAction
-
getOptionString
public static java.lang.String getOptionString(int opt, boolean type)
Convert consequent option to String.- Parameters:
opt
- the optiontype
- true if option is a change; false if option is a trigger- Returns:
- a human readable description of the option or an empty String
-
stringToActionType
public static Conditional.Action stringToActionType(java.lang.String str)
Get action type from a String.- Parameters:
str
- the string to get the type for- Returns:
- the type or 0 if str is not a recognized action
-
stringToActionData
public static int stringToActionData(java.lang.String str)
Get action Data from a String.- Parameters:
str
- the string to get the action data for- Returns:
- the action data of -1 is str is not recognized
-
getActionDataString
public static java.lang.String getActionDataString(Conditional.Action t, int data)
-
description
public java.lang.String description(boolean triggerType)
- Specified by:
description
in interfaceConditionalAction
-
dispose
public void dispose()
Dispose this ConditionalAction.- Specified by:
dispose
in interfaceConditionalAction
-
-