org.jmythapi.protocol.response.impl
Class ARecordings<E extends Enum<E>>

java.lang.Object
  extended by org.jmythapi.impl.AData<E>
      extended by org.jmythapi.protocol.response.impl.AMythResponse<E>
          extended by org.jmythapi.protocol.response.impl.ARecordings<E>
All Implemented Interfaces:
Cloneable, Iterable<IProgramInfo>, IPropertyAware<E>, IVersionable, ISendable, IMythResponse<E>, IRecordings
Direct Known Subclasses:
RecordingsConflicting, RecordingsExpiring, RecordingsPending, RecordingsScheduled

public abstract class ARecordings<E extends Enum<E>>
extends AMythResponse<E>
implements IRecordings


Field Summary
 
Fields inherited from class org.jmythapi.impl.AData
logger, propsClass, protoVersion, respArgs
 
Constructor Summary
ARecordings(Class<E> propsClass, IMythPacket packet)
           
ARecordings(ProtocolVersion protoVersion, Class<E> propsClass, List<String> responseArgs)
           
 
Method Summary
protected  int getExpectedSize(List<String> responseArgs)
          This function returns the expected size of the response-argument-list.
 IProgramInfoList getProgramInfoList()
          Gets a list of contained recordings.
 IProgramInfoList getProgramInfoList(IProgramInfoFilter filter)
          Gets the list of contained recordings.
protected abstract  int getSizePropertyIndex()
           
 boolean isEmpty()
          Checks if the recordings-list contains a recording.
 Iterator<IProgramInfo> iterator()
          Gets an iterator to loop through all available recordings.
 Iterator<IProgramInfo> iterator(IProgramInfoFilter filter)
          Gets an iterator to loop through all recordings matching the given filter.
 int size()
          Gets the amount of recordings contained in the list.
 String toString()
          Returns the content of this data object as a formatted string.
 
Methods inherited from class org.jmythapi.protocol.response.impl.AMythResponse
checkSize, decodeProperty, encodeProperty, getPacket, getProperties, getProperty, getPropertyIndex
 
Methods inherited from class org.jmythapi.impl.AData
clone, equals, getPropertyClass, getPropertyCount, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValueObject, getPropertyValues, getVersionNr, hashCode, init, postProcessArguments, setPropertyValue, setPropertyValue, setPropertyValueObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jmythapi.IVersionable
getVersionNr
 
Methods inherited from interface org.jmythapi.IPropertyAware
getPropertyClass, getPropertyCount, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValues, setPropertyValue, setPropertyValue, setPropertyValueObject
 

Constructor Detail

ARecordings

public ARecordings(Class<E> propsClass,
                   IMythPacket packet)

ARecordings

public ARecordings(ProtocolVersion protoVersion,
                   Class<E> propsClass,
                   List<String> responseArgs)
Method Detail

getExpectedSize

protected int getExpectedSize(List<String> responseArgs)
Description copied from class: AMythResponse

This function returns the expected size of the response-argument-list.

The expected size may be different depending on the current MythTV-protocol-version.
The default implementation of this function uses EnumUtils#getEnumLength(Class, int) to determine the expected size of the argument-list.

Overrides:
getExpectedSize in class AMythResponse<E extends Enum<E>>
Parameters:
responseArgs - the response-argument-list

getSizePropertyIndex

protected abstract int getSizePropertyIndex()
Returns:
the position within the response-arguments where the size property is located

getProgramInfoList

public IProgramInfoList getProgramInfoList()
Description copied from interface: IRecordings
Gets a list of contained recordings.

Specified by:
getProgramInfoList in interface IRecordings
Returns:
the list of contained recordings

getProgramInfoList

public IProgramInfoList getProgramInfoList(IProgramInfoFilter filter)
Description copied from interface: IRecordings
Gets the list of contained recordings. Only recordings matching the given filter will be returned.

Usage example:


In the example listed below we fetch all pending recordings, but only list recordings having the status WILL_RECORD.

 // query pending recordings
 IRecordingsPending pendingRecords = backend.queryAllPending();
 
 // creating the program filter
 IProgramInfoFilter filter = ProgramInfoFilters.recordingStatus(IProgramRecordingStatus.Status.WILL_RECORD);
 
 // loop through the filtered list
 for (IProgramInfo program : pendingRecords.getProgramInfoList(filter)) {
    System.out.println(String.format(
       "%1$tF %1$tT- %2$s (%3$s)",
       program.getStartTime(),
       program.getTitle(),
       program.getChannelSign()
    ));
 }
  

This function internally uses IProgramInfoList.filter(IProgramInfoFilter) to filter the programs.

Specified by:
getProgramInfoList in interface IRecordings
Parameters:
filter - the filter that should be applied, or null if no filtering should be done.
Returns:
a new list containing the filtered programs

iterator

public Iterator<IProgramInfo> iterator()
Description copied from interface: IRecordings
Gets an iterator to loop through all available recordings.

Specified by:
iterator in interface Iterable<IProgramInfo>
Specified by:
iterator in interface IRecordings
Returns:
a recordings iterator
See Also:
Iterable.iterator()

iterator

public Iterator<IProgramInfo> iterator(IProgramInfoFilter filter)
Description copied from interface: IRecordings
Gets an iterator to loop through all recordings matching the given filter.

Specified by:
iterator in interface IRecordings
Parameters:
filter - the filter that should be applied or null if no filtering should be done.
Returns:
all recordings matching the given filter

size

public int size()
Description copied from interface: IRecordings
Gets the amount of recordings contained in the list.

Specified by:
size in interface IRecordings
Returns:
the size of the ProgramInfoList

isEmpty

public boolean isEmpty()
Description copied from interface: IRecordings
Checks if the recordings-list contains a recording.

Specified by:
isEmpty in interface IRecordings
Returns:
false if there is at least one recording

toString

public String toString()
Description copied from class: AData

Returns the content of this data object as a formatted string.

E.g.
 <0>TOTAL_RAM_MB: 1002 | <1>FREE_RAM_MB: 474 | <2>TOTAL_VM_MB: 853 | <3>FREE_VM_MB: 853
 

Overrides:
toString in class AData<E extends Enum<E>>


Copyright © 2008-2013. All Rights Reserved.