Package net.dona.doip.server
Interface DoipServerResponse
-
- All Known Implementing Classes:
DoipServerResponseImpl
public interface DoipServerResponseInterface for an outgoing DOIP response to be populated by aDoipProcessor. The initial segment of the response is a JSON segment with a status code and attributes. TheDoipProcessorcan set those until the initial segment is "committed", that is, sent to the client. The initial segment can be committed manually with a call tocommit(), and will be committed automatically when eitherwriteCompactOutput(JsonElement)orgetOutput()is called.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcommit()Ensure that the initial segment has been sent to the client.OutDoipMessagegetOutput()Get anOutDoipMessagefor writing output segments to the client.voidsetAttribute(java.lang.String key, com.google.gson.JsonElement value)Set a single attribute in the initial segment of the response.voidsetAttribute(java.lang.String key, java.lang.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.voidsetStatus(java.lang.String status)Sets the status code in the initial segment of the response.voidwriteCompactOutput(com.google.gson.JsonElement output)Write a "compact" single-segment output.
-
-
-
Method Detail
-
setStatus
void setStatus(java.lang.String status)
Sets the status code in the initial segment of the response.- Parameters:
status- the status code
-
setAttribute
void setAttribute(java.lang.String key, com.google.gson.JsonElement value)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
void setAttribute(java.lang.String key, java.lang.String value)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
-
commit
void commit() throws java.io.IOExceptionEnsure that the initial segment has been sent to the client.- Throws:
java.io.IOException
-
writeCompactOutput
void writeCompactOutput(com.google.gson.JsonElement output) throws java.io.IOExceptionWrite 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:
java.io.IOException
-
getOutput
OutDoipMessage getOutput() throws java.io.IOException
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:
java.io.IOException
-
-