Class 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 Detail

      • AnswerEntity

        protected AnswerEntity()
    • Method Detail

      • 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