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.ResourceBundlerbx
-
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.Stringdescription(boolean triggerType)Get an I18N description of the ConditionAction.voiddispose()Dispose this ConditionalAction.booleanequals(java.lang.Object obj)intgetActionData()Integer data for action.java.lang.StringgetActionDataString()Get an I18N String to represent the Action Data.static java.lang.StringgetActionDataString(Conditional.Action t, int data)Get the Action Data String in I18N form.java.lang.StringgetActionString()String data for action.NamedBeangetBean()java.lang.StringgetDeviceName()Name of the device or element that is affected.java.awt.event.ActionListenergetListener()NamedBeanHandle<?>getNamedBean()intgetOption()Options on when action is taken.java.lang.StringgetOptionString(boolean type)Get the Option String in I18N format.static java.lang.StringgetOptionString(int opt, boolean type)Convert consequent option to I18N String.SoundgetSound()Get Sound file.javax.swing.TimergetTimer()Conditional.ActiongetType()The consequent device or element type.java.lang.StringgetTypeString()inthashCode()booleanisTimerActive()voidsetActionData(int actionData)voidsetActionData(java.lang.String actionData)Set action data from I18N name for it.voidsetActionString(java.lang.String actionString)Set the Action String.voidsetDeviceName(java.lang.String deviceName)voidsetListener(java.awt.event.ActionListener listener)voidsetOption(int option)Set the Action Option.protected voidsetSound(Sound sound)Set the sound file.voidsetTimer(javax.swing.Timer timer)voidsetType(java.lang.String type)Set type from user name for it.voidsetType(Conditional.Action type)voidstartTimer()voidstopTimer()static intstringToActionData(java.lang.String str)Get action Data from an I18N String.static Conditional.ActionstringToActionType(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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getType
@Nonnull public Conditional.Action getType()
The consequent device or element type.- Specified by:
getTypein interfaceConditionalAction- Returns:
- the type
-
setType
public void setType(@Nonnull Conditional.Action type)
- Specified by:
setTypein interfaceConditionalAction
-
setType
public void setType(java.lang.String type)
Set type from user name for it.- Specified by:
setTypein interfaceConditionalAction- Parameters:
type- name of the type
-
getDeviceName
public java.lang.String getDeviceName()
Name of the device or element that is affected.- Specified by:
getDeviceNamein interfaceConditionalAction- Returns:
- the name
-
setDeviceName
public void setDeviceName(java.lang.String deviceName)
- Specified by:
setDeviceNamein interfaceConditionalAction
-
getNamedBean
@CheckForNull public NamedBeanHandle<?> getNamedBean()
- Specified by:
getNamedBeanin interfaceConditionalAction
-
getBean
@CheckForNull public NamedBean getBean()
- Specified by:
getBeanin interfaceConditionalAction
-
getOption
public int getOption()
Options on when action is taken.- Specified by:
getOptionin interfaceConditionalAction- Returns:
- the option
-
setOption
public void setOption(int option)
Description copied from interface:ConditionalActionSet the Action Option.- Specified by:
setOptionin interfaceConditionalAction- Parameters:
option- the action option number.
-
getActionData
public int getActionData()
Integer data for action.- Specified by:
getActionDatain interfaceConditionalAction- Returns:
- the data
-
setActionData
public void setActionData(int actionData)
- Specified by:
setActionDatain interfaceConditionalAction
-
setActionData
public void setActionData(java.lang.String actionData)
Set action data from I18N name for it.- Specified by:
setActionDatain interfaceConditionalAction- Parameters:
actionData- user name
-
getActionString
@Nonnull public java.lang.String getActionString()
String data for action.- Specified by:
getActionStringin interfaceConditionalAction- Returns:
- the action String
-
setActionString
public void setActionString(java.lang.String actionString)
Description copied from interface:ConditionalActionSet the Action String. Any String float values ( delayed Sensor ) should use a . decimal separator.- Specified by:
setActionStringin interfaceConditionalAction- Parameters:
actionString- the action String.
-
getTimer
@CheckForNull public javax.swing.Timer getTimer()
- Specified by:
getTimerin interfaceConditionalAction
-
setTimer
public void setTimer(javax.swing.Timer timer)
- Specified by:
setTimerin interfaceConditionalAction
-
isTimerActive
public boolean isTimerActive()
- Specified by:
isTimerActivein interfaceConditionalAction
-
startTimer
public void startTimer()
- Specified by:
startTimerin interfaceConditionalAction
-
stopTimer
public void stopTimer()
- Specified by:
stopTimerin interfaceConditionalAction
-
getListener
@CheckForNull public java.awt.event.ActionListener getListener()
- Specified by:
getListenerin interfaceConditionalAction
-
setListener
public void setListener(java.awt.event.ActionListener listener)
- Specified by:
setListenerin interfaceConditionalAction
-
getSound
@CheckForNull public Sound getSound()
Get Sound file.- Specified by:
getSoundin 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:
getTypeStringin interfaceConditionalAction- Returns:
- name of this consequent type
-
getOptionString
@Nonnull public java.lang.String getOptionString(boolean type)
Description copied from interface:ConditionalActionGet the Option String in I18N format.- Specified by:
getOptionStringin 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:ConditionalActionGet an I18N String to represent the Action Data.- Specified by:
getActionDataStringin 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:
descriptionin 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:
disposein interfaceConditionalAction
-
-