public abstract class JSONPacket
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PACKET_TYPE
JSON key for the integer packet type.
|
protected int |
type |
Constructor and Description |
---|
JSONPacket(IntegerPacketType t) |
JSONPacket(org.json.JSONObject json) |
Modifier and Type | Method and Description |
---|---|
static boolean |
couldBeJSON(byte[] bytes) |
static boolean |
couldBeJSON(byte[] bytes,
int offset) |
static boolean |
couldBeJSON(java.lang.String str) |
static boolean |
couldBeJSONArray(java.lang.String str) |
static boolean |
couldBeJSONObject(java.lang.String str) |
static java.lang.Integer |
getPacketType(org.json.JSONObject json) |
static void |
putPacketType(org.json.JSONObject json,
int type)
Puts type into json.
|
static void |
putPacketType(org.json.JSONObject json,
IntegerPacketType type)
Puts type.getInt() into json.
|
org.json.JSONObject |
toJSONObject() |
protected abstract org.json.JSONObject |
toJSONObjectImpl() |
java.lang.String |
toString() |
public static final java.lang.String PACKET_TYPE
protected int type
public JSONPacket(IntegerPacketType t)
t
- public JSONPacket(org.json.JSONObject json) throws org.json.JSONException
json
- org.json.JSONException
protected abstract org.json.JSONObject toJSONObjectImpl() throws org.json.JSONException
org.json.JSONException
public org.json.JSONObject toJSONObject() throws org.json.JSONException
org.json.JSONException
public java.lang.String toString()
toString
in class java.lang.Object
public static final java.lang.Integer getPacketType(org.json.JSONObject json) throws org.json.JSONException
json
- org.json.JSONException
public static final void putPacketType(org.json.JSONObject json, int type)
json
- type
- public static final void putPacketType(org.json.JSONObject json, IntegerPacketType type)
json
- type
- public static final boolean couldBeJSON(java.lang.String str)
str
- str
could possibly (but not necessarily) be in
JSON format. This sanity check is quicker compared to taking a
JSONException hit.public static final boolean couldBeJSONObject(java.lang.String str)
str
- public static final boolean couldBeJSONArray(java.lang.String str)
str
- public static final boolean couldBeJSON(byte[] bytes)
bytes
- bytes
could be possibly (but not
necessarily) be in JSON format assuming the default
MessageExtractor
encoding.public static final boolean couldBeJSON(byte[] bytes, int offset)
bytes
- offset
- bytes
could be possibly (but not
necessarily) be in JSON format assuming the default
MessageExtractor
encoding.