Keel 2.1RC2

org.keel.comm
Class ModelResponseMessage

java.lang.Object
  extended byorg.keel.comm.ModelResponseMessage
All Implemented Interfaces:
KeelResponse, ModelResponse, java.io.Serializable

public class ModelResponseMessage
extends java.lang.Object
implements ModelResponse, java.io.Serializable

See Also:
Serialized Form

Field Summary
private  java.util.Map attributes
           
private  java.util.List elementList
           
private  java.util.Map elements
          Map of the ResponseElement entries this response contains
private  short errorDupCount
           
private  java.util.Map errors
           
private  java.util.Map errorTypes
           
private  ModelResponse originalRes
           
private static java.lang.String PREFIX
           
private  java.util.Map stackTraces
           
 
Fields inherited from interface org.keel.services.model.ModelResponse
ROLE
 
Constructor Summary
ModelResponseMessage()
           
 
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 newErrors)
          Deprecated. This method doesn't support sending the stack trace with the error, which is usually very helpful. Use addError instead for each error.
 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 addThrowables(java.util.Map m)
           
 void clearErrors()
          Clear the current errors Map
 void copyFrom(ModelResponse res)
           
 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)
          We don't store the actual Throwable in a ModelRequestMessage, only the stacktrace.
private  void notImplemented()
           
 void remove(ResponseElement re)
          Remove a specific element
 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.
 java.lang.String toString()
          toString for a ModelRequestMessage just passes the request on to the underlying ModelRequest.
private  java.lang.String uniqueErrorName(java.lang.String errorName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

private java.util.Map attributes

errorDupCount

private transient short errorDupCount

PREFIX

private static java.lang.String PREFIX

elements

private java.util.Map elements
Map of the ResponseElement entries this response contains


elementList

private java.util.List elementList

errors

private java.util.Map errors

errorTypes

private java.util.Map errorTypes

stackTraces

private java.util.Map stackTraces

originalRes

private transient ModelResponse originalRes
Constructor Detail

ModelResponseMessage

public ModelResponseMessage()
Method Detail

removeAttribute

public void removeAttribute(java.lang.String key)
Specified by:
removeAttribute in interface KeelResponse

addOutput

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

Specified by:
addOutput in interface KeelResponse
Throws:
ModelException

notImplemented

private void notImplemented()

addOutput

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

Specified by:
addOutput in interface KeelResponse
Throws:
ModelException

createOutput

public Output createOutput(java.lang.String name)
                    throws ModelException
Description copied from interface: KeelResponse
Create an Output with the specified name

Specified by:
createOutput in interface KeelResponse
Throws:
ModelException

createOutput

public Output createOutput(java.lang.String name,
                           java.lang.String content)
                    throws ModelException
Description copied from interface: KeelResponse
Create an output with the specified name and content

Specified by:
createOutput in interface KeelResponse
Throws:
ModelException

createInput

public Input createInput(java.lang.String name)
                  throws ModelException
Description copied from interface: KeelResponse
Create an Input with the specified name

Specified by:
createInput in interface KeelResponse
Throws:
ModelException

addInput

public void addInput(java.lang.String name,
                     java.lang.String label)
              throws ModelException
Description copied from interface: KeelResponse
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.

Specified by:
addInput in interface KeelResponse
Throws:
ModelException

createCommand

public Command createCommand(java.lang.String model)
                      throws ModelException
Description copied from interface: KeelResponse
Create a Command with the specified name

Specified by:
createCommand in interface KeelResponse
Throws:
ModelException

createCommandRelativeSequence

public Command createCommandRelativeSequence(int numberOfSteps)
                                      throws ModelException
Specified by:
createCommandRelativeSequence in interface KeelResponse
Throws:
ModelException

addCommand

public void addCommand(java.lang.String model,
                       java.lang.String label)
                throws ModelException
Description copied from interface: KeelResponse
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.

Specified by:
addCommand in interface KeelResponse
Throws:
ModelException

get

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

Specified by:
get in interface KeelResponse

remove

public void remove(ResponseElement re)
Remove a specific element

Specified by:
remove in interface KeelResponse

getAll

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

Specified by:
getAll in interface KeelResponse

add

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

Specified by:
add in interface KeelResponse
Throws:
ModelException

uniqueErrorName

private java.lang.String uniqueErrorName(java.lang.String errorName)

addError

public void addError(java.lang.String errorName,
                     java.lang.String errorMessage)
Description copied from interface: KeelResponse
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.

Specified by:
addError in interface KeelResponse
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)
Description copied from interface: KeelResponse
Just like addError above, but including an actual throwable with details about the error

Specified by:
addError in interface KeelResponse
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)
Description copied from interface: KeelResponse
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.

Specified by:
addError in interface KeelResponse
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 newErrors)
Deprecated. This method doesn't support sending the stack trace with the error, which is usually very helpful. Use addError instead for each error.

Add an entire Map of errors at once

Specified by:
addErrors in interface KeelResponse

clearErrors

public void clearErrors()
Description copied from interface: KeelResponse
Clear the current errors Map

Specified by:
clearErrors in interface KeelResponse

getErrors

public java.util.Map getErrors()
Description copied from interface: KeelResponse
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.

Specified by:
getErrors in interface KeelResponse
Returns:
A map of error names and messages

getErrorType

public java.lang.String getErrorType(java.lang.String errorName)
Description copied from interface: KeelResponse
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.

Specified by:
getErrorType in interface KeelResponse
Parameters:
errorName - Name of the error to be checked
Returns:
The classname of the exception embedded in the given error.

getStackTrace

public java.lang.String getStackTrace(java.lang.String errorName)
Description copied from interface: KeelResponse
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

Specified by:
getStackTrace in interface KeelResponse
Parameters:
errorName - The name of the error, as used when addError logged the error originally

setRequest

public void setRequest(ModelRequest req)
Description copied from interface: KeelResponse
Used *only* by the ModelRequest to associate the originating request with the response.

Specified by:
setRequest in interface KeelResponse

setDefaultsFromPrevious

public void setDefaultsFromPrevious()
Description copied from interface: KeelResponse
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.

Specified by:
setDefaultsFromPrevious in interface KeelResponse

addThrowables

public void addThrowables(java.util.Map m)

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Specified by:
getAttribute in interface KeelResponse

getAttributes

public java.util.Map getAttributes()
Specified by:
getAttributes in interface KeelResponse

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Description copied from interface: KeelResponse
Set the value of an attribute of this response

Specified by:
setAttribute in interface KeelResponse

copyFrom

public void copyFrom(ModelResponse res)
              throws ModelException
Throws:
ModelException

serialize

public byte[] serialize()
                 throws java.io.IOException
Specified by:
serialize in interface KeelResponse
Throws:
java.io.IOException

deserialize

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

getThrowable

public java.lang.Throwable getThrowable(java.lang.String oneKey)
We don't store the actual Throwable in a ModelRequestMessage, only the stacktrace.

Specified by:
getThrowable in interface KeelResponse
Parameters:
oneKey - The error message key of the error for which the corresponding Throwable was requested.
Returns:
Nothing. This method always throws an exception.
Throws:
java.lang.IllegalArgumentException - We don't store the throwables.

toString

public java.lang.String toString()
toString for a ModelRequestMessage just passes the request on to the underlying ModelRequest.

Returns:
A string representation of this class

Keel 2.1RC2

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