/*
* JFLAP - Formal Languages and Automata Package
*
*
* Susan H. Rodger
* Computer Science Department
* Duke University
* August 27, 2009
* Copyright (c) 2002-2009
* All rights reserved.
* JFLAP is open source software. Please see the LICENSE for terms.
*
*/
package gui.action;
import gui.environment.RegularEnvironment;
import javax.swing.Icon;
import regular.RegularExpression;
/**
* The RegularAction
is the general action that various
* controllers for operators on regular expressions should subclass. The only
* real change from the RestrictedAction
is that by default the
* .isAcceptable
method now only returns true if the object is an
* instance of RegularExpression
.
*
* @author Thomas Finley
*/
public abstract class RegularAction extends RestrictedAction {
/**
* Instantiates a new RegularAction
.
*
* @param string
* a string description
* @param icon
* the optional icon, or null
if there is to be no
* icon associated with this action
* @param environment
*/
public RegularAction(String string, Icon icon,
RegularEnvironment environment) {
super(string, icon);
this.environment = environment;
}
/**
* Given an object, determine if this automaton action is able to be applied
* to that object based on its class. By default, this method returns true
* if this object is an instance of Automaton
.
*
* @param object
* the object to test for "applicability"
* @return true
if this action should be available to an
* object of this type, false
otherwise.
*/
public static boolean isApplicable(Object object) {
return object instanceof RegularExpression;
}
/**
* Returns the environment associated with this action
*
* @return the environment for this action
*/
protected RegularEnvironment getEnvironment() {
return environment;
}
/**
* Returns expression for this action's environment.
*
* @return the expression for this action's environment
*/
protected RegularExpression getExpression() {
return environment.getExpression();
}
/** The environment associated with this action. */
private RegularEnvironment environment;
}