Keel 2.1RC2

org.keel.services.model
Interface KeelResponse

All Known Subinterfaces:
ModelResponse
All Known Implementing Classes:
DefaultModelResponse, ModelResponseMessage

public interface KeelResponse


Method Summary
 void add(ResponseElement re)
          The Model (only) uses the method below to add new response elements to this response.
 void addCommand(java.lang.String model, java.lang.String label)
          Convenience add method for creating a simple command If you need to specify additional information about the command, such as parameters use createCommand, populate the object, then use add.
 void addError(java.lang.String errorName, java.lang.String errorMessage)
          Add an error with a specific name.
 void addError(java.lang.String errorName, java.lang.String errorMessage, java.lang.Throwable t)
          Just like addError above, but including an actual throwable with details about the error
 void addError(java.lang.String errorName, java.lang.Throwable t)
          Just like addError above, but including a throwable but no message.
 void addErrors(java.util.Map errors)
          Add a whole set of errors to the current error set.
 void addInput(java.lang.String name, java.lang.String label)
          Convenience add method for creating a simple input.
 void addOutput(java.lang.String content)
          Convenience add method for creating a simple string output with a name assigned by the ModelResponse
 void addOutput(java.lang.String name, java.lang.String content)
          Convenience add method for creating a simple string output with a specific name
 void clearErrors()
          Clear the current errors Map
 Command createCommand(java.lang.String model)
          Create a Command with the specified name
 Command createCommandRelativeSequence(int numberOfSteps)
           
 Input createInput(java.lang.String name)
          Create an Input with the specified name
 Output createOutput(java.lang.String name)
          Create an Output with the specified name
 Output createOutput(java.lang.String name, java.lang.String content)
          Create an output with the specified name and content
 KeelResponse deserialize(byte[] bytes)
           
 ResponseElement get(java.lang.String elementLocator)
          Return a specific element
 java.util.Iterator getAll()
          Return an iterator over all of the ResponseElements in this response
 java.lang.Object getAttribute(java.lang.String key)
           
 java.util.Map getAttributes()
           
 java.util.Map getErrors()
          Return a map of error names and error messages.
 java.lang.String getErrorType(java.lang.String errorName)
          Get the type of the specified error, where the type is the classname of the exception contained in the error.
 java.lang.String getStackTrace(java.lang.String errorName)
          If there is a stack trace related to the error, it can be accessed via this method.
 java.lang.Throwable getThrowable(java.lang.String oneKey)
           
 void remove(ResponseElement re)
           
 void removeAttribute(java.lang.String key)
           
 byte[] serialize()
           
 void setAttribute(java.lang.String key, java.lang.Object value)
          Set the value of an attribute of this response
 void setDefaultsFromPrevious()
          This method is used to facilitate a "repeat request" where the default values of Inputs are set from the values entered in the previous request by the user.
 void setRequest(ModelRequest req)
          Used *only* by the ModelRequest to associate the originating request with the response.
 

Method Detail

get

public ResponseElement get(java.lang.String elementLocator)
Return a specific element


remove

public void remove(ResponseElement re)
            throws ModelException
Throws:
ModelException

getAll

public java.util.Iterator getAll()
Return an iterator over all of the ResponseElements in this response


add

public void add(ResponseElement re)
         throws ModelException
The Model (only) uses the method below to add new response elements to this response.

Throws:
ModelException

addOutput

public void addOutput(java.lang.String name,
                      java.lang.String content)
               throws ModelException
Convenience add method for creating a simple string output with a specific name

Throws:
ModelException

addOutput

public void addOutput(java.lang.String content)
               throws ModelException
Convenience add method for creating a simple string output with a name assigned by the ModelResponse

Throws:
ModelException

addInput

public void addInput(java.lang.String name,
                     java.lang.String label)
              throws ModelException
Convenience add method for creating a simple input. If you need to specify additional information about the input, such as valid values, use createInput, populate the object, then use add.

Throws:
ModelException

addCommand

public void addCommand(java.lang.String model,
                       java.lang.String label)
                throws ModelException
