Class Response

java.lang.Object
nzilbb.labbcat.Response

public class Response extends Object
A class representing the JSON response of a LaBB-CAT request.
Author:
Robert Fromont robert@fromont.net.nz
  • Constructor Details

    • Response

      public Response()
      Default constructor.
    • Response

      public Response(InputStream input) throws nzilbb.ag.StoreException
      Constructor from InputStream.
      Parameters:
      input - The stream to read from.
      Throws:
      nzilbb.ag.StoreException - If an error prevents the operation.
    • Response

      public Response(InputStream input, boolean verbose) throws nzilbb.ag.StoreException
      Constructor from InputStream.
      Parameters:
      input - The stream to read from.
      verbose - The verbosity setting to use.
      Throws:
      nzilbb.ag.StoreException - If an error prevents the operation.
    • Response

      public Response(HttpURLConnection connection, boolean verbose) throws nzilbb.ag.StoreException
      Constructor from HttpURLConnection.
      Parameters:
      connection - The connection to read from.
      verbose - The verbosity setting to use.
      Throws:
      nzilbb.ag.StoreException - If an error prevents the operation.
  • Method Details

    • getHttpStatus

      public int getHttpStatus()
      Getter for httpStatus: The HTTP status code, or -1 if not known.
      Returns:
      The HTTP status code, or -1 if not known.
    • getTitle

      public String getTitle()
      Getter for title: Server title.
      Returns:
      Server title.
    • getVersion

      public String getVersion()
      Getter for version: Server version.
      Returns:
      Server version.
    • setVersion

      public Response setVersion(String newVersion)
      Setter for version: Server version.
      Parameters:
      newVersion - Server version.
      Returns:
      A reference to this object, so that setters can be chained.
    • getCode

      public int getCode()
      Getter for code: The request code.
      Returns:
      The request code.
    • getErrors

      public Vector<String> getErrors()
      Getter for errors: Errors returned.
      Returns:
      Errors returned.
    • getMessages

      public Vector<String> getMessages()
      Getter for messages: Messages returned.
      Returns:
      Messages returned.
    • getModel

      public Object getModel()
      Getter for model: The model or result returned.
      Returns:
      The model or result returned.
    • setModel

      public Response setModel(Object newModel)
      Setter for model: The model or result returned.
      Parameters:
      newModel - The model or result returned.
      Returns:
      A reference to this object, so that setters can be chained.
    • getRaw

      public String getRaw()
      Getter for raw: Raw response text.
      Returns:
      Raw response text.
    • getVerbose

      public boolean getVerbose()
      Getter for verbose: Whether to print verbose output or not.
      Returns:
      Whether to print verbose output or not.
    • load

      public Response load(InputStream input) throws IOException
      Loads the response from the given stream.
      Parameters:
      input - The stream to read from.
      Returns:
      A reference to this object,
      Throws:
      IOException - If an IO error occurs.
    • load

      public Response load(String text)
      Loads the response from the given stream.
      Parameters:
      text - The raw text of the response.
      Returns:
      A reference to this object,
    • checkForErrors

      public Response checkForErrors() throws ResponseException
      Convenience method for checking whether the response any errors. If so, a corresponding StoreException will be thrown.
      Returns:
      A reference to this object,
      Throws:
      ResponseException - If an error prevents the operation.
    • isModelNull

      public boolean isModelNull()
      Determines whether the model is null.
      Returns:
      true if the model returned is null, false otherwise.