Mobile Tools for Java
Release 1.0

org.eclipse.mtj.core.model.device
Class DeviceRegistry

java.lang.Object
  extended by org.eclipse.mtj.core.model.device.DeviceRegistry
All Implemented Interfaces:
IPersistable

public class DeviceRegistry
extends Object
implements IPersistable

The device registry provides a place to store and retrieve devices by name.

This registry is implemented as a multi-level registry in which the top-level device groups reference lower-level devices.


Field Summary
static DeviceRegistry singleton
          Singleton instance of the device registry
 
Method Summary
 void addDevice(IDevice device, boolean fireDeviceAddedEvent)
          Add a new device instance to the device registry.
 void addRegistryListener(IDeviceRegistryListener listener)
          Add the specified listener to the list of listeners for changes in this registry.
 void clear()
          Clear the registry of all entries.
 List<IDevice> getAllDevices()
          Return a list of all of the devices in the registry.
 IDevice getDefaultDevice()
          Return the default device or null if one is not specified.
 IPreverifier getDefaultPreferifier()
          Return the default preverifier or null if one is not specified.
 IDevice getDevice(String groupName, String deviceName)
          Return the device with the specified key or null if no such device is found in the registry.
 int getDeviceCount()
          Return the number of devices registered.
 List<String> getDeviceGroups()
          Return the registered device groups.
 List<IDevice> getDevices(String groupName)
          Return the devices found in the specified group or null if the specified group cannot be found.
 void load()
          Load the contents of the device registry from the storage file in the plug-in state location.
 void loadUsing(IPersistenceProvider persistenceProvider)
          Load the state of this object using the specified persistence state information.
 void removeDevice(IDevice device)
          Remove the specified device from the registry if it exists.
 void removeRegistryListener(IDeviceRegistryListener listener)
          Remove the specified listener to the list of listeners for changes in this registry.
 void setDefaultDevice(IDevice device)
          Set the default device.
 void setDefaultPreverifer(IPreverifier preverifier)
          Set the default preverifier.
 void store()
          Store out the contents of the registry into the standard device storage file in the plug-in state location.
 void storeUsing(IPersistenceProvider persistenceProvider)
          Save the state of this object using the specified persistence state information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

public static final DeviceRegistry singleton
Singleton instance of the device registry

Method Detail

addDevice

public void addDevice(IDevice device,
                      boolean fireDeviceAddedEvent)
               throws IllegalArgumentException,
                      PersistenceException
Add a new device instance to the device registry.

Parameters:
device -
fireDeviceAddedEvent - TODO
Throws:
IllegalArgumentException - if the device is not well formed.
PersistenceException - if there is a problem doing the initial registry load

addRegistryListener

public void addRegistryListener(IDeviceRegistryListener listener)
Add the specified listener to the list of listeners for changes in this registry.

Parameters:
listener -

clear

public void clear()
           throws PersistenceException
Clear the registry of all entries.

Throws:
PersistenceException - if there is a problem doing the initial registry load

getAllDevices

public List<IDevice> getAllDevices()
                            throws PersistenceException
Return a list of all of the devices in the registry.

Returns:
Throws:
PersistenceException - if there is a problem doing the initial registry load

getDefaultDevice

public IDevice getDefaultDevice()
Return the default device or null if one is not specified.

Returns:

getDevice

public IDevice getDevice(String groupName,
                         String deviceName)
                  throws PersistenceException
Return the device with the specified key or null if no such device is found in the registry.

Parameters:
groupName -
deviceName -
Returns:
Throws:
PersistenceException - if there is a problem doing the initial registry load

getDeviceCount

public int getDeviceCount()
                   throws PersistenceException
Return the number of devices registered.

Returns:
Throws:
PersistenceException - if there is a problem doing the initial registry load

getDeviceGroups

public List<String> getDeviceGroups()
                             throws PersistenceException
Return the registered device groups.

Returns:
Throws:
PersistenceException - if there is a problem doing the initial registry load

getDevices

public List<IDevice> getDevices(String groupName)
                         throws PersistenceException
Return the devices found in the specified group or null if the specified group cannot be found.

Parameters:
groupName -
Returns:
Throws:
PersistenceException

load

public void load()
          throws PersistenceException
Load the contents of the device registry from the storage file in the plug-in state location.

Throws:
PersistenceException

loadUsing

public void loadUsing(IPersistenceProvider persistenceProvider)
               throws PersistenceException
Description copied from interface: IPersistable
Load the state of this object using the specified persistence state information.

Specified by:
loadUsing in interface IPersistable
Throws:
PersistenceException
See Also:
IPersistable.loadUsing(org.eclipse.mtj.core.persistence.IPersistenceProvider)

removeDevice

public void removeDevice(IDevice device)
                  throws PersistenceException
Remove the specified device from the registry if it exists.

Parameters:
device -
Throws:
PersistenceException - if there is a problem doing the initial registry load

removeRegistryListener

public void removeRegistryListener(IDeviceRegistryListener listener)
Remove the specified listener to the list of listeners for changes in this registry.

Parameters:
listener -

setDefaultDevice

public void setDefaultDevice(IDevice device)
Set the default device.

Parameters:
device -

store

public void store()
           throws PersistenceException,
                  TransformerException,
                  IOException
Store out the contents of the registry into the standard device storage file in the plug-in state location.

Throws:
PersistenceException
TransformerException
IOException

storeUsing

public void storeUsing(IPersistenceProvider persistenceProvider)
                throws PersistenceException
Description copied from interface: IPersistable
Save the state of this object using the specified persistence state information.

Specified by:
storeUsing in interface IPersistable
Throws:
PersistenceException
See Also:
IPersistable.storeUsing(org.eclipse.mtj.core.persistence.IPersistenceProvider)

setDefaultPreverifer

public void setDefaultPreverifer(IPreverifier preverifier)
Set the default preverifier.

Parameters:
device -

getDefaultPreferifier

public IPreverifier getDefaultPreferifier()
Return the default preverifier or null if one is not specified.

Returns:

Mobile Tools for Java
Release 1.0