org.jmythapi.protocol.utils
Class ResponseUtils
java.lang.Object
org.jmythapi.protocol.utils.ResponseUtils
public class ResponseUtils
- extends Object
This class provides MythTV-response related utility function.
Usage example:
IMythPacket resp = cmdConnection.readMessage();
IRecorderInfo recorderInfo = ResponseUtils.readFrom(RecorderInfo.class, resp);
In the above example a new instance of the class RecorderInfo
is created and
initialized with the arguments of the response packet.
- See Also:
IMythResponse
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
STATUS_OK
public static final String STATUS_OK
- See Also:
- Constant Field Values
readFrom
public static final <E extends Enum<E>,Resp extends AMythResponse<E> & IMythResponse<E>> Resp readFrom(Class<Resp> respClass,
IMythPacket packet)
throws IllegalArgumentException
- Converts a protocol packet into a response object.
This function create a new subclass of the AMythResponse
object and initializes
it with the data from the given protocol packet.
Response objects passed to this function must provide one of the following functions:
- a static function
valueOf(IMythPacket)
- a constructor
ResponseObject(IMythPacket)
Usage example:
IBackendConnection cmdConnection = ....;
IMythPacket resp = cmdConnection.readMessage();
IRecorderInfo recorderInfo = ResponseUtils.readFrom(RecorderInfo.class, resp);
- Type Parameters:
E
- the type of the response object propertiesResp
- the type of the response object- Parameters:
respClass
- the class of the response objectpacket
- the myth-packet
- Returns:
- the instantiated class
- Throws:
IllegalArgumentException
- if the created class is not compatible with the given packet arguments.
readFrom
public static final <E extends Enum<E>,Resp extends AMythResponse<E>> Resp readFrom(ProtocolVersion protoVersion,
Class<Resp> respClass,
InputStream input)
throws IOException
- Throws:
IOException
readFrom
public static final <E extends Enum<E>,Resp extends AMythResponse<E>> Resp readFrom(ProtocolVersion protoVersion,
Class<Resp> respClass,
String input)
copyArguments
public static final <E extends Enum<E>,S extends AMythResponse<E>,F extends Enum<F>,T extends AMythResponse<F>> void copyArguments(S source,
T target)
Copyright © 2008-2013. All Rights Reserved.