|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmythapi.protocol.utils.PacketUtils
public class PacketUtils
This class provides MythTV-packet related utility function.
// write a packet to the output stream IMythPacket resp = sendableObj.getPacket(); PacketUtils.writeTo(req, this.socketOutputStream); // read the response packet from the input stream IMythPacket resp = PacketUtils.readFrom(protoVersion, this.socketInputStream);
writeTo
is used.
To read the response-packet from the stream function readFrom
is used.
IMythPacket
Field Summary | |
---|---|
static String |
DELIM_REGEXP
A regular expression used to split packet arguments when receiving them over network. |
static int |
SIZE_STRING_LENGTH
The length of the size string of a packet. |
Method Summary | |
---|---|
static String |
formatPayloadSizeString(int size)
Generates the payload-size string. |
static IMythPacket |
readFrom(ProtocolVersion protoVersion,
InputStream input)
Reads a MythTV-packet from an input-stream. |
static IMythPacket |
readFrom(ProtocolVersion protoVersion,
String inputString)
Reads a MythTV-packet from a string. |
static int |
readPayloadSize(InputStream input)
|
static ArrayList<String> |
split(String data)
Converts an MythTV data-line into a list of arguments. |
static void |
writeTo(IMythPacket packet,
OutputStream output)
Writes a MythTV-packet to an output-stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SIZE_STRING_LENGTH
public static final String DELIM_REGEXP
Method Detail |
---|
public static ArrayList<String> split(String data)
E.g. "1002[]:[]224[]:[]853[]:[]853
" will be converted to [1002,224,853,853]
.
data
- the data-string that should be parsed.
public static final IMythPacket readFrom(ProtocolVersion protoVersion, String inputString) throws IOException
protoVersion
- the protocol version of the packetinputString
- the string representing the packet, e.g. "13 2[]:[]4[]:[]6
".
IOException
- on communication errorspublic static final IMythPacket readFrom(ProtocolVersion protoVersion, InputStream input) throws IOException
protoVersion
- the protocol version of the packetinput
- the input stream containing the packet data
IOException
- on communication errorspublic static final int readPayloadSize(InputStream input) throws IOException
IOException
public static final void writeTo(IMythPacket packet, OutputStream output) throws IOException
packet
- the packet that should be written to the stream.output
- the output-stream to write the date to.
IOException
- on communication errorspublic static final String formatPayloadSizeString(int size)
size
- the size of the payload
13
"
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |