com.objectplanet.survey.plugin.api
Class Response

java.lang.Object
  extended by com.objectplanet.survey.plugin.api.Response
Direct Known Subclasses:
ResponseDropdown, ResponseMatrix, ResponseMultiple, ResponseNumeric, ResponseRating

public class Response
extends java.lang.Object

ATTENTION: This class is a facade for the system business Response. To improve performance you can force it to keep the reference to the business object by calling keepBusinessObject() . Keeping references to objects may cause inconsistencies in the system, so always remember to call releaseBusinessObject() as soon as you are finished using them.

Response object contains respondent's answers to a question. Subclasses for the object implement response logic for different types of questions. This class stores respondents answer to the in-text elements and free text.
Flag isPersisted is true if the response is already saved in the storage.

If during validation the response happens to contain incorrect values, the isValid flag in the Response object is set to false and errorMessage will contain the message to show to the respondent.
If isValid() returns false, and getErrorMessage() returns null, the error is in one or more of the in-text element (or matrix cells), and you have to search through them to find the invalid ones. Use isValid(int intextIndex) and getErrorMessage(int intextIndex).

Author:
Irina Brun

Method Summary
 void deleteEssayResponse(int inTextFieldIndex)
          Deprecated. use deleteIntextResponse(int intextIndex)
 void deleteIntextResponse(int intextIndex)
          Deletes response to the in-text element.
 java.lang.String getErrorMessage()
          Gets the error message for the response.
 java.lang.String getErrorMessage(int intextIndex)
          Gets the error message for an in-text element.
 java.lang.String getEssayResponse(int inTextFieldIndex, int inTextFieldType)
          Deprecated. use getIntextResponse(int intextIndex, int intextType)
 java.lang.String getFreeText()
          Gets the answer to the free text.
 java.lang.String getIntextResponse(int intextIndex, int intextType)
          Gets the response value for the specified in-text element
 long getQuestionNo()
          Gets the questionId attribute of the Response object
 long getRespondentId()
          Gets the respondentId of the Response object
 long getResponseDate()
          Gets the response date (time stamp) for the response submission.
 boolean hasBusinessObject()
          Check if this question has reference to the business Response object.
 boolean isPersisted()
          Gets the isPersisted attribute of the Response object
 boolean isValid()
          Checks if response to the question is valid.
 boolean isValid(int intextIndex)
          Checks if response to the in-text element is valid.
 void keepBusinessObject()
          Get and keep business object.
 void releaseBusinessObject()
          Release business object.
 void setEssayResponse(int inTextFieldIndex, int inTextFieldType, java.lang.String answer)
          Deprecated. use setIntextResponse(int intextIndex, int intextType, String answer)
 void setFreeText(java.lang.String freeText)
          Sets the free text answer
 void setIntextResponse(int intextIndex, int intextType, java.lang.String answer)
          Sets the answer to an in-text element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setFreeText

public void setFreeText(java.lang.String freeText)
                 throws SurveySystemException
Sets the free text answer

Parameters:
freeText - The new free text
Throws:
SurveySystemException - If any error occurs in the system.

getErrorMessage

public java.lang.String getErrorMessage()
                                 throws SurveySystemException
Gets the error message for the response. This will exist if the 'question-type' input is invalid.
Read more here .

Returns:
The error message
Throws:
SurveySystemException - If any error occurs in the system.

getErrorMessage

public java.lang.String getErrorMessage(int intextIndex)
                                 throws SurveySystemException
Gets the error message for an in-text element. This will exist if the response to the in-text element is invalid. Read more here .

Parameters:
intextIndex - Position of the in-text element. Starts at 0.
Returns:
The error message
Throws:
SurveySystemException - If any error occurs in the system.

getFreeText

public java.lang.String getFreeText()
                             throws SurveySystemException
Gets the answer to the free text.

Returns:
The free text or null if no answer exists.
Throws:
SurveySystemException - If any error occurs in the system.

getQuestionNo

public long getQuestionNo()
Gets the questionId attribute of the Response object

Returns:
The questionId value

getRespondentId

public long getRespondentId()
Gets the respondentId of the Response object

Returns:
The respondentId value

getResponseDate

public long getResponseDate()
                     throws SurveySystemException
Gets the response date (time stamp) for the response submission.

Returns:
the response date
Throws:
SurveySystemException - If any error occurs in the system.

isPersisted

