Package org.silverpeas.components.survey.web

# Class AnswerEntity

java.lang.Object
org.silverpeas.components.survey.web.AnswerEntity

All Implemented Interfaces:
  `Serializable`, `org.silverpeas.core.web.rs.WebEntity`

public class AnswerEntity extends Object implements org.silverpeas.core.web.rs.WebEntity
This is a WEB entity representation of an `Answer` linked to a `Question`.

Author:
  silveryocha
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AnswerEntity()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AnswerEntity`
  `asWebEntity(org.silverpeas.core.questioncontainer.answer.model.Answer answer)`
  Gets the `AnswerEntity` instance from given `Answer` one.
  `String`
  `getId()`
  Gets the identifier of the answer.
  `String`
  `getImageUrl()`
  Gets the URL of a linked image if any.
  `String`
  `getInstanceId()`
  Gets the identifier of the survey component instance hosting the answer.
  `String`
  `getLabel()`
  Gets the label of the answer.
  `int`
  `getNbVoters()`
  Gets the number of voters who choose the answer.
  `String`
  `getQuestionId()`
  Gets the identifier of the question the answer is linked to.
  `URI`
  `getURI()`
  `boolean`
  `isOpened()`
  Indicates if the answer is an opened one.
  `static Optional<String>`
  `normalizeImageUrl(String instanceId, String imageUrl)`
  Normalizes the image URL of an answer.
  `void`
  `setId(String id)`
  `void`
  `setImageUrl(String imageUrl)`
  `void`
  `setInstanceId(String instanceId)`
  `void`
  `setLabel(String label)`
  `void`
  `setNbVoters(int nbVoters)`
  `void`
  `setOpened(boolean opened)`
  `void`
  `setQuestionId(String questionId)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AnswerEntity

    protected AnswerEntity()

- ## Method Details

  - ### asWebEntity

    public static AnswerEntity asWebEntity(org.silverpeas.core.questioncontainer.answer.model.Answer answer)
    Gets the `AnswerEntity` instance from given `Answer` one.
    Parameters:
      `answer` - the answer model to get into WEB entity representation.
    Returns:
      an `AnswerEntity` instance.

  - ### normalizeImageUrl

    public static Optional<String> normalizeImageUrl(String instanceId, String imageUrl)
    Normalizes the image URL of an answer. This method does not take into parameters directly an `Answer` instance in order to be used in context of survey creation. In a such context, `Answer` data are not safe.
    Parameters:
      `instanceId` - the identifier of the survey component instance.
      `imageUrl` - the URL of the image linked to an answer.
    Returns:
      an optional normalized URL.

  - ### getId

    public String getId()
    Gets the identifier of the answer.
    Returns:
      a string identifier.

  - ### setId

    public void setId(String id)

  - ### getInstanceId

    public String getInstanceId()
    Gets the identifier of the survey component instance hosting the answer.
    Returns:
      a string identifier.

  - ### setInstanceId

    public void setInstanceId(String instanceId)

  - ### getQuestionId

    public String getQuestionId()
    Gets the identifier of the question the answer is linked to.
    Returns:
      a string identifier.

  - ### setQuestionId

    public void setQuestionId(String questionId)

  - ### getLabel

    public String getLabel()
    Gets the label of the answer.
    Returns:
      a string.

  - ### setLabel

    public void setLabel(String label)

  - ### isOpened

    public boolean isOpened()
    Indicates if the answer is an opened one.
    Returns:
      true if opened, false otherwise.

  - ### setOpened

    public void setOpened(boolean opened)

  - ### getNbVoters

    public int getNbVoters()
    Gets the number of voters who choose the answer.
    Returns:
      an integer.

  - ### setNbVoters

    public void setNbVoters(int nbVoters)

  - ### getImageUrl

    public String getImageUrl()
    Gets the URL of a linked image if any.
    Returns:
      a string if any, null or empty otherwise.

  - ### setImageUrl

    public void setImageUrl(String imageUrl)

  - ### getURI

    public URI getURI()
    Specified by:
      `getURI` in interface `org.silverpeas.core.web.rs.WebEntity`