Class ClientAnswer
java.lang.Object
ch.autumo.beetroot.server.message.AbstractMessage
ch.autumo.beetroot.server.message.ClientAnswer
- Direct Known Subclasses:
FileAnswer, HealthAnswer, StopAnswer
Client answer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAnswer type: error.static final intAnswer type: file transfer failed.static final intAnswer type: file transfer OK.static final intAnswer type: OK.Fields inherited from class AbstractMessage
domain, ENCRYPT, entity, fileId, id, INTERNAL_MSG_PART_SEPARATOR, INTERNAL_MSG_PART_SEPARATOR_REGEXP, LOG, message, MSG_PART_SEPARATOR, MSG_PART_SEPARATOR_REGEXP, object, serverNameModifier and TypeFieldDescriptionprotected StringTransport domain name.protected static final booleanEncrypt client-server-com?protected StringTransport entity name.protected StringTransport file ID.protected longTransport entity ID.static final Stringinternal message part separatorstatic final Stringinternal message part separator regular expressionprotected static final org.slf4j.LoggerLogger.protected StringTransport message.static final Stringmessage part separatorstatic final Stringmessage part separator regular expressionprotected SerializableAdditional transport object.static Stringserver name -
Constructor Summary
ConstructorsConstructorDescriptionClient answer.ClientAnswer(int type) Client answer.ClientAnswer(int type, String answer, String entity, long id, String errorReason) Client answer.ClientAnswer(String answer) Client answer.ClientAnswer(String answer, int type) Client answer.ClientAnswer(String answer, String fileId) Client answer.ClientAnswer(String answer, String entity, long id) Client answer. -
Method Summary
Modifier and TypeMethodDescriptionGet answer, possibly holds message parts separated by '|'.Get error reason if any.Get JSON representation; this includes all set information including the additional object if set.Get transfer string; this includes all set information including the additional object is set.intgetType()Get client answer type.static ClientAnswerCreate a new client answer out of transfer string.static ClientAnswerCreate a new client answer out of JSON transfer string.Methods inherited from class AbstractMessage
contains, deserializeObject, getData, getDataLength, getDomain, getEntity, getFileId, getId, getJSONObject, getMessageIntValue, getMessageValue, getObject, serializeObject, setEntity, setObjectModifier and TypeMethodDescriptionbooleanChecks if this key is contained in a paired transport message.protected voiddeserializeObject(String serializedObject) Deserialize this object with FasterXML/Jackson.byte[]getData()Get transfer data; this includes all set information including an object.intGet transfer data length.Get a domain associated with this message or null.Get entity associated with this message or null.File ID if this message is used to transport file information.longgetId()Get entity ID associated with this message or null.org.json.JSONObjectReturn a JSON object or null; null means the object hold by this message represents another object type, but it is always serializable.intgetMessageIntValue(String key) Helper method for accessing paired transport message values.getMessageValue(String key) Helper method for accessing paired transport message values.Get serializable transport object hold by this message or null.protected StringSerialize this object with FasterXML/Jackson.voidSet an entity associated with this message.voidsetObject(Serializable object) Set any serializable object, usually a JSON string is meaningful for transport.
-
Field Details
-
TYPE_OK
public static final int TYPE_OKAnswer type: OK.- See Also:
-
TYPE_FILE_OK
public static final int TYPE_FILE_OKAnswer type: file transfer OK.- See Also:
-
TYPE_FILE_NOK
public static final int TYPE_FILE_NOKAnswer type: file transfer failed.- See Also:
-
TYPE_ERROR
public static final int TYPE_ERRORAnswer type: error.- See Also:
-
-
Constructor Details
-
ClientAnswer
public ClientAnswer()Client answer. -
ClientAnswer
public ClientAnswer(int type) Client answer.- Parameters:
type- type
-
ClientAnswer
Client answer. The answer can have parts, separated by '|'.- Parameters:
answer- answer
-
ClientAnswer
Client answer. The answer can have parts, separated by '|'.- Parameters:
answer- answertype- type
-
ClientAnswer
-
ClientAnswer
-
ClientAnswer
Client answer. The answer can have parts, separated by '|'.- Parameters:
type- typeanswer- answerentity- entity name of served/looked-up entityid- id name of served/looked-up entityerrorReason- if there's an error
-
-
Method Details
-
getType
public int getType()Get client answer type.- Returns:
- type
-
getAnswer
Get answer, possibly holds message parts separated by '|'.- Returns:
- answer
-
getErrorReason
-
getTransferString
Description copied from class:AbstractMessageGet transfer string; this includes all set information including the additional object is set.- Specified by:
getTransferStringin classAbstractMessage- Returns:
- transfer string
- Throws:
IOException- IO exception
-
parse
Create a new client answer out of transfer string.- Parameters:
transferString- transfer string- Returns:
- parsed client answer command
- Throws:
IOException- IO exception
-
getJsonTransferString
Description copied from class:AbstractMessageGet JSON representation; this includes all set information including the additional object if set.- Specified by:
getJsonTransferStringin classAbstractMessage- Returns:
- transfer JSON string
- Throws:
IOException- IO exception
-
parseJson
Create a new client answer out of JSON transfer string.- Parameters:
transferString- JSON transfer string- Returns:
- parsed client answer
- Throws:
IOException- IO exception
-