Package jmri.server.json.message
Class JsonMessage
java.lang.Object
jmri.server.json.message.JsonMessage
A message to be sent by the JMRI JSON message service.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJsonMessage(String message, Locale locale) Create a message with anJsonMessage.TYPE.INFOtype to be sent to all JSON clients.JsonMessage(JsonMessage.TYPE type, String message, String client, com.fasterxml.jackson.databind.JsonNode context, Locale locale) Create a message to be sent to the specified JSON client with the specified context.JsonMessage(JsonMessage.TYPE type, String message, String client, Locale locale) Create a message to be sent to the specified JSON client.JsonMessage(JsonMessage.TYPE type, String message, Locale locale) Create a message to be sent to all JSON clients. -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodegetType()Get the JSON token for each of the message types used in the constructors.voidsend()Send the message using the defaultJsonMessageClientManager.com.fasterxml.jackson.databind.JsonNodetoJSON(com.fasterxml.jackson.databind.ObjectMapper mapper) Create a JSON node from this message.
-
Field Details
-
CLIENT
"client"- See Also:
-
MESSAGE
"message"- See Also:
-
CONTEXT
"context"- See Also:
-
-
Constructor Details
-
JsonMessage
Create a message with anJsonMessage.TYPE.INFOtype to be sent to all JSON clients.- Parameters:
message- the message to sendlocale- the locale of the message
-
JsonMessage
Create a message to be sent to all JSON clients.- Parameters:
type- the message typemessage- the message to sendlocale- the locale of the message
-
JsonMessage
public JsonMessage(JsonMessage.TYPE type, @Nonnull String message, @CheckForNull String client, @Nonnull Locale locale) Create a message to be sent to the specified JSON client.- Parameters:
type- the message typemessage- the message to sendclient- the client to send the message to; if null, the message is sent to all clientslocale- the locale of the message
-
JsonMessage
public JsonMessage(JsonMessage.TYPE type, @Nonnull String message, @CheckForNull String client, @CheckForNull com.fasterxml.jackson.databind.JsonNode context, @Nonnull Locale locale) Create a message to be sent to the specified JSON client with the specified context.- Parameters:
type- the message typemessage- the message to sendclient- the client to send the message to; if null, the message is sent to all clientscontext- the context for the message; if null, no context is sentlocale- the locale of the message
-
-
Method Details
-
send
Send the message using the defaultJsonMessageClientManager.To send a message to an alternate JsonMessageClientManager, call that manager's
JsonMessageClientManager.send(jmri.server.json.message.JsonMessage)method. -
getClient
-
getContext
-
getMessage
-
getLocale
-
getType
Get the JSON token for each of the message types used in the constructors.- Returns:
- the token value
-
toJSON
public com.fasterxml.jackson.databind.JsonNode toJSON(com.fasterxml.jackson.databind.ObjectMapper mapper) Create a JSON node from this message.- Parameters:
mapper- the instance used to create raw JSON nodes- Returns:
- the JSON node
-