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 (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)
Get an I18N description of the ConditionAction.void
dispose()
Dispose this ConditionalAction.boolean
equals(java.lang.Object obj)
int
getActionData()
Integer data for action.java.lang.String
getActionDataString()
Get an I18N String to represent the Action Data.static java.lang.String
getActionDataString(Conditional.Action t, int data)
Get the Action Data String in I18N form.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)
Get the Option String in I18N format.static java.lang.String
getOptionString(int opt, boolean type)
Convert consequent option to I18N 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 I18N name for it.void
setActionString(java.lang.String actionString)
Set the Action String.void
setDeviceName(java.lang.String deviceName)
void
setListener(java.awt.event.ActionListener listener)
void
setOption(int option)
Set the Action 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 an I18N String.static Conditional.Action
stringToActionType(java.lang.String str)
Get action type from a String.
-
-
-
Field Detail
-
rbx
static final java.util.ResourceBundle rbx
-
-
Constructor Detail
-
DefaultConditionalAction
public DefaultConditionalAction()
-
DefaultConditionalAction
public DefaultConditionalAction(int option, @Nonnull 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
@Nonnull public Conditional.Action getType()
The consequent device or element type.- Specified by:
getType
in interfaceConditionalAction
- Returns:
- the type
-
setType
public void setType(@Nonnull 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
@CheckForNull public NamedBeanHandle<?> getNamedBean()
- Specified by:
getNamedBean
in interfaceConditionalAction
-
getBean
@CheckForNull 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)
Description copied from interface:ConditionalAction
Set the Action Option.- Specified by:
setOption
in interfaceConditionalAction
- Parameters:
option
- the action option number.
-
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 I18N name for it.- Specified by:
setActionData
in interfaceConditionalAction
- Parameters:
actionData
- user name
-
getActionString
@Nonnull 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)
Description copied from interface:ConditionalAction
Set the Action String. Any String float values ( delayed Sensor ) should use a . decimal separator.- Specified by:
setActionString
in interfaceConditionalAction
- Parameters:
actionString
- the action String.
-
getTimer
@CheckForNull 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
@CheckForNull 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
@CheckForNull 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
@Nonnull public java.lang.String getTypeString()
- Specified by:
getTypeString
in interfaceConditionalAction
- Returns:
- name of this consequent type
-
getOptionString
@Nonnull public java.lang.String getOptionString(boolean type)
Description copied from interface:ConditionalAction
Get the Option String in I18N format.- Specified by:
getOptionString
in interfaceConditionalAction
- Parameters:
type
- true if option is a change; false if option is a trigger.- Returns:
- name of the option for this consequent type
-
getActionDataString
@Nonnull public java.lang.String getActionDataString()
Description copied from interface:ConditionalAction
Get an I18N String to represent the Action Data.- Specified by:
getActionDataString
in interfaceConditionalAction
- Returns:
- human readable String of the data.
-
getOptionString
@Nonnull public static java.lang.String getOptionString(int opt, boolean type)
Convert consequent option to I18N String.- Parameters:
opt
- the option.type
- 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
@Nonnull public static Conditional.Action stringToActionType(@CheckForNull 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(@Nonnull java.lang.String str)
Get action Data from an I18N String.- Parameters:
str
- the I18N string to get the action data for.- Returns:
- the action data of -1 is str is not recognized.
-
getActionDataString
@Nonnull public static java.lang.String getActionDataString(@Nonnull Conditional.Action t, int data)
Get the Action Data String in I18N form.- Parameters:
t
- the Condition.Action, must be null.data
- the constant for the action command type.- Returns:
- the action / data string.
-
description
@Nonnull public java.lang.String description(boolean triggerType)
Get an I18N description of the ConditionAction.- Specified by:
description
in interfaceConditionalAction
- Parameters:
triggerType
- true if option is a change; false if option is a trigger.- Returns:
- human readable description.
-
dispose
public void dispose()
Dispose this ConditionalAction.- Specified by:
dispose
in interfaceConditionalAction
-
-