Class Message
java.lang.Object
edu.uky.cs.nil.tt.io.Message
- All Implemented Interfaces:
Timestamped
A message is information sent to or from a
server in JSON format.- Author:
- Stephen G. Ware
-
Nested Class Summary
Nested classes/interfaces inherited from interface Timestamped
Timestamped.Adapter -
Field Summary
Fields inherited from interface Timestamped
FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigure(com.google.gson.GsonBuilder builder) Configures aGsonBuilderto encode and decodeMessageobjects as JSON.getAgent()Returns theAgentwho sent this message, or null if this message was sent by the server.longReturns the time this object was created as the number of milliseconds from the epoch (1970-01-01T00:00:00Z) in Coordinated Universal Time (UTC).voidSets theAgentwho sent this message.voidverify()Checks that this message is correctly configured and throws an exception if not.
-
Constructor Details
-
Message
public Message()Constructs a message.
-
-
Method Details
-
configure
public static void configure(com.google.gson.GsonBuilder builder) Configures aGsonBuilderto encode and decodeMessageobjects as JSON.- Parameters:
builder- the GSON builder to configure
-
getAgent
-
setAgent
-
getTimestamp
public long getTimestamp()Description copied from interface:TimestampedReturns the time this object was created as the number of milliseconds from the epoch (1970-01-01T00:00:00Z) in Coordinated Universal Time (UTC).- Specified by:
getTimestampin interfaceTimestamped- Returns:
- the object's timestamp in milliseconds from the epoch in UTC
-
verify
public void verify()Checks that this message is correctly configured and throws an exception if not. This method should be called soon after the message has been parsed. It should check that all the necessary fields are set and that their values are legal values.
-