Package net.dona.doip.server
Interface DoipServerResponse
- All Known Implementing Classes:
DoipServerResponseImpl
public interface DoipServerResponse
Interface for an outgoing DOIP response to be populated by a
DoipProcessor.
The initial segment of the response is a JSON segment with a status code and attributes.
The DoipProcessor can set those until the initial segment is "committed", that is,
sent to the client. The initial segment can be committed manually with a call to commit(),
and will be committed automatically when either writeCompactOutput(JsonElement) or
getOutput() is called.-
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Ensure that the initial segment has been sent to the client.com.google.gson.JsonObjectReturns the entire collection of attributes in the initial segment of the DOIP response.Get anOutDoipMessagefor writing output segments to the client.Returns the status code in the initial segment of the DOIP response.voidsetAttribute(String key, com.google.gson.JsonElement value) Set a single attribute in the initial segment of the response.voidsetAttribute(String key, String value) Set (as a String) a single attribute in the initial segment of the response.voidsetAttributes(com.google.gson.JsonObject attributes) Set the entire collection of attributes in the initial segment of the response.voidSets the status code in the initial segment of the response.voidwriteCompactOutput(com.google.gson.JsonElement output) Write a "compact" single-segment output.
-
Method Details
-
setStatus
Sets the status code in the initial segment of the response.- Parameters:
status- the status code
-
getStatus
String getStatus()Returns the status code in the initial segment of the DOIP response.- Returns:
- the status code in the initial segment of the DOIP response
-
setAttribute
Set a single attribute in the initial segment of the response.- Parameters:
key- the attribute to setvalue- the value of the attribute to be set
-
setAttribute
Set (as a String) a single attribute in the initial segment of the response.- Parameters:
key- the attribute to setvalue- the value of the attribute to be set
-
setAttributes
void setAttributes(com.google.gson.JsonObject attributes) Set the entire collection of attributes in the initial segment of the response.- Parameters:
attributes- the new value of the entire attributes collection
-
getAttributes
com.google.gson.JsonObject getAttributes()Returns the entire collection of attributes in the initial segment of the DOIP response.- Returns:
- the entire collection of attributes in the initial segment of the DOIP response
-
commit
Ensure that the initial segment has been sent to the client.- Throws:
IOException
-
writeCompactOutput
Write a "compact" single-segment output. The output is supplied as an "output" property in the JSON of the single segment sent to the client.- Parameters:
output- the output JSON- Throws:
IOException
-
getOutput
Get anOutDoipMessagefor writing output segments to the client. This is used for a non-compact output containing multiple segments. This will commit the initial segment, so it will no longer be possible to change the status code or attributes.- Returns:
- an OutDoipMessage for writing output segments.
- Throws:
IOException
-