org.jmythapi
Interface IPropertyAware<E extends Enum<E>>

Type Parameters:
E - the enumeration property type
All Superinterfaces:
Cloneable
All Known Subinterfaces:
IAskRecording, IClearSettingsCache, IClientErrorEvent, ICommflagStart, IDoneRecording, IDownloadFile<E>, IDownloadFileFinished, IDownloadFileUpdate, IFileStatus, IFileTransfer, IFreeSpace, IFreeSpaceListEntry, IFreeSpaceSummary, IGuideDataThrough, IInputInfoFree, IInputInfoTuned, IJobQueue, ILiveTvChainUpdate, ILoad, IMemStats, IMythEvent<E>, IMythFillDatabaseSettings, IMythJobSettings, IMythResponse<E>, IMythShutdownSettings, IPixmap, IPixmapGenerated, IProgramInfo, IProgramInfoList, IRecorderChannelInfo, IRecorderChannelPrefixStatus, IRecorderInfo, IRecorderNextProgramInfo, IRecorderProgramInfo, IRecordingEvent<E>, IRecordingListChange<E>, IRecordingListChangeAdd, IRecordingListChangeDelete, IRecordingListChangeList, IRecordingListChangeSingle<E>, IRecordingListChangeUpdate, IRecordingsConflicting, IRecordingsExpiring, IRecordingsPending, IRecordingsScheduled, IRecordingStatus, IRecordingUpdateEvent<E>, IRemoteEncoderBusyStatus, IRemoteEncoderState, IResetIdleTime, IRingBuffer, ISchedule, IScheduleChange, ISetting, IShutdownCountdown, IStorageGroupDirectory, IStorageGroupFile, ISystemEvent, ITimezone, ITransferable<E>, ITunerInfo, IUpdateFileSize, IUpdateProgInfo, IUptime, IVideoList<E>, IVideoListChange, IVideoListNoChange
All Known Implementing Classes:
AData, ADatabaseRow, AFreeSpace, AMythEvent, AMythResponse, AProgramInfo, ARecorderProgramInfo, ARecordings, ASettingsGroup, AskRecording, ChannelInfo, ClearSettingsCache, ClientErrorEvent, CommflagStart, DoneRecording, DownloadFileFinished, DownloadFileUpdate, FileStatus, FileTransfer, FreeInputsList, FreeSpace, FreeSpaceList, FreeSpaceList.Entry, FreeSpaceSummary, GuideDataThrough, GuideDataThrough, InputInfoFree, InputInfoTuned, JobQueue, LiveTvChainUpdate, Load, MemStats, MythFillDatabaseStatus, MythShutdownStatus, Pixmap, PixmapGenerated, ProgramInfo, ProgramInfoList, RecorderChannelInfo, RecorderChannelPrefixStatus, RecorderInfo, RecorderInfo, RecorderNextProgramInfo, RecorderNextProgramInfo, RecorderProgramInfo, RecordingListChangeAdd, RecordingListChangeAny, RecordingListChangeDelete, RecordingListChangeUpdate, RecordingsConflicting, RecordingsExpiring, RecordingsPending, RecordingsScheduled, RecordingStatus, RemoteEncoderBusyStatus, RemoteEncoderState, ResetIdleTime, RingBuffer, Schedule, ScheduleChange, Setting, Setting, ShutdownCountdown, StorageGroupDirectory, StorageGroupFile, StorageGroupFileList, SystemEvent, Timezone, TunerInfo, UpdateFileSize, UpdateProgInfo, Uptime, VideoList, VideoListChange, VideoListNoChange

public interface IPropertyAware<E extends Enum<E>>
extends Cloneable

This interface represents a property aware object.

Property aware objects are typically response messages, received from a MythTV backend.

Property Position and Version Range

Each property-aware object has a set of enumeration properties, that can be used to get the value of a property, within the property value list.

Without the enum properties, you would need to know at which position in the value array, a specific property value can be found. Moreover a property value may only be available for specific protocol versions.

Then using the enum properties, you do not need to take care about the proper position or version number. If a property is not available for the current protocol-version, null is returned as value.

Usage examples:

Read Property Values:


    // a property aware object
    IProgramInfo program = ...;
    
    // read the recording status as string (as returned by the backend)
    String recStatusString = program.getPropertyValue(IProgramInfo.Props.REC_STATUS);
    
    // read the recording status as object
    IProgramRecordingStatus recStatus = program.getPropertyValueObject(IProgramInfo.Props.REC_STATUS);
    
    // read the storage group (this will return null for proto version < 32)
    String storageGroup = program.getPropertyValueObject(IProgramInfo.Props.STORAGE_GROUP);
 

Copy properties between objects:


    // the source and target object
    IProgramInfo source = ..., target = ...;
    
    // copy the string values of all properties
    for(E prop : source.getProperties()) {
       String sourceValue = source.getPropertyValue(prop);
       target.setPropertyValue(prop, sourceValue);		
    }		
 

Print the names of all available properties:


    for(int i=0; i < object.getPropertyCount(); i++) {
       System.out.println(String.format(
          "Property %02d: %s",
          i, object.getProperty(i)
       ));
    }
 

Utility Class:

See EnumUtils for additional methods that can be used to work with the properties of a property-aware object.

See Also:
EnumUtils, IMythResponse

Method Summary
 EnumSet<E> getProperties()
          Returns all supported properties.
 E getProperty(int idx)
          Gets the property for the given index.
 Class<E> getPropertyClass()
          Gets the enumeration class defining all available properties.
 int getPropertyCount()
          Gets the amount of available properties stored in this object.
 int getPropertyIndex(E prop)
          Gets the index for the given property.
 EnumMap<E,String> getPropertyMap()
          Gets a map with all available properties and their values.
 String getPropertyValue(E prop)
          Gets the value for the given property.
 String getPropertyValue(int idx)
          Gets the value for the given property index.