Convenience add method for creating a simple command If you need to specify additional information about the command, such as parameters use createCommand, populate the object, then use add.

Throws:
ModelException

createOutput

public Output createOutput(java.lang.String name)
                    throws ModelException
Create an Output with the specified name

Throws:
ModelException

createOutput

public Output createOutput(java.lang.String name,
                           java.lang.String content)
                    throws ModelException
Create an output with the specified name and content

Throws:
ModelException

createInput

public Input createInput(java.lang.String name)
                  throws ModelException
Create an Input with the specified name

Throws:
ModelException

createCommand

public Command createCommand(java.lang.String model)
                      throws ModelException
Create a Command with the specified name

Throws:
ModelException

createCommandRelativeSequence

public Command createCommandRelativeSequence(int numberOfSteps)
                                      throws ModelException
Throws:
ModelException

addError

public void addError(java.lang.String errorName,
                     java.lang.String errorMessage)
Add an error with a specific name. This name may be used to associate the error with a certain UI element (such as an Input), so the user can see immediately what was wrong when the error is displayed.

Parameters:
errorName - A name for this error message, which may (or may not) correspond to the UI element from which the error originated.
errorMessage - A human-readable error message to be displayed to the user. Messages beginning with "$" will be taken to be internationalized keys to look up in the appropriate message bundle for this locale.

addError

public void addError(java.lang.String errorName,
                     java.lang.String errorMessage,
                     java.lang.Throwable t)
Just like addError above, but including an actual throwable with details about the error

Parameters:
errorName - A name for this error message, which may (or may not) correspond to the UI element from which the error originated.
errorMessage - A human-readable error message to be displayed to the user. Messages beginning with "$" will be taken to be internationalized keys to look up in the appropriate message bundle for this locale.
t - A Throwable that caused this error to be recorded.

addError

public void addError(java.lang.String errorName,
                     java.lang.Throwable t)
Just like addError above, but including a throwable but no message. The getMessage() method of the throwable will be used to determine the message displayed.

Parameters:
errorName - A name for this error message, which may (or may not) correspond to the UI element from which the error originated.
t - A Throwable that caused this error to be recorded.

addErrors

public void addErrors(java.util.Map errors)
Add a whole set of errors to the current error set. The map is assumed to contain an error name followed by an error message or a throwable.


getErrors

public java.util.Map getErrors()
Return a map of error names and error messages. Use getStackTrace to get the corresponding stack trace of the throwable recorded with this error, if any.

Returns:
A map of error names and messages

clearErrors

public void clearErrors()
Clear the current errors Map


getStackTrace

public java.lang.String getStackTrace(java.lang.String errorName)
If there is a stack trace related to the error, it can be accessed via this method. Each error has an error key - this same key is used here to request the corresponding stack trace, if any

Parameters:
errorName - The name of the error, as used when addError logged the error originally

getErrorType

public java.lang.String getErrorType(java.lang.String errorName)
Get the type of the specified error, where the type is the classname of the exception contained in the error. May be null if no exception was included in the error.

Parameters:
errorName - Name of the error to be checked
Returns:
The classname of the exception embedded in the given error.

setRequest

public void setRequest(ModelRequest req)
Used *only* by the ModelRequest to associate the originating request with the response.


setDefaultsFromPrevious

public void setDefaultsFromPrevious()
This method is used to facilitate a "repeat request" where the default values of Inputs are set from the values entered in the previous request by the user. This method sets the default value for each input found in the current request to the value of the parameter with the same name from the *previous* ModelRequest.


setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Set the value of an attribute of this response


removeAttribute

public void removeAttribute(java.lang.String key)

getAttribute

public java.lang.Object getAttribute(java.lang.String key)

getAttributes

public java.util.Map getAttributes()

serialize

public byte[] serialize()
                 throws java.io.IOException
Throws:
java.io.IOException

deserialize

public KeelResponse deserialize(byte[] bytes)
                         throws java.io.IOException
Throws:
java.io.IOException

getThrowable

public java.lang.Throwable getThrowable(java.lang.String oneKey)

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.