org.jmythapi.protocol.utils
Class ResponseUtils

java.lang.Object
  extended by org.jmythapi.protocol.utils.ResponseUtils

public class ResponseUtils
extends Object

This class provides MythTV-response related utility function.

Usage example:


    // read the response packet from the connection
    IMythPacket resp = cmdConnection.readMessage();
    
    // convert the response packet into a specific response object
    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

Field Summary
static String STATUS_OK
           
 
Method Summary
static
<E extends Enum<E>,S extends AMythResponse<E>,F extends Enum<F>,T extends AMythResponse<F>>
void
copyArguments(S source, T target)
           
static
<E extends Enum<E>,Resp extends AMythResponse<E> & IMythResponse<E>>
Resp
readFrom(Class<Resp> respClass, IMythPacket packet)
          Converts a protocol packet into a response object.
static
<E extends Enum<E>,Resp extends AMythResponse<E>>
Resp
readFrom(ProtocolVersion protoVersion, Class<Resp> respClass, InputStream input)
           
static
<E extends Enum<E>,Resp extends AMythResponse<E>>
Resp
readFrom(ProtocolVersion protoVersion, Class<Resp> respClass, String input)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_OK

public static final String STATUS_OK
See Also:
Constant Field Values
Method Detail

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:

Usage example:

    // the backend connection
    IBackendConnection cmdConnection = ....;
 
    // read response		
    IMythPacket resp = cmdConnection.readMessage();
    
    // create response-wrapper object
    IRecorderInfo recorderInfo = ResponseUtils.readFrom(RecorderInfo.class, resp);
 

Type Parameters:
E - the type of the response object properties
Resp - the type of the response object
Parameters:
respClass - the class of the response object
packet - 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.