de.enough.polish.devices
Class DeviceDatabase

java.lang.Object
  extended by de.enough.polish.devices.DeviceDatabase

public class DeviceDatabase
extends Object

Manages the complete device database.

Copyright Enough Software 2005 - 2012

Author:
Robert Virkus, j2mepolish@enough.de

Constructor Summary
DeviceDatabase()
          Creates a new device database, please call init() right after the initialization.
DeviceDatabase(File polishHome)
          Creates a new device database.
DeviceDatabase(Map properties, File polishHome, File projectHome, File apisHome, PolishProject polishProject, Map inputStreamsByFileName, Map customFilesByFileName)
          Creates a new device database.
 
Method Summary
 void clear()
          Clears all referenced objects and databases from the memory.
 File getApisHome()
           
 CapabilityManager getCapabilityManager()
           
 ConfigurationManager getConfigurationManager()
           
 Configuration[] getConfigurations()
           
 Device getDevice(String identifier)
          Retrieves the specified device or null when not found.
 DeviceManager getDeviceManager()
           
 Device[] getDevices()
           
 Device[] getDevices(Configuration configuration)
          Retrieves all devices with support for the specified configuration.
 Device[] getDevices(Platform platform)
          Retrieves all devices with support for the specified platform.
 DeviceGroupManager getGroupManager()
           
static DeviceDatabase getInstance(File polishHome)
          Creates a new device database.
static DeviceDatabase getInstance(Map properties, File polishHome, File projectHome, File apisHome, PolishProject polishProject, Map inputStreamsByFileName, Map customFilesByFileName)
          Creates a new device database.
 Library[] getLibraries()
           
 LibraryManager getLibraryManager()
           
 PlatformManager getPlatformManager()
           
 Platform[] getPlatforms()
           
 File getPolishHome()
           
 VendorManager getVendorManager()
           
 void init(File polishHomeDir)
          Initializes a new Device Database.
 void init(Map properties, File polishHomeDir, File projectHomeDir, File apisHomeDir, PolishProject polishProject, Map inputStreamsByFileName, Map customFilesByFileName)
          Initializes a new device database.
static Device loadDevice(File polishHome, String identifier)
          Loads only the specified device.
static Device[] loadDevices(File polishHome, String[] identifiers)
          Loads only the specified devices.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeviceDatabase

public DeviceDatabase()
Creates a new device database, please call init() right after the initialization.

See Also:
init(Map, File, File, File, PolishProject, Map, Map)

DeviceDatabase

public DeviceDatabase(File polishHome)
Creates a new device database.

Parameters:
polishHome - the installation directory of J2ME Polish

DeviceDatabase

public DeviceDatabase(Map properties,
                      File polishHome,
                      File projectHome,
                      File apisHome,
                      PolishProject polishProject,
                      Map inputStreamsByFileName,
                      Map customFilesByFileName)
Creates a new device database.

Parameters:
properties - configuration settings, like the optional wtk.home key
polishHome - the installation directory of J2ME Polish
projectHome - the project's directory
apisHome - the default import folder, can be null (in which case ${polish.home}/import is used)
polishProject - basic settings, can be null
inputStreamsByFileName - the configured input streams, can be null
customFilesByFileName - user-defined XLM configuration files, can be null
Method Detail

init

public void init(File polishHomeDir)
Initializes a new Device Database.

Parameters:
polishHomeDir - the polish.home setting

init

public void init(Map properties,
                 File polishHomeDir,
                 File projectHomeDir,
                 File apisHomeDir,
                 PolishProject polishProject,
                 Map inputStreamsByFileName,
                 Map customFilesByFileName)
Initializes a new device database.

Parameters:
properties - configuration settings, like the optional wtk.home key
polishHomeDir - the installation directory of J2ME Polish
projectHomeDir - the project's directory
apisHomeDir - the default import folder, can be null (in which case ${polish.home}/import is used)
polishProject - basic settings, can be null
inputStreamsByFileName - the configured input streams, can be null
customFilesByFileName - user-defined XLM configuration files, can be null

getInstance

public static final DeviceDatabase getInstance(File polishHome)
Creates a new device database.

Parameters:
polishHome - the installation directory of J2ME Polish
Returns:
a DeviceDatabase object.
Throws:
BuildException - thrown when something went wrong.

getInstance

public static final DeviceDatabase getInstance(Map properties,
                                               File polishHome,
                                               File projectHome,
                                               File apisHome,
                                               PolishProject polishProject,
                                               Map inputStreamsByFileName,
                                               Map customFilesByFileName)
Creates a new device database.

Parameters:
properties - configuration settings, like the optional wtk.home key
polishHome - the installation directory of J2ME Polish. Must not be null.
projectHome - the project's directory
apisHome - the default import folder, can be null (in which case ${polish.home}/import is used)
polishProject - basic settings, can be null
inputStreamsByFileName - the configured input streams, can be null
customFilesByFileName - user-defined XML configuration files, can be null
Returns:
a DeviceDatabase object.
Throws:
BuildException - thrown when something went wrong.

loadDevices

public static Device[] loadDevices(File polishHome,
                                   String[] identifiers)
Loads only the specified devices. This call ignores all other device definitions and is thus less memory intensive and much faster than using a regular device database.

Parameters:
polishHome - the location of the J2ME Polish installation dir
identifiers - the identifiers of the devices like "Nokia/N70"
Returns:
the found device definitions, not necessarily the same length as the specified identifiers, when a device has not been found.

loadDevice

public static Device loadDevice(File polishHome,
                                String identifier)
Loads only the specified device. This call ignores all other device definitions and is thus less memory intensive and much faster than using a regular device database.

Parameters:
polishHome - the location of the J2ME Polish installation dir
identifier - the identifier of the devic like "Nokia/N70"
Returns:
the found device definition
Throws:
IllegalArgumentException - when the device with the given identifier was not found

getCapabilityManager

public CapabilityManager getCapabilityManager()
Returns:
Returns the capabilityManager.

getDeviceManager

public DeviceManager getDeviceManager()
Returns:
Returns the deviceManager.

getGroupManager

public DeviceGroupManager getGroupManager()
Returns:
Returns the groupManager.

getLibraryManager

public LibraryManager getLibraryManager()
Returns:
Returns the libraryManager.

getVendorManager

public VendorManager getVendorManager()
Returns:
Returns the vendorManager.

getPlatformManager

public PlatformManager getPlatformManager()
Returns:
Returns the manager of platforms.

getConfigurationManager

public ConfigurationManager getConfigurationManager()
Returns:
Returns the configurationManager.

getPolishHome

public File getPolishHome()

getApisHome

public File getApisHome()

getConfigurations

public Configuration[] getConfigurations()

getPlatforms

public Platform[] getPlatforms()

getLibraries

public Library[] getLibraries()

getDevices

public Device[] getDevices()

getDevice

public Device getDevice(String identifier)
Retrieves the specified device or null when not found.

Parameters:
identifier - the identifier like "Nokia/6630", "Generic/midp2"
Returns:
the device or null when not found.

clear

public void clear()
Clears all referenced objects and databases from the memory.


getDevices

public Device[] getDevices(Platform platform)
Retrieves all devices with support for the specified platform.

Parameters:
platform - the platform that should be supported by the device
Returns:
a list of devices suporting that specific platform, can be empty

getDevices

public Device[] getDevices(Configuration configuration)
Retrieves all devices with support for the specified configuration.

Parameters:
configuration - the configuration that should be supported by the device
Returns:
a list of devices suporting that specific configuration, can be empty

main

public static void main(String[] args)