| java.lang.Object com.jcorporate.expresso.core.controller.State
All known Subclasses: com.jcorporate.expresso.services.controller.dbmaint.DynamicCmd, com.jcorporate.expresso.services.controller.configuration.ConfigurationBase,
State | public class State implements Cloneable,Serializable(Code) | | A State embodies a single state in the finite state machine of a
Controller object. Transitioning to a new state causes a Controller
to generate a set of Input, Output and Action objects. In order
to transition to a new state a controller can require that certain
parameters be supplied
A state is not inherantly threadsafe. The framework clones the
state and hands it off to the multithreaded controller with each state
invocation.
|
Field Summary | |
final public static String | NOTEMPTY_MASK Regular expression to check for at least one character, including newline
(?s) puts the expressoion in single-line mode so that . | protected boolean | secure |
Constructor Summary | |
public | State() The no-args constructor is not normally used directly, but only
by the mechanism that runs the states in order to invoke a state
dynamically. | public | State(String newName, String newDescrip) Convenience constructor to allow us to specify
a new state with a name and description. |
Method Summary | |
protected void | add(ControllerElement t) | protected void | addAutoInput(String fieldName, String friendlyName, String defaultValue, int displayLength, int maxLength, Vector validValues) addAutoInput is a convenience method that creates a new Input object based on
the specified field parameters and adds the input object to this
controller object. | protected void | addAutoInput(String fieldName, String dbClassName, String defaultValue) addAutoInput is a convenience method that creates a new Input object based on
the specified field parameters and adds the input object to this
controller object. | protected void | addAutoInput(String fieldName, String friendlyName, String dbClassName, String defaultValue) addAutoInput is a convenience method that creates a new Input object based on
the specified field parameters and adds the input object to this
controller object. | protected void | addBlock(Block newBlock) Adds a block to the controller response associated with this state. | public void | addError(String newError) | protected void | addInput(Input newInput) | public void | addOptionalParameter(String newParam) | protected void | addOutput(Output newOutput) | public void | addParameter(String newParam, String mask) | public void | addParameter(String newParam, boolean required, String mask) | public void | addParameter(String newParam, boolean required, String mask, String maskError) | public void | addRequiredParameter(String newParam) | public void | addTransition(Transition newTransition) Adds a transition to the controller response associated with a state. | protected void | autoValidate(String checkClassName, ErrorCollection errorCollection) AutoValidate is a quick way to validate the fields of a specified dbobj. | protected void | autoValidate(String checkClassName, ErrorCollection errorCollection, Vector requiredFields) AutoValidate is a quick way to validate the fields of a specified dbobj. | protected void | calculateHandlerName(String stateName) Calculates the appropriate method name based upon the name of the state
to be used in setName. | protected void | checkMask(String paramName, String paramValue, Pattern compiledRegExp) Checks a parameter given to the controller against a defined regular
expression mask. | public void | checkParamMasks() If any parameters for this state have an associated regular
expression "mask", verify that the value for the parameter
matches the mask. | protected void | clearFormCache() | public Object | clone() | public boolean | equals(Object o) Overrides default Object.equals(Object) behavior
Parameters: o - The object to compare against. | protected String | getAttribute(String attrib) | public Controller | getController() | protected ControllerRequest | getControllerRequest() Gets the ControllerRequest object associated with this state. | protected ControllerResponse | getControllerResponse() | protected DBController | getDBController() A convenience method that allows you to get a secured controller
which is a subclass of a regular controller. | public String | getDBName() | public String | getDataContext() | public String | getDescription() Get the description of this state, as supplied when the
state is created. | public String | getErrorState() | public Transition | getErrorTransition() Return the error transition. | public ErrorCollection | getErrors() Returns the errors collection of this current request and current state. | protected String | getFileName(String paramName) If a particular parameter represents an uploaded file (which can be determined
by the isFileParameter(String) method) then this method retrieves the server-side
file name - e.g. | protected String | getFormCache(String fieldName) | public String | getHandlerName() Return the name of the method that will handle transitions to this
state. | public String | getInitParameter(String paramName) | public String | getName() Get the name of this state. | public Object | getObjectParameter(String paramName) | public Vector | getOptionalParameters() | public List | getOptionalParametersList() Returns a list of optional parameters. | public String | getParameter(String paramCode) Fetch the value for the given parameter. | public Vector | getParameters() | protected PatternMatcher | getPatternMatcher() Retrieve a thread local instance of the Perl5 pattern matcher. | public List | getRequiredParametersList() | public ControllerResponse | getResponse() | public Transition | getReturnToSender() Return the return-to-sender transition. | public PersistentSession | getSession() | public String | getStateFormClass() Return the class name (if any) of the state form associated with
this state. | protected String | getString(String key, Object[] args) Convenience method - simply passes the request for a string on to
the ControllerResponse object associated with this State
Parameters: key - The key to format Parameters: args - The formatting arguments for the key. | protected String | getString(String key) | public Transition | getSuccessTransition() Return the success transition. | protected int | getUid() Retrieve the State user ID. | public String | getUser() | public int | hashCode() Returns a hash code value for the object. | public boolean | isFileParameter(String paramName) Does a specified parameter refer to an uploaded file?
Parameters: paramName - The parameter name to check. | protected boolean | isParameter(String paramName) | public boolean | isSecure() | public void | perform(StateForm stateForm, ControllerRequest newRequest, ControllerResponse newResponse) A state may implement a "perform" method to actually perform it's
logic by overriding this method. | public void | run(ControllerRequest newRequest, ControllerResponse newResponse) A state may implement a "run" method to actually perform it's
logic by overriding this method. | protected void | saveErrors(ErrorCollection e) | public void | setController(Controller newController) | public void | setDescription(String newDescrip) Set a description (human-readable) for this state. | public synchronized void | setErrorState(String newErrorState) Sets the state that defines the error state. | public void | setErrorTransition(Transition newErrorTransition) Set the error transition. | protected void | setFormCache() | public void | setHandlerName(String newName) | public synchronized void | setMask(String paramName, String mask) Set a regular expression "mask" for a particular parameter
The parameter value is checked against this mask before the
transition into the new state begins Also precompiles the regular
expression to allow for quick parameter checking. | public synchronized void | setMask(String paramName, String mask, String errorMsg) | public void | setMaskError(String paramName, String errorMsg) If a state fails a parameter check on a mask, then the error specified will
be stored in the error collections
Parameters: paramName - The parameter name to check against the regular expressionset in setMask Parameters: errorMsg - The error message to display. | public void | setName(String newName) Set the internal "name" of this state. | protected void | setResponse(ControllerResponse res) | public void | setReturnToSender(Transition newReturnToSender) Set the return-to-sender transition. | public void | setSecure(boolean newSecure) Sets the "should be secure" flag. | public void | setStateFormClass(String newStateFormClass) Set the class name of the state form associated with this state. | public void | setSuccessTransition(Transition newSuccessTransition) Set the success transition. | public String | toString() Returns the string of this state. | protected void | transition(String newState, ControllerRequest req, ControllerResponse res) |
NOTEMPTY_MASK | final public static String NOTEMPTY_MASK(Code) | | Regular expression to check for at least one character, including newline
(?s) puts the expressoion in single-line mode so that . (a period) will match newlines
|
secure | protected boolean secure(Code) | | Is this state to run within an SSL setting?
|
State | public State()(Code) | | The no-args constructor is not normally used directly, but only
by the mechanism that runs the states in order to invoke a state
dynamically. Use the detailed constructor instead.
|
State | public State(String newName, String newDescrip)(Code) | | Convenience constructor to allow us to specify
a new state with a name and description. This is the preferred
constructor for a controller, and is used within the constructor
of a Controller to define the states that this controller
has available to it.
Parameters: newName - The name of the new state Parameters: newDescrip - A description for the new state - this may be(preferrably) a key into the local language file in order to facilitateinternationalization, or just a simple string. |
add | protected void add(ControllerElement t) throws ControllerException(Code) | | Convenience method to allow us to add any ControllerElement to this
controllers inputs, outputs or transitions
Parameters: t - The controller element, either an input an output, a transition,or a block that gets added to the controller response. throws: ControllerException - upon error |
addAutoInput | protected void addAutoInput(String fieldName, String friendlyName, String defaultValue, int displayLength, int maxLength, Vector validValues) throws ControllerException(Code) | | addAutoInput is a convenience method that creates a new Input object based on
the specified field parameters and adds the input object to this
controller object.
Creation date: (7/20/00 3:43:14 PM)
author: Adam Rossi, PlatinumSolutions
Parameters: fieldName - java.lang.String Parameters: friendlyName - the input's label Parameters: defaultValue - java.lang.String Parameters: displayLength - The size of the input text box Parameters: maxLength - The maximum input length of the input. Parameters: validValues - The valid value list associated with the input(for drop-down multivalue inputs only) throws: ControllerException - upon error |
addAutoInput | protected void addAutoInput(String fieldName, String dbClassName, String defaultValue) throws ControllerException(Code) | | addAutoInput is a convenience method that creates a new Input object based on
the specified field parameters and adds the input object to this
controller object.
Creation date: (7/20/00 3:43:14 PM)
author: Adam Rossi, PlatinumSolutions
Parameters: fieldName - java.lang.String Parameters: dbClassName - java.lang.String Parameters: defaultValue - java.lang.String throws: ControllerException - upon error |
addAutoInput | protected void addAutoInput(String fieldName, String friendlyName, String dbClassName, String defaultValue) throws ControllerException(Code) | | addAutoInput is a convenience method that creates a new Input object based on
the specified field parameters and adds the input object to this
controller object.
Creation date: (7/20/00 3:43:14 PM)
author: Adam Rossi, PlatinumSolutions
Parameters: fieldName - java.lang.String Parameters: friendlyName - The label of the new input Parameters: dbClassName - java.lang.String Parameters: defaultValue - java.lang.String throws: ControllerException - upon error |
addOptionalParameter | public void addOptionalParameter(String newParam)(Code) | | Add a required parameter to this state
Parameters: newParam - The name of the new parameter |
addParameter | public void addParameter(String newParam, String mask)(Code) | | Add a new parameter to this state
Parameters: newParam - The name of the new parameter Parameters: mask - The regular expression mask to compare against. |
addParameter | public void addParameter(String newParam, boolean required, String mask)(Code) | | Add a new parameter to this state
Parameters: newParam - The name of the new parameter Parameters: required - should an exception be thrown if this parameter isn't included? Parameters: mask - The regular expression mask to compare against. |
addParameter | public void addParameter(String newParam, boolean required, String mask, String maskError)(Code) | | Add a new parameter to this state
Parameters: newParam - The name of the new parameter Parameters: required - should an exception be thrown if this parameter isn't included? Parameters: mask - The regular expression mask to compare against. Parameters: maskError - The error message to give if mask validation fails. |
addRequiredParameter | public void addRequiredParameter(String newParam)(Code) | | Add a required parameter to this state
Parameters: newParam - The name of the new parameter |
autoValidate | protected void autoValidate(String checkClassName, ErrorCollection errorCollection, Vector requiredFields) throws ValidationException, ControllerException(Code) | | AutoValidate is a quick way to validate the fields of a specified dbobj.
This method has not been tested and may not be correct.
This methods takes an optional requiredFields vector, which just tells the
validation routine which inputs are required.
Creation date: (7/19/00 6:06:21 PM)
author: Adam Rossi, PlatinumSolutions
Parameters: checkClassName - The class name to perform the error checking Parameters: errorCollection - The error collection to get populated with validation errorsif validation on any particular field fails. Parameters: requiredFields - Vector of Strings: which inputs are required. throws: com.jcorporate.expresso.core.controller.ValidationException - Upon validation error throws: ControllerException - upon error |
calculateHandlerName | protected void calculateHandlerName(String stateName)(Code) | | Calculates the appropriate method name based upon the name of the state
to be used in setName. and sets the handlerName String to that value.
Parameters: stateName - The name of the state to calculate the handler name. |
checkMask | protected void checkMask(String paramName, String paramValue, Pattern compiledRegExp) throws ControllerException(Code) | | Checks a parameter given to the controller against a defined regular
expression mask. Puts an error in the error collection if there is
a problem.
Parameters: paramName - The state parameter name to check Parameters: paramValue - The value given the state to check against Parameters: compiledRegExp - The compiled Perl 5 regular expression. throws: ControllerException - if there's an error with the regular expressionmask. |
checkParamMasks | public void checkParamMasks() throws ControllerException(Code) | | If any parameters for this state have an associated regular
expression "mask", verify that the value for the parameter
matches the mask.
throws: ControllerException - upon error |
equals | public boolean equals(Object o)(Code) | | Overrides default Object.equals(Object) behavior
Parameters: o - The object to compare against. true if the objects are equal |
getAttribute | protected String getAttribute(String attrib)(Code) | | get attribute from request
Parameters: attrib - The name of an "attribute" for this ControllerElement item java.lang.String The attribute value |
getControllerRequest | protected ControllerRequest getControllerRequest()(Code) | | Gets the ControllerRequest object associated with this state.
the ControllerRequest Object associated with this state. |
getControllerResponse | protected ControllerResponse getControllerResponse()(Code) | | Retrieves the ControllerResponse object associated with this state
ControllerResponse object associated with this state. |
getDBController | protected DBController getDBController() throws ControllerException(Code) | | A convenience method that allows you to get a secured controller
which is a subclass of a regular controller.
DBController instance throws: ControllerException - if the controller is not an instance ofDBController. |
getDBName | public String getDBName()(Code) | | Return the name of the database connection we use - or null
for the default connection
java.lang.String |
getDataContext | public String getDataContext()(Code) | | Return the name of the database connection we use - or null
for the default connection
java.lang.String |
getDescription | public String getDescription()(Code) | | Get the description of this state, as supplied when the
state is created. Try to use the description as a key
in the current local-language file - if available. If we can't
do that, or it's not a valid key, just return the description as
it was originally specified.
A description of this state |
getErrorState | public String getErrorState()(Code) | | Retrieves the state that has been set as the error state
java.lang.String |
getErrorTransition | public Transition getErrorTransition()(Code) | | Return the error transition. This is the transition that will be
executed if this state returns any errors in the error collection.
The Error Transition |
getFileName | protected String getFileName(String paramName)(Code) | | If a particular parameter represents an uploaded file (which can be determined
by the isFileParameter(String) method) then this method retrieves the server-side
file name - e.g. the location that has the data that was uploaded stored in it.
Parameters: paramName - The parameter name that is expected to have a file associated with. java.lang.String the location on the filesystem of the temporary storedfile. |
getHandlerName | public String getHandlerName()(Code) | | Return the name of the method that will handle transitions to this
state.
the handler name, or possibly null if the |
getInitParameter | public String getInitParameter(String paramName)(Code) | | ?
Parameters: paramName - The parameter name to retrieve java.lang.String |
getName | public String getName()(Code) | | Get the name of this state. This is the "internal" name used
to refer to the state, not the "human readable" description. This
name is suitable as a parameter to the newState method, for example.
The name of this state |
getOptionalParameters | public Vector getOptionalParameters()(Code) | | Returns a list of optional parameters
a vector of optional parameter names. |
getOptionalParametersList | public List getOptionalParametersList()(Code) | | Returns a list of optional parameters. Same as
getOptionalParameters() but returns an List instead
a List collection giving all optional parameters |
getParameter | public String getParameter(String paramCode) throws ControllerException(Code) | | Fetch the value for the given parameter. Return null
if there is no such parameter
Parameters: paramCode - Code of the parameter desired java.lang.String The parameter value. throws: ControllerException - upon error |
getParameters | public Vector getParameters()(Code) | | Return the list of parameters required by this State
A Vector of the parameter names required by this State |
getPatternMatcher | protected PatternMatcher getPatternMatcher()(Code) | | Retrieve a thread local instance of the Perl5 pattern matcher. Allows
for optimization of # of instances of pattern matcher vs synchronization.
PatternMatcher |
getRequiredParametersList | public List getRequiredParametersList()(Code) | | Same as getParameters, but returns a List instead
a List collection giving all optional paramaters |
getReturnToSender | public Transition getReturnToSender()(Code) | | Return the return-to-sender transition. This is the transition that will
serialized and passed to any state that is invoked via a transition that
has return-to-sender enabled.
Transition object |
getStateFormClass | public String getStateFormClass()(Code) | | Return the class name (if any) of the state form associated with
this state.
java.lang.String |
getString | protected String getString(String key, Object[] args) throws ControllerException(Code) | | Convenience method - simply passes the request for a string on to
the ControllerResponse object associated with this State
Parameters: key - The key to format Parameters: args - The formatting arguments for the key. The i18n message that key points to. throws: ControllerException - upon error |
getString | protected String getString(String key) throws ControllerException(Code) | | Convenience method - simply passes the request for a string on to
the ControllerResponse object associated with this State
Parameters: key - the message bundle key java.lang.String throws: ControllerException - upon error |
getSuccessTransition | public Transition getSuccessTransition()(Code) | | Return the success transition. This is the transition that will be
executed if this state returns without errors in the error collection.
Transition object |
getUser | public String getUser()(Code) | | Get the user name
java.lang.String login name of the user |
hashCode | public int hashCode()(Code) | | Returns a hash code value for the object.
a hash code value for this object. |
isFileParameter | public boolean isFileParameter(String paramName)(Code) | | Does a specified parameter refer to an uploaded file?
Parameters: paramName - The parameter name to check. true if the parameter is a file parameter. |
isSecure | public boolean isSecure()(Code) | | Should this state be run within an SSL protocol (if SSL is available)
true if SSL should be used for this state |
perform | public void perform(StateForm stateForm, ControllerRequest newRequest, ControllerResponse newResponse) throws NonHandleableException, ControllerException(Code) | | A state may implement a "perform" method to actually perform it's
logic by overriding this method. Any associated state form will
be passed in with its data populated.
If this method is not implemented by a child class then the "run" method will be
called to be backwards compatible with previous versions.
Parameters: stateForm - unused, useful for matching with Struts API Parameters: newRequest - The controller request object that has been prepared by the framework,that contains all the parameters needed to execute state Parameters: newResponse - The controller response object that you use to populate withinputs, outputs and transitions. throws: ControllerException - upon error throws: NonHandleableException - upon fatal error |
setDescription | public void setDescription(String newDescrip)(Code) | | Set a description (human-readable) for this state. This is normally
done via the constructor. The description may be just a string
describing the state in a few words, or (preferrably) it may
be a key into the local language file, facilitation internationalization
Parameters: newDescrip - The new description for the state. |
setErrorState | public synchronized void setErrorState(String newErrorState)(Code) | | Sets the state that defines the error state.
Parameters: newErrorState - The name of the state to set as the error state |
setErrorTransition | public void setErrorTransition(Transition newErrorTransition)(Code) | | Set the error transition. This is the transition that will be
executed if this state returns any errors in the error collection.
Parameters: newErrorTransition - A new transition object pointing to the error state |
setHandlerName | public void setHandlerName(String newName)(Code) | | Use this function to bypass the automatic function naming that goes on
based upon the state
Parameters: newName - the name that you want the controller to automatically call whentransitioning to this state. |
setMask | public synchronized void setMask(String paramName, String mask)(Code) | | Set a regular expression "mask" for a particular parameter
The parameter value is checked against this mask before the
transition into the new state begins Also precompiles the regular
expression to allow for quick parameter checking.
Parameters: paramName - parameter name to check against the regular expression Parameters: mask - The regular Expression throws: IllegalArgumentException - if the paramName or mask is blank. |
setMask | public synchronized void setMask(String paramName, String mask, String errorMsg)(Code) | | Set a regular expression "mask" for a particular parameter
The parameter value is checked against this mask before the
transition into the new state begins
Parameters: paramName - The parameter name to check against the regular expression Parameters: mask - The regular Expression Parameters: errorMsg - The error message to use if the state fails. throws: IllegalArgumentException - if the paramName or mask is blank. |
setMaskError | public void setMaskError(String paramName, String errorMsg)(Code) | | If a state fails a parameter check on a mask, then the error specified will
be stored in the error collections
Parameters: paramName - The parameter name to check against the regular expressionset in setMask Parameters: errorMsg - The error message to display. It may be a string thatexists in a resource bundle, in which case that will be displayed instead |
setName | public void setName(String newName)(Code) | | Set the internal "name" of this state. Normally done via the
constructor when the state is "declared" in the appropriate
controller.
Parameters: newName - The new name of the state. |
setReturnToSender | public void setReturnToSender(Transition newReturnToSender)(Code) | | Set the return-to-sender transition. This is the transition that will be
serialized and passed to any state that is invoked via a transition that
has return-to-sender enabled.
Parameters: newReturnToSender - Transition instance. |
setSecure | public void setSecure(boolean newSecure)(Code) | | Sets the "should be secure" flag. Ie, if SSL is available, this state
should be run within SSL.
Parameters: newSecure - Such a true if you want to use SSL for the state. |
setStateFormClass | public void setStateFormClass(String newStateFormClass)(Code) | | Set the class name of the state form associated with this state.
Parameters: newStateFormClass - The class name of the object to use as an action form. |
setSuccessTransition | public void setSuccessTransition(Transition newSuccessTransition)(Code) | | Set the success transition. This is the transition that will be
executed if this state returns without errors in the error collection.
Parameters: newSuccessTransition - The transition to use for successful state executions. |
toString | public String toString()(Code) | | Returns the string of this state. Good for debugging error messages
The object class name |
|
|