public boolean isPersisted()
                    throws SurveySystemException
Gets the isPersisted attribute of the Response object

Returns:
The isPersisted value
Throws:
SurveySystemException - If any error occurs in the system.

isValid

public boolean isValid()
                throws SurveySystemException
Checks if response to the question is valid. For in-text elements and matrix questions the hole response will be invalid if input in one field is invalid.

Returns:
The valid value
Throws:
SurveySystemException - If any error occurs in the system.

isValid

public boolean isValid(int intextIndex)
                throws SurveySystemException
Checks if response to the in-text element is valid.

Parameters:
intextIndex - Position of the in-text element. Starts at 0.
Returns:
The valid value
Throws:
SurveySystemException - If any error occurs in the system.

hasBusinessObject

public boolean hasBusinessObject()
Check if this question has reference to the business Response object. See ATTENTION .

Returns:
True/false

keepBusinessObject

public void keepBusinessObject()
                        throws SurveySystemException
Get and keep business object. See ATTENTION .

Throws:
SurveySystemException - If an error occurs in the system.

releaseBusinessObject

public void releaseBusinessObject()
Release business object. See ATTENTION .


setIntextResponse

public void setIntextResponse(int intextIndex,
                              int intextType,
                              java.lang.String answer)
                       throws java.lang.IllegalArgumentException,
                              SurveySystemException
Sets the answer to an in-text element. If the in-text element is of type Question.INTEXT_TYPE_CHECKBOX, use "true" for checked value. Everything but "true" will be considered as not checked value.

Parameters:
intextIndex - Position of the in-text element. Starts at 0.
intextType - in-text element type. One of the types defined in Question.
answer - The response to the in-text element
Throws:
java.lang.IllegalArgumentException - If illegal parameters
SurveySystemException - If any error occurs in the system.

getIntextResponse

public java.lang.String getIntextResponse(int intextIndex,
                                          int intextType)
                                   throws java.lang.IllegalArgumentException,
                                          SurveySystemException
Gets the response value for the specified in-text element

Parameters:
intextIndex - Position of the in-text element. Starts at 0.
intextType - in-text element type. One of the types defined in Question.
Returns:
The response value
Throws:
java.lang.IllegalArgumentException - If illegal positions
SurveySystemException - If any error occurs in the system.

deleteIntextResponse

public void deleteIntextResponse(int intextIndex)
                          throws SurveySystemException
Deletes response to the in-text element.

Parameters:
intextIndex - Position of the in-text element. Starts at 0.
Throws:
SurveySystemException - If any error occurs in the system.

setEssayResponse

public void setEssayResponse(int inTextFieldIndex,
                             int inTextFieldType,
                             java.lang.String answer)
                      throws java.lang.IllegalArgumentException,
                             SurveySystemException
Deprecated. use setIntextResponse(int intextIndex, int intextType, String answer)

Sets the answer to an in-text field. If the in-text field is of type Question.ESSAY_FIELD_CHECKBOX, use "true" for checked value. Everything but "true" will be considered as not checked value.

Parameters:
inTextFieldIndex - Position of the in-text field. Starts at 0.
inTextFieldType - In-text field type. One of the types defined in Question.
answer - The response to the in-text field
Throws:
java.lang.IllegalArgumentException - If illegal parameters
SurveySystemException - If any error occurs in the system.

getEssayResponse

public java.lang.String getEssayResponse(int inTextFieldIndex,
                                         int inTextFieldType)
                                  throws java.lang.IllegalArgumentException,
                                         SurveySystemException
Deprecated. use getIntextResponse(int intextIndex, int intextType)

Gets the response value for the specified in-text field

Parameters:
inTextFieldIndex - In-text field position. Starts at 0.
inTextFieldType - In-text field type. One of the types defined in Question.
Returns:
The response value
Throws:
java.lang.IllegalArgumentException - If illegal positions
SurveySystemException - If any error occurs in the system.

deleteEssayResponse

public void deleteEssayResponse(int inTextFieldIndex)
                         throws SurveySystemException
Deprecated. use deleteIntextResponse(int intextIndex)

Deletes response to the in-text field.

Parameters:
inTextFieldIndex - Position of the in-text field. Starts at 0.
Throws:
SurveySystemException - If any error occurs in the system.

Copyright ? ObjectPlanet Inc. All Rights Reserved.

Built on December 20 2016