Class ClientAnswer

java.lang.Object
ch.autumo.beetroot.server.message.AbstractMessage
ch.autumo.beetroot.server.message.ClientAnswer
Direct Known Subclasses:
FileAnswer, HealthAnswer, StopAnswer

public class ClientAnswer extends AbstractMessage
Client answer.
  • Field Details

  • Constructor Details

    • ClientAnswer

      public ClientAnswer()
      Client answer.
    • ClientAnswer

      public ClientAnswer(int type)
      Client answer.
      Parameters:
      type - type
    • ClientAnswer

      public ClientAnswer(String answer)
      Client answer. The answer can have parts, separated by '|'.
      Parameters:
      answer - answer
    • ClientAnswer

      public ClientAnswer(String answer, int type)
      Client answer. The answer can have parts, separated by '|'.
      Parameters:
      answer - answer
      type - type
    • ClientAnswer

      public ClientAnswer(String answer, String fileId)
      Client answer. The answer can have parts, separated by '|'.
      Parameters:
      answer - answer
      fileId - file ID of uploaded file generated by a file server
    • ClientAnswer

      public ClientAnswer(String answer, String entity, long id)
      Client answer. The answer can have parts, separated by '|'.
      Parameters:
      answer - answer
      entity - entity name of served/looked-up entity
      id - id name of served/looked-up entity
    • ClientAnswer

      public ClientAnswer(int type, String answer, String entity, long id, String errorReason)
      Client answer. The answer can have parts, separated by '|'.
      Parameters:
      type - type
      answer - answer
      entity - entity name of served/looked-up entity
      id - id name of served/looked-up entity
      errorReason - if there's an error
  • Method Details

    • getType

      public int getType()
      Get client answer type.
      Returns:
      type
    • getAnswer

      public String getAnswer()
      Get answer, possibly holds message parts separated by '|'.
      Returns:
      answer
    • getErrorReason

      public String getErrorReason()
      Get error reason if any.
      Returns:
      error reason
    • getTransferString

      public String getTransferString() throws IOException
      Description copied from class: AbstractMessage
      Get transfer string; this includes all set information including the additional object is set.
      Specified by:
      getTransferString in class AbstractMessage
      Returns:
      transfer string
      Throws:
      IOException - IO exception
    • parse

      public static ClientAnswer parse(String transferString) throws IOException
      Create a new client answer out of transfer string.
      Parameters:
      transferString - transfer string
      Returns:
      parsed client answer command
      Throws:
      IOException - IO exception
    • getJsonTransferString

      public String getJsonTransferString() throws IOException
      Description copied from class: AbstractMessage
      Get JSON representation; this includes all set information including the additional object if set.
      Specified by:
      getJsonTransferString in class AbstractMessage
      Returns:
      transfer JSON string
      Throws:
      IOException - IO exception
    • parseJson

      public static ClientAnswer parseJson(String transferString) throws IOException
      Create a new client answer out of JSON transfer string.
      Parameters:
      transferString - JSON transfer string
      Returns:
      parsed client answer
      Throws:
      IOException - IO exception