<T> T
getPropertyValueObject(E prop)
          Gets the property value for a given property and converts it into the property data-type.
 List<String> getPropertyValues()
          Returns all property values as strings.
 String setPropertyValue(E prop, String value)
          Sets the property value for the given property.
 String setPropertyValue(int propIdx, String value)
          Sets the property value for the given property.
<S,T> void
setPropertyValueObject(E prop, S propValue)
          Sets the property value for the given property.
 

Method Detail

getPropertyClass

Class<E> getPropertyClass()
Gets the enumeration class defining all available properties.

Returns:
the enumeration class

getPropertyCount

int getPropertyCount()
Gets the amount of available properties stored in this object.

Protocol Version Hint:

Depending on the used protocol version the amount of available properties may be different.

Returns:
the amount of properties

getProperty

E getProperty(int idx)
Gets the property for the given index.

This is the reverse operation of getPropertyIndex(Enum).

Protocol Version Hint:

Depending on the used protocol version a specific property may be located at a different position.

Usage example:


    for(int i=0; i < object.getPropertyCount(); i++) {
       System.out.println(String.format(
          "Property %02d: %s",
          i, object.getProperty(i)
       ));
    }
 

Parameters:
idx - the position within the property array
Returns:
the enumeration constant
Throws:
IndexOutOfBoundsException - if the specified index is out of range

getPropertyIndex

int getPropertyIndex(E prop)
Gets the index for the given property.

This is the reverse operation of getProperty(int)

Protocol Version Hint:

If the given property is not supported in the current protocol version, -1 is returned.

Usage example:


    EnumSet<IProgramInfo.Props> props = program.getProperties();
    for(IProgramInfo.Props prop : props) {
       System.out.println(String.format(
          "Property %s is stored at position %d.",
          prop.name(), program.getPropertyIndex(prop)
       ));
    }
 

Parameters:
prop - the property for which the index should be returned
Returns:
the index of the property or -1, if a property is not supported in the currently used protocol version.

getPropertyValue

String getPropertyValue(E prop)
Gets the value for the given property.

Internally this method uses getPropertyIndex(Enum), to determine the position of the value in the value list.

Parameters:
prop - the desired property
Returns:
the property value or null if no value is available or the given property is not supported in the given protocol-version.

getPropertyValue

String getPropertyValue(int idx)
Gets the value for the given property index.

Protocol Version Hint:

Depending on the current protocol version, a different property may be located on the same index.

Usage example:


    // reads the recorder-info property "hostport" and 
    String port = recorderInfo.getPropertyValue(IRecorderInfo.Props.HOSTPORT);
 

Parameters:
idx - the index of the property for which the value should be returned
Returns:
the property value
Throws:
IndexOutOfBoundsException - if the specified index is out of range

getPropertyValueObject

<T> T getPropertyValueObject(E prop)
Gets the property value for a given property and converts it into the property data-type.

The data type conversion is done using methods of the utility class EncodingUtils.

Protocol Version Hint:

If the requested property is not supported in the current protocol version, null is returned as value.

Usage example:


    // reads the recorder-info property "hostport" and 
    // converts it into an object of type Integer.
    Integer port = recorderInfo.getPropertyValueObject(IRecorderInfo.Props.HOSTPORT);
 

Type Parameters:
T - the property data type
Parameters:
prop - the desired property
Returns:
the converted property value or null if no value is available or the given property is not supported in the given protocol-version.
See Also:
EncodingUtils.decodeString(java.lang.Class, org.jmythapi.protocol.ProtocolVersion, java.lang.String)

getProperties

EnumSet<E> getProperties()
Returns all supported properties.

Protocol Version Hint:

Depending on the protocol version, a different set of properties my be returned.

Returns:
all properties supported in the current protocol version

getPropertyValues

List<String> getPropertyValues()
Returns all property values as strings.

Returns:
all properties as strings

getPropertyMap

EnumMap<E,String> getPropertyMap()
Gets a map with all available properties and their values.

Protocol Version Hint:

Depending on the protocol version a different set of properties may be returned.

Returns:
a map containing all properties and their values.
See Also:
EnumUtils.getEnums(java.lang.Class, org.jmythapi.protocol.ProtocolVersion)

setPropertyValue

String setPropertyValue(E prop,
                        String value)
Sets the property value for the given property.

Protocol Version Hint:

If the given property is not supported for the current protocol version, than calling this method has no effect.

Parameters:
prop - the property whose value should be set
value - the new value
Returns:
the old value.

setPropertyValue

String setPropertyValue(int propIdx,
                        String value)
Sets the property value for the given property.

Protocol Version Hint:

Depending on the current protocol version, a different property may be located on the same index.

Parameters:
propIdx - the index of the argument, whose value should be set.
Depending on the current protocol version the same index may address different properties.
value - the new value
Returns:
the old value
Throws:
IndexOutOfBoundsException - if the specified index is out of range

setPropertyValueObject

<S,T> void setPropertyValueObject(E prop,
                                  S propValue)
Sets the property value for the given property.

Protocol Version Hint:

If the given property is not supported for the current protocol version, than calling this method has no effect.

Type Parameters:
S - the type of the property value
T - the to-string type of the property value
Parameters:
prop - the property
propValue - the property value as object


Copyright © 2008-2013. All Rights Reserved.