|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
E
- the type of the response object propertiespublic interface IMythResponse<E extends Enum<E>>
This interface represents a MythTV response object.
A response object consists of a list of response arguments. This response arguments are simple
strings that were received over network in the form of a packet
.
ResponseUtils
:
// read the response packet from network IMythPacket resp = connection.readPacket(); // convert the response packet into a specific response object IRecorderInfo recorderInfo = ResponseUtils.readFrom(RecorderInfo.class, resp);
property-aware
. Therefore the advantage of a response-object
in comparison to a the raw packet is the enumeration property class, that belongs to each type of response
object.
version-range
is specified, describing in which protocol version a specific property is part of a response.
IRecorderInfo
object (as show in the following example) and then we can use the
enumeration property HOSTNAME
to get the hostname of the recorder.
IMythPacket resp = ...; // a previously received myth packet // convert the response packet into a specific response object RecorderInfo recorderInfo = ResponseUtils.readFrom(RecorderInfo.class, resp); // read a property value String hostName = recorderInfo.getPropertyValue(IRecorderInfo.Props.HOSTNAME); // the above call is similar to hostName = recorderInfo.getHostName();
29 | GET_NEXT_FREE_RECORDER[]:[]-1 |
26 | 1[]:[]192.168.0.2[]:[]6543 |
hostname
is located at position 1
in the response array. Furthermore the position of an argument may change
depending of the protocol-version, the backend is speaking. When using the enumeration constants to fetch an argument,
we do not need to take care about this.
Moreover, an enumeration property may not be part of the response in the current protocol version. In this case the
the property-aware object will just return null
as value.
IPropertyAware.getPropertyValue(Enum)
internally uses helper function of the utility
class EnumUtils
to determine, which enumeration properties are available in which protocol-version and
at which position in the response arguments array, the value for a given property can be found.
EnumMap<IRecorderInfo.Props,String> props = recorderInfo.getPropertyMap(); for(Entry<IRecorderInfo.Props,String> prop : props.entrySet()) { System.out.println(String.format( "Property %s=%s", prop.getKey(),prop.getValue() )); }
IPropertyAware
for details.
ResponseUtils.readFrom(java.lang.Class, org.jmythapi.protocol.IMythPacket)
,
EnumUtils
Method Summary |
---|
Methods inherited from interface org.jmythapi.IPropertyAware |
---|
getProperties, getProperty, getPropertyClass, getPropertyCount, getPropertyIndex, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValues, setPropertyValue, setPropertyValue, setPropertyValueObject |
Methods inherited from interface org.jmythapi.IVersionable |
---|
getVersionNr |
Methods inherited from interface org.jmythapi.protocol.ISendable |
---|
getPacket |
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |