Package nzilbb.labbcat
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 Summary
Constructors Constructor Description Response()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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponsecheckForErrors()Convenience method for checking whether the response any errors.intgetCode()Getter forcode: The request code.Vector<String>getErrors()Getter forerrors: Errors returned.intgetHttpStatus()Getter forhttpStatus: The HTTP status code, or -1 if not known.Vector<String>getMessages()Getter formessages: Messages returned.ObjectgetModel()Getter formodel: The model or result returned.StringgetRaw()Getter forraw: Raw response text.StringgetTitle()Getter fortitle: Server title.booleangetVerbose()Getter forverbose: Whether to print verbose output or not.StringgetVersion()Getter forversion: Server version.booleanisModelNull()Determines whether the model is null.Responseload(InputStream input)Loads the response from the given stream.Responseload(String text)Loads the response from the given stream.ResponsesetModel(Object newModel)Setter formodel: The model or result returned.ResponsesetVersion(String newVersion)Setter forversion: Server version.
-
-
-
Constructor Detail
-
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 Detail
-
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
public String getTitle()
Getter fortitle: Server title.- Returns:
- Server title.
-
getVersion
public String getVersion()
Getter forversion: Server version.- Returns:
- Server version.
-
setVersion
public Response setVersion(String newVersion)
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
public Vector<String> getErrors()
Getter forerrors: Errors returned.- Returns:
- Errors returned.
-
getMessages
public Vector<String> getMessages()
Getter formessages: Messages returned.- Returns:
- Messages returned.
-
getModel
public Object getModel()
Getter formodel: The model or result returned.- Returns:
- The model or result returned.
-
setModel
public Response setModel(Object newModel)
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
public String 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
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.
-
-