Class JsonResult

java.lang.Object
io.milton.common.JsonResult

public class JsonResult extends Object
Value object holding the result of some operation in a generic form which is suitable for outputting as JSON.
  • Field Details

    • CONTENT_TYPE

      public static String CONTENT_TYPE
  • Constructor Details

    • JsonResult

      public JsonResult()
    • JsonResult

      public JsonResult(boolean status, String nextHref, List<String> messages, List<JsonResult.FieldMessage> fieldMessages)
    • JsonResult

      public JsonResult(boolean status)
    • JsonResult

      public JsonResult(boolean status, String message)
    • JsonResult

      public JsonResult(boolean status, String message, String nextHref)
  • Method Details

    • error

      public static JsonResult error(String description)
    • fieldError

      public static JsonResult fieldError(String field, String fieldMessage)
    • returnData

      public static JsonResult returnData(String href, Object data)
    • returnData

      public static JsonResult returnData(Object data)
    • addFieldMessage

      public void addFieldMessage(String field, String message)
    • isStatus

      public boolean isStatus()
      Flag to indicate success or failure of the operation
      Returns:
      the status
    • setStatus

      public void setStatus(boolean status)
      Parameters:
      status - the status to set
    • getNextHref

      public String getNextHref()
      If an object was created this should be the href of that object. If the operation completed was part of a workflow then this should be the href of the next step in the workflow
      Returns:
      the nextHref
    • setNextHref

      public void setNextHref(String nextHref)
      Parameters:
      nextHref - the nextHref to set
    • getMessages

      public List<String> getMessages()
      Any messages which are not specific to certain fields
      Returns:
      the messages
    • setMessages

      public void setMessages(List<String> messages)
      Parameters:
      messages - the messages to set
    • getFieldMessages

      public List<JsonResult.FieldMessage> getFieldMessages()
      List of messages relating to specific fields. The field name must correspond to a POST variable name
      Returns:
      the fieldMessages
    • setFieldMessages

      public void setFieldMessages(List<JsonResult.FieldMessage> fieldMessages)
      Parameters:
      fieldMessages - the fieldMessages to set
    • getData

      public Object getData()
      Any JSON friendly object
      Returns:
    • setData

      public void setData(Object data)