Class EUA

java.lang.Object
fr.inria.rules.integraal.api.external.eua.EUA

public class EUA extends Object
Represents a standardized JSON-based response object intended for end-user communication.

The EUA (End User Answer) class wraps a JSON structure that contains:

  • result – a numeric status code (usually from EUACode)
  • message – a human-readable message or payload
  • data – a nested JSON object for additional key-value data

This structure is useful for APIs, services, or UI-layer responses where a consistent, structured format is required for both humans and machines to interpret.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON key for the result code.
    static final String
    JSON key for the data section.
    static final String
    JSON key for the message.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EUA(EUACode code, String message)
    Constructs a new EUA response object.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(EUAData key, Object value)
    Adds a key-value pair to the internal data section of the JSON response.
    Returns the enumerated result code stored in this EUA.
    org.json.JSONObject
    Returns the data object stored in this EUA.
    Returns a data field stored under the given key.
    Returns the human-readable message stored in this EUA.
    int
    Returns the numeric result code stored in this EUA.
    static void
    main(String[] args)
    Temporary entry point for development and internal testing purposes only.
    static EUA
    parse(String jsonString)
    Builds an EUA object from its corresponding JSON String
    Returns the full JSON representation of this response as a string.
    Returns the JSON string representation of this response.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • EUA

      public EUA(EUACode code, String message) throws NullPointerException
      Constructs a new EUA response object.

      Initializes the internal JSON structure with a result code, a message intended for the end user, and an empty data object to which key-value pairs can be added later.

      Parameters:
      code - an EUACode instance representing the result status
      message - a human-readable message for the end user; must not be null
      Throws:
      NullPointerException - if code or message is null
  • Method Details

    • getResult

      public int getResult()
      Returns the numeric result code stored in this EUA.
      Returns:
      the numeric result code
    • getCode

      public EUACode getCode()
      Returns the enumerated result code stored in this EUA.
      Returns:
      the result code as an enum value
    • getMessage

      public String getMessage()
      Returns the human-readable message stored in this EUA.
      Returns:
      the message
    • getData

      public org.json.JSONObject getData()
      Returns the data object stored in this EUA.
      Returns:
      the data object
    • getDataField

      public Object getDataField(EUAData name)
      Returns a data field stored under the given key.
      Parameters:
      name - the data field key
      Returns:
      the stored field value
    • add

      public EUA add(EUAData key, Object value) throws org.json.JSONException, NullPointerException
      Adds a key-value pair to the internal data section of the JSON response. If the value is null, it is converted to JSONObject.NULL.
      Parameters:
      key - the name of the field to add
      value - the value to associate with the key; may be null
      Returns:
      this EUA instance
      Throws:
      org.json.JSONException - if the value is of an unsupported type (e.g., NaN, Infinity)
      NullPointerException - if the key is null
    • toJsonString

      public String toJsonString()
      Returns the full JSON representation of this response as a string.
      Returns:
      the serialized JSON string
    • toString

      public String toString()
      Returns the JSON string representation of this response. Equivalent to toJsonString().
      Overrides:
      toString in class Object
      Returns:
      the stringified JSON content
    • parse

      public static EUA parse(String jsonString) throws org.json.JSONException
      Builds an EUA object from its corresponding JSON String
      Parameters:
      jsonString - a JSON String representation of an EUA object
      Returns:
      the parsed EUA object
      Throws:
      org.json.JSONException - If the string is not valid JSON or if required keys are missing
      IllegalArgumentException - If the result code is unknown
    • main

      public static void main(String[] args)
      Temporary entry point for development and internal testing purposes only.

      This method is intended to facilitate quick, manual checks during development. It should not be used in production code, nor relied upon for automated testing.

      May be modified or removed at any time without notice.

      Parameters:
      args - command-line arguments (not used)