org.jmythapi.database.impl
Class ADatabaseRow<E extends Enum<E>>

java.lang.Object
  extended by org.jmythapi.impl.AData<E>
      extended by org.jmythapi.database.impl.ADatabaseRow<E>
All Implemented Interfaces:
Cloneable, IPropertyAware<E>, IVersionable
Direct Known Subclasses:
ASettingsGroup, ChannelInfo, GuideDataThrough, JobQueue, RecorderInfo, RecorderNextProgramInfo, Schedule, Setting, StorageGroupDirectory

public abstract class ADatabaseRow<E extends Enum<E>>
extends AData<E>
implements IVersionable


Field Summary
 
Fields inherited from class org.jmythapi.impl.AData
logger, propsClass, protoVersion, respArgs
 
Constructor Summary
ADatabaseRow(ProtocolVersion protoVersion, int dbVersion, Class<E> propsClass)
           
ADatabaseRow(ProtocolVersion protoVersion, int dbVersion, Class<E> propsClass, List<String> data)
           
 
Method Summary
 Object clone()
          Creates a copy of this object.
protected
<T> T
decodeProperty(Class<T> dataType, String dataValue)
           
protected
<S,T> String
encodeProperty(Class<S> propObjectType, S propValue, Class<T> propStringType, String propDefaultValue)
           
 boolean equals(Object obj)
          Tests objects for equality.
 int getDatabaseVersion()
           
 EnumSet<E> getProperties()
          Returns all supported properties.
 E getProperty(int idx)
          Gets the property for the given index.
 int getPropertyIndex(E prop)
          Gets the index for the given property.
 
Methods inherited from class org.jmythapi.impl.AData
getPropertyClass, getPropertyCount, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValueObject, getPropertyValues, getVersionNr, hashCode, init, postProcessArguments, setPropertyValue, setPropertyValue, setPropertyValueObject, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jmythapi.IVersionable
getVersionNr
 

Constructor Detail

ADatabaseRow

public ADatabaseRow(ProtocolVersion protoVersion,
                    int dbVersion,
                    Class<E> propsClass)

ADatabaseRow

public ADatabaseRow(ProtocolVersion protoVersion,
                    int dbVersion,
                    Class<E> propsClass,
                    List<String> data)
Method Detail

getDatabaseVersion

public int getDatabaseVersion()

getProperty

public E getProperty(int idx)
Description copied from interface: IPropertyAware
Gets the property for the given index.

This is the reverse operation of IPropertyAware.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)
       ));
    }
 

Specified by:
getProperty in interface IPropertyAware<E extends Enum<E>>
Specified by:
getProperty in class AData<E extends Enum<E>>
Parameters:
idx - the position within the property array
Returns:
the enumeration constant

getPropertyIndex

public int getPropertyIndex(E prop)
Description copied from interface: IPropertyAware
Gets the index for the given property.

This is the reverse operation of IPropertyAware.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)
       ));
    }
 

Specified by:
getPropertyIndex in interface IPropertyAware<E extends Enum<E>>
Specified by:
getPropertyIndex in class AData<E extends Enum<E>>
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.

getProperties

public EnumSet<E> getProperties()
Description copied from interface: IPropertyAware
Returns all supported properties.

Protocol Version Hint:

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

Specified by:
getProperties in interface IPropertyAware<E extends Enum<E>>
Specified by:
getProperties in class AData<E extends Enum<E>>
Returns:
all properties supported in the current protocol version

decodeProperty

protected <T> T decodeProperty(Class<T> dataType,
                               String dataValue)
Specified by:
decodeProperty in class AData<E extends Enum<E>>

encodeProperty

protected <S,T> String encodeProperty(Class<S> propObjectType,
                                      S propValue,
                                      Class<T> propStringType,
                                      String propDefaultValue)
Specified by:
encodeProperty in class AData<E extends Enum<E>>

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: AData
Creates a copy of this object.

Overrides:
clone in class AData<E extends Enum<E>>
Returns:
a copy of this object
Throws:
CloneNotSupportedException

equals

public boolean equals(Object obj)
Tests objects for equality.

Data objects are seen to be equal if the response to the following function calls are equal:

  1. Object.getClass()
  2. AData.getVersionNr()
  3. getDatabaseVersion()
  4. AData.getPropertyClass()
  5. AData.getPropertyValues()

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


Copyright © 2008-2013. All Rights Reserved.