|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmythapi.impl.AData<E>
E
- the enumeration class describing the object properties.public abstract class AData<E extends Enum<E>>
A generic data object.
This object represents is a generic data object containing the following mandatory fields:
This object is property-aware
. getProperties()
can be used to determine the
properties, which are accessible by this object.
Field Summary | |
---|---|
protected Logger |
logger
For logging. |
protected Class<E> |
propsClass
An enumeration class defining all data properties. |
protected ProtocolVersion |
protoVersion
The MythTV-protocol-version of this data object. |
protected List<String> |
respArgs
The values of all data properties. |
Constructor Summary | |
---|---|
AData()
|
Method Summary | ||
---|---|---|
Object |
clone()
Creates a copy of this object. |
|
protected abstract
|
decodeProperty(Class<T> dataType,
String dataValue)
|
|
protected abstract
|
encodeProperty(Class<S> propObjectType,
S propValue,
Class<T> propStringType,
String propDefaultValue)
|
|
boolean |
equals(Object obj)
Tests objects for equality. |
|
abstract EnumSet<E> |
getProperties()
Returns all supported properties. |
|
abstract 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. |
|
abstract 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 propIdx)
Gets the value for the given property index. |
|
|
getPropertyValueObject(Class<T> dataType,
E prop)
|
|
|
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. |
|
ProtocolVersion |
getVersionNr()
Gets the protocol-version of an object. |
|
int |
hashCode()
Generates a hashCode for this object. |
|
protected void |
init(ProtocolVersion protoVersion,
Class<E> propsClass,
List<String> data)
Initializes this object with all mandatory values. |
|
protected void |
postProcessArguments()
|
|
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. |
|
String |
toString()
Returns the content of this data object as a formatted string. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Logger logger
protected ProtocolVersion protoVersion
protected Class<E extends Enum<E>> propsClass
protected List<String> respArgs
This list has a fixed size.
Constructor Detail |
---|
public AData()
Method Detail |
---|
protected void init(ProtocolVersion protoVersion, Class<E> propsClass, List<String> data)
protoVersion
- the protocol version of this objectpropsClass
- the enumeration class, containing all properties of this objectdata
- the property values of this objectprotected void postProcessArguments()
public ProtocolVersion getVersionNr()
getVersionNr
in interface IVersionable
public Class<E> getPropertyClass()
IPropertyAware
getPropertyClass
in interface IPropertyAware<E extends Enum<E>>
public int getPropertyCount()
IPropertyAware
getPropertyCount
in interface IPropertyAware<E extends Enum<E>>
public List<String> getPropertyValues()
IPropertyAware
getPropertyValues
in interface IPropertyAware<E extends Enum<E>>
public String getPropertyValue(int propIdx)
IPropertyAware
// reads the recorder-info property "hostport" and String port = recorderInfo.getPropertyValue(IRecorderInfo.Props.HOSTPORT);
getPropertyValue
in interface IPropertyAware<E extends Enum<E>>
propIdx
- the index of the property for which the value should be returned
public String getPropertyValue(E prop)
IPropertyAware
Internally this method uses IPropertyAware.getPropertyIndex(Enum)
,
to determine the position of the value in the value list.
getPropertyValue
in interface IPropertyAware<E extends Enum<E>>
prop
- the desired property
null
if no value is available or
the given property is not supported in the given protocol-version.public <T> T getPropertyValueObject(E prop)
IPropertyAware
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);
getPropertyValueObject
in interface IPropertyAware<E extends Enum<E>>
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)
public <T> T getPropertyValueObject(Class<T> dataType, E prop)
protected abstract <T> T decodeProperty(Class<T> dataType, String dataValue)
public String setPropertyValue(int propIdx, String value)
IPropertyAware
setPropertyValue
in interface IPropertyAware<E extends Enum<E>>
propIdx
- the index of the argument, whose value should be set.value
- the new value
public String setPropertyValue(E prop, String value)
IPropertyAware
setPropertyValue
in interface IPropertyAware<E extends Enum<E>>
prop
- the argument, whose value should be setvalue
- the new value of the argument
public <S,T> void setPropertyValueObject(E prop, S propValue)
IPropertyAware
setPropertyValueObject
in interface IPropertyAware<E extends Enum<E>>
S
- the type of the property valueT
- the to-string type of the property valueprop
- the propertypropValue
- the property value as objectprotected abstract <S,T> String encodeProperty(Class<S> propObjectType, S propValue, Class<T> propStringType, String propDefaultValue)
public EnumMap<E,String> getPropertyMap()
IPropertyAware
getPropertyMap
in interface IPropertyAware<E extends Enum<E>>
EnumUtils.getEnums(java.lang.Class, org.jmythapi.protocol.ProtocolVersion)
public abstract E getProperty(int idx)
IPropertyAware
This is the reverse operation of IPropertyAware.getPropertyIndex(Enum)
.
for(int i=0; i < object.getPropertyCount(); i++) { System.out.println(String.format( "Property %02d: %s", i, object.getProperty(i) )); }
getProperty
in interface IPropertyAware<E extends Enum<E>>
idx
- the position within the property array
public abstract int getPropertyIndex(E prop)
IPropertyAware
This is the reverse operation of IPropertyAware.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) )); }
getPropertyIndex
in interface IPropertyAware<E extends Enum<E>>
prop
- the property for which the index should be returned
-1
, if a property is not supported in
the currently used protocol version.public abstract EnumSet<E> getProperties()
IPropertyAware
getProperties
in interface IPropertyAware<E extends Enum<E>>
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public boolean equals(Object obj)
Data objects are seen to be equal if the response to the following function calls are equal:
equals
in class Object
public int hashCode()
This is required when using this object as a key in a map
.
hashCode
in class Object
public String toString()
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
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |