de.unikassel.android.sdcframework.preferences
Class SDCConfigurationManager

Package class diagram package SDCConfigurationManager
java.lang.Object
  extended by de.unikassel.android.sdcframework.preferences.SDCConfigurationManager

public final class SDCConfigurationManager
extends Object

Implementation of a management component responsible to handle the preconfigured default configuration, respectively to read it from the file and update the default values in a preference manager instance.
The default configuration can be defined in an XML file, which is located in the projects asset folder.
A configuration example is given in the documentation of the class SDCConfiguration.


Field Summary
private  boolean isUsingExternalConfiguration
          Flag for the usage of an uploaded external configuration file;
private  Map<SensorDeviceIdentifier,SensorDeviceConfiguration> mapDeviceDefaults
          The map with available device defaults
private  SDCConfiguration sdcConfiguration
          The service configuration
 
Constructor Summary
SDCConfigurationManager(Context appContext, String configFileName)
          Constructor
 
Method Summary
private  ServiceConfiguration createServiceConfiguration(ApplicationPreferenceManager appPrefManager)
          Method to create a service default configuration from the XML file preferences to update the application preference defaults
private  TimeProviderConfiguration createTimeProviderConfiguration(ApplicationPreferenceManager appPrefManager)
          Method to create a time provider default configuration from the XML file entries to update the application preference defaults
 Set<SensorDeviceIdentifier> getListDevices()
          Getter for the configured sensor devices
 boolean isUsingExternalConfiguration()
          Method to test, if an external configuration is used.
 void onDestroy()
          Method to clean up before class can be destroyed
private  void readDefaults(InputStream is)
          Does read the defaults from an input stream.
private  void readDefaultsFromAssetFolder(Context appContext, String configFileName)
          Does read the defaults from the configuration file
private  boolean readDefaultsFromPrivateFileFolder(Context appContext, String configFileName)
          Does read the defaults from the configuration file
 void updateDefaults(ApplicationPreferenceManager appPrefManager)
          Does update defaults for the managed device preferences
private  void updateDefaults(SensorDevicePreferences devicePreferences)
          Does update preference defaults by pre-configured defaults if available
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapDeviceDefaults

private final Map<SensorDeviceIdentifier,SensorDeviceConfiguration> mapDeviceDefaults
The map with available device defaults


sdcConfiguration

private SDCConfiguration sdcConfiguration
The service configuration


isUsingExternalConfiguration

private final boolean isUsingExternalConfiguration
Flag for the usage of an uploaded external configuration file;

Constructor Detail

SDCConfigurationManager

public SDCConfigurationManager(Context appContext,
                               String configFileName)
Constructor

Parameters:
appContext - the application context
configFileName - the configuration file name
Method Detail

readDefaultsFromPrivateFileFolder

private final boolean readDefaultsFromPrivateFileFolder(Context appContext,
                                                        String configFileName)
Does read the defaults from the configuration file

Parameters:
appContext - the application context
configFileName - the configuration file name

readDefaultsFromAssetFolder

private final void readDefaultsFromAssetFolder(Context appContext,
                                               String configFileName)
Does read the defaults from the configuration file

Parameters:
appContext - the application context
configFileName - the configuration file name

readDefaults

private final void readDefaults(InputStream is)
                         throws Exception
Does read the defaults from an input stream.

Parameters:
is - the input stream
Throws:
Exception

updateDefaults

private final void updateDefaults(SensorDevicePreferences devicePreferences)
Does update preference defaults by pre-configured defaults if available

Parameters:
devicePreferences - the sensor device to update defaults for

updateDefaults

public final void updateDefaults(ApplicationPreferenceManager appPrefManager)
Does update defaults for the managed device preferences

Parameters:
appPrefManager - the application preference manager

createTimeProviderConfiguration

private TimeProviderConfiguration createTimeProviderConfiguration(ApplicationPreferenceManager appPrefManager)
Method to create a time provider default configuration from the XML file entries to update the application preference defaults

Parameters:
appPrefManager - the application preference manager
Returns:
an updated default configuration for the time provider preferences

createServiceConfiguration

private ServiceConfiguration createServiceConfiguration(ApplicationPreferenceManager appPrefManager)
Method to create a service default configuration from the XML file preferences to update the application preference defaults

Parameters:
appPrefManager - the application preference manager
Returns:
an updated default configuration for the service preferences

onDestroy

public final void onDestroy()
Method to clean up before class can be destroyed


getListDevices

public Set<SensorDeviceIdentifier> getListDevices()
Getter for the configured sensor devices

Returns:
a list of the configured sensor devices to be supported by the SDC service

isUsingExternalConfiguration

public boolean isUsingExternalConfiguration()
Method to test, if an external configuration is used.

Returns:
true if an external configuration is used, false otherwise