|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jmythapi.impl.AData<E>
org.jmythapi.protocol.response.impl.AMythResponse<IProgramInfoList.Props>
org.jmythapi.protocol.response.impl.ProgramInfoList
public class ProgramInfoList
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jmythapi.protocol.response.IProgramInfoList |
|---|
IProgramInfoList.MapKey, IProgramInfoList.Props |
| Field Summary |
|---|
| Fields inherited from class org.jmythapi.impl.AData |
|---|
logger, propsClass, protoVersion, respArgs |
| Constructor Summary | |
|---|---|
ProgramInfoList(IMythPacket packet)
|
|
ProgramInfoList(ProtocolVersion protoVersion,
List<String> responseArgs)
|
|
| Method Summary | |
|---|---|
List<IProgramInfo> |
asList()
Returns a list of programs. |
List<IProgramInfo> |
asList(IProgramInfoFilter filter)
Returns a list of programs. |
Map<String,IProgramInfo> |
asMap(IProgramInfoList.MapKey mapKey)
Returns a map containing the unique-id of each program as key and the program as value. |
static ProgramInfoList |
emptyList(ProtocolVersion protoVersion)
Creates an empty program-info list |
IProgramInfoList |
filter(IProgramInfoFilter filter)
Returns a new program list containing only programs that are accepted by the given filter. |
IProgramInfo |
get(int idx)
Gets the program-info object at the given index. |
protected int |
getExpectedSize(List<String> responseArgs)
This function returns the expected size of the response-argument-list. |
Map<String,Integer> |
getIndexMap(IProgramInfoList.MapKey mapKey)
Returns a map containing the unique-id of each program as key and the program-index as value. |
long |
getTotalDuration()
Gets the sum of all recording durations. |
static long |
getTotalDuration(Iterable<IProgramInfo> programs,
boolean checkCurrentTime)
|
static long |
getTotalFileSize(Iterable<IProgramInfo> programs)
|
long |
getTotalFilesSize()
Gets the sum of all file sizes. |
Map<Object,IProgramInfoList> |
groupBy(IProgramInfo.Props prop)
Groups the list of program-infos by the specified program-info property. |
Map<Object,IProgramInfoList> |
groupBy(IProgramInfo.Props prop,
IProgramInfoFilter filter)
Groups the list of program-infos by the specified program-info property. |
boolean |
isEmpty()
Checks if the program list is empty. |
Iterator<IProgramInfo> |
iterator()
|
Iterator<IProgramInfo> |
iterator(IProgramInfoFilter filter)
|
IProgramInfoList[] |
multiFilter(IProgramInfoFilter... filters)
Allows to filter the program list, using multiple filters. |
int |
size()
Returns the number of programs contained in this list |
String |
toString()
Returns the content of this data object as a formatted string. |
static ProgramInfoList |
valueOf(ProtocolVersion protoVersion,
Collection<IProgramInfo> programs)
Converts a collection of program-info objects into a program-info list. |
| 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.protocol.response.IProgramInfoList |
|---|
clone |
| Methods inherited from interface org.jmythapi.IVersionable |
|---|
getVersionNr |
| Methods inherited from interface org.jmythapi.IPropertyAware |
|---|
getProperties, getProperty, getPropertyClass, getPropertyCount, getPropertyIndex, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValues, setPropertyValue, setPropertyValue, setPropertyValueObject |
| Constructor Detail |
|---|
public ProgramInfoList(IMythPacket packet)
public ProgramInfoList(ProtocolVersion protoVersion,
List<String> responseArgs)
| Method Detail |
|---|
protected int getExpectedSize(List<String> responseArgs)
AMythResponseThis function returns the expected size of the response-argument-list.
The expected size may be different depending on the current MythTV-protocol-version.EnumUtils#getEnumLength(Class, int)
to determine the expected size of the argument-list.
getExpectedSize in class AMythResponse<IProgramInfoList.Props>responseArgs - the response-argument-listpublic int size()
IProgramInfoList
size in interface IProgramInfoListpublic boolean isEmpty()
IProgramInfoList
isEmpty in interface IProgramInfoListtrue if the list is empty.public List<IProgramInfo> asList()
IProgramInfoList
Use IProgramInfoList.asList(IProgramInfoFilter) if you want to filter out unwanted programs.
asList in interface IProgramInfoListpublic List<IProgramInfo> asList(IProgramInfoFilter filter)
IProgramInfoList
asList in interface IProgramInfoListfilter - the filter to apply to the list of programs
public IProgramInfoList filter(IProgramInfoFilter filter)
IProgramInfoList
// our list of programs IProgramInfoList programs = ...; // creating the program filter IProgramInfoFilter filter = ProgramInfoFilters.recordingStatus(IProgramRecordingStatus.Status.WILL_RECORD); // filter programs IProgramInfoList filteredPrograms = programs.filter(filter); // loop through the filtered list for (IProgramInfo program : filteredPrograms) { System.out.println(String.format( "%1$tF %1$tT- %2$s (%3$s)", program.getStartTime(), program.getFullTitle(), program.getChannelSign() )); }
See ProgramInfoFilters for a list of predefined filters.
filter in interface IProgramInfoListfilter - the program filter to use or null if no filtering should be done
public IProgramInfoList[] multiFilter(IProgramInfoFilter... filters)
IProgramInfoListFor each filter a list of matching program-info objects is returned.
multiFilter in interface IProgramInfoListfilters - a list of filters
public IProgramInfo get(int idx)
IProgramInfoList
get in interface IProgramInfoListidx - the index
public Iterator<IProgramInfo> iterator()
iterator in interface Iterable<IProgramInfo>Iterable.iterator()public Iterator<IProgramInfo> iterator(IProgramInfoFilter filter)
public String toString()
ADataReturns 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
toString in class AData<IProgramInfoList.Props>public Map<String,IProgramInfo> asMap(IProgramInfoList.MapKey mapKey)
IProgramInfoList
The input parameter specifies if the unique program-id or
recording-id should be used as key.
Please note that multiple different recordings may have the same program-id but different recording-ids.
asMap in interface IProgramInfoListpublic Map<String,Integer> getIndexMap(IProgramInfoList.MapKey mapKey)
IProgramInfoListThe result of this function can be used to determine the index of a program within the program-list.
The input parameter specifies if the unique program-id or
recording-id should be used as key.
Please note that multiple different recordings may have the same program-id but different recording-ids.
getIndexMap in interface IProgramInfoListpublic Map<Object,IProgramInfoList> groupBy(IProgramInfo.Props prop)
IProgramInfoList// get a list of all recordings IProgramInfoList allRecordings = backend.queryRecordings(); // group recordings by storage group Map<Object,IProgramInfoList> recordingsByStorageGroup = allRecordings.groupBy(IProgramInfo.Props.STORAGE_GROUP); for(Entry<Object,IProgramInfoList> entry : recordingsByStorageGroup.entrySet()) { System.out.println(String.format( "\r\nSTORAGE-GROUP '%s': %02d recordings", entry.getKey(), entry.getValue().size() )); for(IProgramInfo program : entry.getValue()) { System.out.println(String.format( "- %s", program.getFullTitle() )); } }
groupBy in interface IProgramInfoListprop - the program-info property that is used for grouping
public Map<Object,IProgramInfoList> groupBy(IProgramInfo.Props prop,
IProgramInfoFilter filter)
IProgramInfoList// get a list of all recordings IProgramInfoList allRecordings = backend.queryRecordings(); // optionally define a filter IProgramInfoFilter filter = null; // group recordings by category Map<Object,IProgramInfoList> recordingsByCategory = allRecordings.groupBy(IProgramInfo.Props.CATEGORY, filter); for(Entry<Object,IProgramInfoList> entry : recordingsByCategory.entrySet()) { System.out.println(String.format( "\r\nCATEGORY '%s': ", entry.getKey() )); for(IProgramInfo program : entry.getValue()) { System.out.println(String.format( "- %s", program.getFullTitle() )); } }
groupBy in interface IProgramInfoListprop - the program-info property that is used for groupingfilter - the program filter to use or null if no filtering should be done
public long getTotalFilesSize()
IProgramInfoList
getTotalFilesSize in interface IProgramInfoListIProgramInfo.getFileSize()public long getTotalDuration()
IProgramInfoList
getTotalDuration in interface IProgramInfoListIBasicProgramInfo.getDuration()public static final long getTotalFileSize(Iterable<IProgramInfo> programs)
public static final long getTotalDuration(Iterable<IProgramInfo> programs,
boolean checkCurrentTime)
public static final ProgramInfoList valueOf(ProtocolVersion protoVersion,
Collection<IProgramInfo> programs)
programs - the collection of programs.
public static final ProgramInfoList emptyList(ProtocolVersion protoVersion)
protoVersion - the protocol version
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||