com.ramblingwood.minecraft.jsonapi.api
Class JSONAPIStreamMessage

java.lang.Object
  extended by com.ramblingwood.minecraft.jsonapi.api.JSONAPIStreamMessage
All Implemented Interfaces:
org.json.simpleForBukkit.JSONAware

public abstract class JSONAPIStreamMessage
extends java.lang.Object
implements org.json.simpleForBukkit.JSONAware

This class will need to be subcalled to provide meaningful data. By default, there are just some convenience methods. It is recommended that you call "setTime()" in your constructor to make sure the timestamp is as accurate as possible.

Author:
alecgorge

Constructor Summary
JSONAPIStreamMessage()
           
 
Method Summary
 long getTime()
          If setTime was previously called, returns the value setTime set.
 void setTime()
          Takes a timestamp of the current time and stores it for usage later when the JSONObject is being created.
 void setTime(long time)
           
abstract  java.lang.String streamName()
          This return value of this method should be the same as the name of the stream when register it with JSONAPI.
abstract  org.json.simpleForBukkit.JSONObject toJSONObject()
          Returns an org.json.simpleForBukkit.JSONObject that is a JSON representation of the data in this class.
 java.lang.String toJSONString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONAPIStreamMessage

public JSONAPIStreamMessage()
Method Detail

streamName

public abstract java.lang.String streamName()
This return value of this method should be the same as the name of the stream when register it with JSONAPI.

Returns:
the stream name

setTime

public void setTime(long time)

getTime

public long getTime()
If setTime was previously called, returns the value setTime set. Otherwise, calls setTime and returns the value.

Returns:
The timestamp store.

setTime

public void setTime()
Takes a timestamp of the current time and stores it for usage later when the JSONObject is being created.


toJSONObject

public abstract org.json.simpleForBukkit.JSONObject toJSONObject()
Returns an org.json.simpleForBukkit.JSONObject that is a JSON representation of the data in this class. Example: JSONObject o = new JSONObject(); o.put("time", getTime()); o.put("player", getPlayer()); o.put("message", getMessage()); return o;

Returns:

toJSONString

public java.lang.String toJSONString()
Specified by:
toJSONString in interface org.json.simpleForBukkit.JSONAware
Returns:
JSON text