Package nzilbb.labbcat
Class Response
java.lang.Object
nzilbb.labbcat.Response
A class representing the JSON response of a LaBB-CAT request.
- Author:
- Robert Fromont robert@fromont.net.nz
-
Constructor Summary
ConstructorsConstructorDescriptionResponse()
Default constructor.Response
(InputStream input) Constructor from InputStream.Response
(InputStream input, boolean verbose) Constructor from InputStream.Response
(HttpURLConnection connection, boolean verbose) Constructor from HttpURLConnection. -
Method Summary
Modifier and TypeMethodDescriptionConvenience method for checking whether the response any errors.int
getCode()
Getter forcode
: The request code.Getter forerrors
: Errors returned.int
Getter forhttpStatus
: The HTTP status code, or -1 if not known.Getter formessages
: Messages returned.getModel()
Getter formodel
: The model or result returned.getRaw()
Getter forraw
: Raw response text.getTitle()
Getter fortitle
: Server title.boolean
Getter forverbose
: Whether to print verbose output or not.Getter forversion
: Server version.boolean
Determines whether the model is null.load
(InputStream input) Loads the response from the given stream.Loads the response from the given stream.Setter formodel
: The model or result returned.setVersion
(String newVersion) Setter forversion
: Server version.
-
Constructor Details
-
Response
public Response()Default constructor. -
Response
Constructor from InputStream.- Parameters:
input
- The stream to read from.- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation.
-
Response
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
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 forhttpStatus
: The HTTP status code, or -1 if not known.- Returns:
- The HTTP status code, or -1 if not known.
-
getTitle
Getter fortitle
: Server title.- Returns:
- Server title.
-
getVersion
Getter forversion
: Server version.- Returns:
- Server version.
-
setVersion
Setter forversion
: Server version.- Parameters:
newVersion
- Server version.- Returns:
- A reference to this object, so that setters can be chained.
-
getCode
public int getCode()Getter forcode
: The request code.- Returns:
- The request code.
-
getErrors
Getter forerrors
: Errors returned.- Returns:
- Errors returned.
-
getMessages
Getter formessages
: Messages returned.- Returns:
- Messages returned.
-
getModel
Getter formodel
: The model or result returned.- Returns:
- The model or result returned.
-
setModel
Setter formodel
: 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
Getter forraw
: Raw response text.- Returns:
- Raw response text.
-
getVerbose
public boolean getVerbose()Getter forverbose
: Whether to print verbose output or not.- Returns:
- Whether to print verbose output or not.
-
load
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
Loads the response from the given stream.- Parameters:
text
- The raw text of the response.- Returns:
- A reference to this object,
-
checkForErrors
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.
-