|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
E
- the enumeration property typepublic interface IPropertyAware<E extends Enum<E>>
This interface represents a property aware object.
Property aware objects are typically response messages
, received from a MythTV backend.
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.
// 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);
// 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); }
for(int i=0; i < object.getPropertyCount(); i++) { System.out.println(String.format( "Property %02d: %s", i, object.getProperty(i) )); }
EnumUtils
for additional methods that can be used to work with the properties of
a property-aware object.
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. |
|
|
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. |
|
|
setPropertyValueObject(E prop,
S propValue)
Sets the property value for the given property. |
Method Detail |
---|
Class<E> getPropertyClass()
int getPropertyCount()
E getProperty(int idx)
This is the reverse operation of getPropertyIndex(Enum)
.
for(int i=0; i < object.getPropertyCount(); i++) { System.out.println(String.format( "Property %02d: %s", i, object.getProperty(i) )); }
idx
- the position within the property array
IndexOutOfBoundsException
- if the specified index is out of rangeint getPropertyIndex(E prop)
This is the reverse operation of getProperty(int)
-1
is returned.
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) )); }
prop
- the property for which the index should be returned
-1
, if a property is not supported in
the currently used protocol version.String getPropertyValue(E prop)
Internally this method uses getPropertyIndex(Enum)
,
to determine the position of the value in the value list.
prop
- the desired property
null
if no value is available or
the given property is not supported in the given protocol-version.String getPropertyValue(int idx)
// reads the recorder-info property "hostport" and String port = recorderInfo.getPropertyValue(IRecorderInfo.Props.HOSTPORT);
idx
- the index of the property for which the value should be returned
IndexOutOfBoundsException
- if the specified index is out of range<T> T getPropertyValueObject(E prop)
The data type conversion is done using methods of the utility
class EncodingUtils
.
null
is returned as value.
// reads the recorder-info property "hostport" and // converts it into an object of type Integer. Integer port = recorderInfo.getPropertyValueObject(IRecorderInfo.Props.HOSTPORT);
T
- the property data typeprop
- the desired property
null
if no value is available or
the given property is not supported in the given protocol-version.EncodingUtils.decodeString(java.lang.Class, org.jmythapi.protocol.ProtocolVersion, java.lang.String)
EnumSet<E> getProperties()
List<String> getPropertyValues()
EnumMap<E,String> getPropertyMap()
EnumUtils.getEnums(java.lang.Class, org.jmythapi.protocol.ProtocolVersion)
String setPropertyValue(E prop, String value)
prop
- the property whose value should be setvalue
- the new value
String setPropertyValue(int propIdx, String value)
propIdx
- the index of the argument, whose value should be set.value
- the new value
IndexOutOfBoundsException
- if the specified index is out of range<S,T> void setPropertyValueObject(E prop, S propValue)
S
- the type of the property valueT
- the to-string type of the property valueprop
- the propertypropValue
- the property value as object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |