|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.controller.State
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 | |
static String |
NOTEMPTY_MASK
Regular expression to check for at least one character, including newline (? |
protected boolean |
secure
Is this state to run within an SSL setting? |
| Constructor Summary | |
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. |
|
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)
Convenience method to allow us to add any ControllerElement to this controllers inputs, outputs or transitions |
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 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 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. |
void |
addError(String newError)
Adds an error to this controllerResponse's Error Collection |
protected void |
addInput(Input newInput)
Adds an input object to the controller response |
void |
addOptionalParameter(String newParam)
Add a required parameter to this state |
protected void |
addOutput(Output newOutput)
Adds an output object to the controller response |
void |
addParameter(String newParam,
boolean required,
String mask)
Add a new parameter to this state |
void |
addParameter(String newParam,
boolean required,
String mask,
String maskError)
Add a new parameter to this state |
void |
addParameter(String newParam,
String mask)
Add a new parameter to this state |
void |
addRequiredParameter(String newParam)
Add a required parameter to this state |
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. and sets the handlerName String to that value. |
protected void |
checkMask(String paramName,
String paramValue,
org.apache.oro.text.regex.Pattern compiledRegExp)
Checks a parameter given to the controller against a defined regular expression mask. |
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()
Clears the form cache in the controller response |
Object |
clone()
returns a copy of itself |
boolean |
equals(Object o)
Deprecated. use direct comparison of state name instead. this algorithm which allows 2 kinds of objects is ugly, and no longer used in expresso as of 5/04, v.5.5.1 LAH |
protected String |
getAttribute(String attrib)
get attribute from request |
Controller |
getController()
retrieve the controller instance that is associated with this state |
protected ControllerRequest |
getControllerRequest()
Gets the ControllerRequest object associated with this state. |
protected ControllerResponse |
getControllerResponse()
Retrieves the ControllerResponse object associated with this state |
String |
getDataContext()
Return the name of the database connection we use - or null for the default connection |
protected DBController |
getDBController()
Deprecated. 4/04 v5.5 use getController and cast. |
String |
getDBName()
Return the name of the database connection we use - or null for the default connection |
String |
getDescription()
Get the description of this state, as supplied when the state is created. |
ErrorCollection |
getErrors()
Returns the errors collection of this current request and current state. |
String |
getErrorState()
Retrieves the state that has been set as the error state |
Transition |
getErrorTransition()
Return the error transition. |
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. the location that has the data that was uploaded stored in it. |
protected String |
getFormCache(String fieldName)
Retrieve the form cash value |
String |
getHandlerName()
Return the name of the method that will handle transitions to this state. |
String |
getInitParameter(String paramName)
? |
String |
getName()
Get the name of this state. |
Object |
getObjectParameter(String paramName)
? |
Vector |
getOptionalParameters()
Deprecated. 3/5/04 v5.5 Use getOptionalParametersList instead |
List |
getOptionalParametersList()
Returns a list of optional parameters. |
String |
getParameter(String paramCode)
Fetch the value for the given parameter. |
Vector |
getParameters()
Return the list of parameters required by this State |
protected org.apache.oro.text.regex.PatternMatcher |
getPatternMatcher()
Retrieve a thread local instance of the Perl5 pattern matcher. |
List |
getRequiredParametersList()
Same as getParameters, but returns a List instead |
ControllerResponse |
getResponse()
|
Transition |
getReturnToSender()
Return the return-to-sender transition. |
PersistentSession |
getSession()
|
String |
getStateFormClass()
Return the class name (if any) of the state form associated with this state. |
protected String |
getString(String key)
Convenience method - simply passes the request for a string on to the ControllerResponse object 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 |
Transition |
getSuccessTransition()
Return the success transition. |
protected int |
getUid()
Retrieve the State user ID. |
String |
getUser()
Deprecated. 3/5/04 use ControllerRequest getUid() instead. |
int |
hashCode()
Returns a hash code value for the object. |
boolean |
isFileParameter(String paramName)
Does a specified parameter refer to an uploaded file? |
protected boolean |
isParameter(String paramName)
|
boolean |
isSecure()
Should this state be run within an SSL protocol (if SSL is available) |
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. |
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)
Deprecated. 3/4/04 [v5.5] Use response.saveErrors instead. |
void |
setController(Controller newController)
Set the 'parent' controller |
void |
setDescription(String newDescrip)
Set a description (human-readable) for this state. |
void |
setErrorState(String newErrorState)
Sets the state that defines the error state. |
void |
setErrorTransition(Transition newErrorTransition)
Set the error transition. |
protected void |
setFormCache()
To the form cache in the controller response |
void |
setHandlerName(String newName)
Use this function to bypass the automatic function naming that goes on based upon the state |
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. |
void |
setMask(String paramName,
String mask,
String errorMsg)
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 |
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 |
void |
setName(String newName)
Set the internal "name" of this state. |
protected void |
setResponse(ControllerResponse res)
Set the ControllerResponse object associated with this state |
void |
setReturnToSender(Transition newReturnToSender)
Set the return-to-sender transition. |
void |
setSecure(boolean newSecure)
Sets the "should be secure" flag. |
void |
setStateFormClass(String newStateFormClass)
Set the class name of the state form associated with this state. |
void |
setSuccessTransition(Transition newSuccessTransition)
Set the success transition. |
String |
toString()
Returns the string of this state. |
protected void |
transition(String newState,
ControllerRequest req,
ControllerResponse res)
|
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String NOTEMPTY_MASK
protected boolean secure
| Constructor Detail |
public State()
public State(String newName,
String newDescrip)
newName - The name of the new statenewDescrip - A description for the new state - this may be
(preferrably) a key into the local language file in order to facilitate
internationalization, or just a simple string.| Method Detail |
protected org.apache.oro.text.regex.PatternMatcher getPatternMatcher()
public void setController(Controller newController)
throws ControllerException
newController - The controller instance to set for the state
ControllerException - upon error or null parameterpublic void setErrorState(String newErrorState)
newErrorState - The name of the state to set as the error statepublic String getErrorState()
public void setMask(String paramName,
String mask)
paramName - parameter name to check against the regular expressionmask - The regular Expression
IllegalArgumentException - if the paramName or mask is blank.
public void setMask(String paramName,
String mask,
String errorMsg)
paramName - The parameter name to check against the regular expressionmask - The regular ExpressionerrorMsg - The error message to use if the state fails.
IllegalArgumentException - if the paramName or mask is blank.
public void setMaskError(String paramName,
String errorMsg)
paramName - The parameter name to check against the regular expression
set in setMaskerrorMsg - The error message to display. It may be a string that
exists in a resource bundle, in which case that will be displayed instead
protected void setResponse(ControllerResponse res)
throws ControllerException
res - The controller response associated with the state's instance.
ControllerException - upon invalid parameterpublic void setReturnToSender(Transition newReturnToSender)
newReturnToSender - Transition instance.public void setStateFormClass(String newStateFormClass)
newStateFormClass - The class name of the object to use as an action form.public void setSuccessTransition(Transition newSuccessTransition)
newSuccessTransition - The transition to use for successful state executions.public ControllerResponse getResponse()
public Controller getController()
throws ControllerException
ControllerException - [usually never thrown]
protected DBController getDBController()
throws ControllerException
ControllerException - if the controller is not an instance of
DBController.public void setName(String newName)
newName - The new name of the state.public void setSecure(boolean newSecure)
newSecure - Such a true if you want to use SSL for the state.public void setDescription(String newDescrip)
newDescrip - The new description for the state.public void addRequiredParameter(String newParam)
newParam - The name of the new parameterpublic void addOptionalParameter(String newParam)
newParam - The name of the new parameter
public void addParameter(String newParam,
String mask)
newParam - The name of the new parametermask - The regular expression mask to compare against.
public void addParameter(String newParam,
boolean required,
String mask)
newParam - The name of the new parameterrequired - should an exception be thrown if this parameter isn't included?mask - The regular expression mask to compare against.
public void addParameter(String newParam,
boolean required,
String mask,
String maskError)
newParam - The name of the new parameterrequired - should an exception be thrown if this parameter isn't included?mask - The regular expression mask to compare against.maskError - The error message to give if mask validation fails.public String getDescription()
public String getName()
public Vector getParameters()
public List getRequiredParametersList()
public Vector getOptionalParameters()
public List getOptionalParametersList()
public String toString()
public boolean equals(Object o)
o - The object to compare against.
public Transition getErrorTransition()
public void run(ControllerRequest newRequest,
ControllerResponse newResponse)
throws ControllerException,
NonHandleableException
newRequest - The controller request object that has been prepared by the framework,
that contains all the parameters needed to execute statenewResponse - The controller response object that you use to populate with
inputs, outputs and transitions.
ControllerException - upon error
NonHandleableException - upon fatal error
public void perform(StateForm stateForm,
ControllerRequest newRequest,
ControllerResponse newResponse)
throws NonHandleableException,
ControllerException
stateForm - unused, useful for matching with Struts APInewRequest - The controller request object that has been prepared by the framework,
that contains all the parameters needed to execute statenewResponse - The controller response object that you use to populate with
inputs, outputs and transitions.
ControllerException - upon error
NonHandleableException - upon fatal error
protected void add(ControllerElement t)
throws ControllerException
t - The controller element, either an input an output, a transition,
or a block that gets added to the controller response.
ControllerException - upon error
public void addTransition(Transition newTransition)
throws ControllerException
newTransition - The transition to add.
ControllerException - upon error
protected void addBlock(Block newBlock)
throws ControllerException
newBlock - The block to add.
ControllerException - upon error
protected void addAutoInput(String fieldName,
String friendlyName,
String defaultValue,
int displayLength,
int maxLength,
Vector validValues)
throws ControllerException
fieldName - java.lang.StringfriendlyName - the input's labeldefaultValue - java.lang.StringdisplayLength - The size of the input text boxmaxLength - The maximum input length of the input.validValues - The valid value list associated with the input
(for drop-down multivalue inputs only)
ControllerException - upon error
protected void addInput(Input newInput)
throws ControllerException
newInput - The input object to add
ControllerException - upon error
protected void addOutput(Output newOutput)
throws ControllerException
newOutput - The output object to add
ControllerException - upon error
protected void addAutoInput(String fieldName,
String dbClassName,
String defaultValue)
throws ControllerException
fieldName - java.lang.StringdbClassName - java.lang.StringdefaultValue - java.lang.String
ControllerException - upon error
protected void addAutoInput(String fieldName,
String friendlyName,
String dbClassName,
String defaultValue)
throws ControllerException
fieldName - java.lang.StringfriendlyName - The label of the new inputdbClassName - java.lang.StringdefaultValue - java.lang.String
ControllerException - upon error
protected void autoValidate(String checkClassName,
ErrorCollection errorCollection)
throws ValidationException,
ControllerException
checkClassName - The class name to perform the error checkingerrorCollection - The error collection to get populated with validation errors
if validation on any particular field fails.
ValidationException - The exception description.
ControllerException - upon error
protected void autoValidate(String checkClassName,
ErrorCollection errorCollection,
Vector requiredFields)
throws ValidationException,
ControllerException
checkClassName - The class name to perform the error checkingerrorCollection - The error collection to get populated with validation errors
if validation on any particular field fails.requiredFields - Vector of Strings: which inputs are required.
ValidationException - Upon validation error
ControllerException - upon errorprotected String getFileName(String paramName)
paramName - The parameter name that is expected to have a file associated with.
protected String getAttribute(String attrib)
attrib - The name of an "attribute" for this ControllerElement item
public Object getObjectParameter(String paramName)
throws ControllerException
paramName - The parameter name to retrieve
ControllerException - upon conversion errorpublic String getHandlerName()
public void setHandlerName(String newName)
newName - the name that you want the controller to automatically call when
transitioning to this state.public String getInitParameter(String paramName)
paramName - The parameter name to retrieve
public Transition getSuccessTransition()
public String getUser()
public String getParameter(String paramCode)
throws ControllerException
paramCode - Code of the parameter desired
ControllerException - upon errorpublic boolean isFileParameter(String paramName)
paramName - The parameter name to check.
public boolean isSecure()
public String getDBName()
public String getDataContext()
protected ControllerRequest getControllerRequest()
protected ControllerResponse getControllerResponse()
protected void calculateHandlerName(String stateName)
stateName - The name of the state to calculate the handler name.
public Object clone()
throws CloneNotSupportedException
CloneNotSupportedException - as specified by the object API
protected void saveErrors(ErrorCollection e)
throws ControllerException
e - The error collection to save
ControllerException - upon errorpublic void setErrorTransition(Transition newErrorTransition)
newErrorTransition - A new transition object pointing to the error state
protected void setFormCache()
throws ControllerException
ControllerException - upon error
protected void clearFormCache()
throws ControllerException
ControllerException - upon error
protected String getFormCache(String fieldName)
throws ControllerException
fieldName - The name of the field to retrieve
ControllerException - upon error
protected boolean isParameter(String paramName)
throws ControllerException
ControllerException
protected void transition(String newState,
ControllerRequest req,
ControllerResponse res)
throws ControllerException,
NonHandleableException
ControllerException
NonHandleableExceptionpublic Transition getReturnToSender()
public PersistentSession getSession()
throws ControllerException
ControllerExceptionpublic String getStateFormClass()
protected int getUid()
throws ControllerException
ControllerException - upon error
public void checkParamMasks()
throws ControllerException
ControllerException - upon error
public ErrorCollection getErrors()
throws ControllerException
ControllerException - upon error
public void addError(String newError)
throws ControllerException
newError - The error string to add.
ControllerException - upon error
protected void checkMask(String paramName,
String paramValue,
org.apache.oro.text.regex.Pattern compiledRegExp)
throws ControllerException
paramName - The state parameter name to checkparamValue - The value given the state to check againstcompiledRegExp - The compiled Perl 5 regular expression.
ControllerException - if there's an error with the regular expression
mask.
protected String getString(String key,
Object[] args)
throws ControllerException
key - The key to formatargs - The formatting arguments for the key.
ControllerException - upon error
protected String getString(String key)
throws ControllerException
key - the message bundle key
ControllerException - upon errorpublic int hashCode()
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||