Mobile Tools for Java
Release 1.0

org.eclipse.mtj.core.model.device.impl
Class AbstractDevice

java.lang.Object
  extended by org.eclipse.mtj.core.model.device.impl.AbstractDevice
All Implemented Interfaces:
IDevice, IBundleReferencePersistable, IPersistable
Direct Known Subclasses:
JavaEmulatorDevice, UEIDevice

public abstract class AbstractDevice
extends Object
implements IDevice, IBundleReferencePersistable

Abstract superclass of the various device implementations.


Field Summary
protected  String bundle
           
protected  Classpath classpath
           
protected  boolean debugServer
           
protected  String description
           
protected  Properties deviceProperties
           
protected  File executable
           
protected  String groupName
           
protected  String launchCommandTemplate
           
protected  String name
           
protected  IPreverifier preverifier
           
protected  String[] protectionDomains
           
 
Constructor Summary
AbstractDevice()
           
 
Method Summary
protected  void addLaunchConfigurationValue(Map<String,String> executionProperties, String propertyName, ILaunchConfiguration launchConfiguration, String launchConstant)
          Add a value from the launch configuration to the execution properties map.
protected  File copyForLaunch(IMidletSuiteProject suite, IProgressMonitor monitor, boolean launchFromJad)
          Copy the deployed jar and jad for use during launching.
 boolean equals(AbstractDevice device)
          Test equality on a AbstractDevice and return a boolean indicating equality.
 String getBundle()
          Return the bundle identifier that should be used to load this persistable.
 Classpath getClasspath()
          Return the classpath provided by this device.
 ILibrary getConfigurationLibrary()
          Return the library that provides the configuration for this device or null if no such library can be found.
 String getDescription()
          Return the displayable description of this device.
 Properties getDeviceProperties()
          Return the properties associated with this device.
 File getExecutable()
           
 String getGroupName()
          Return the name of the device group to which this device belongs.
protected  File getJadForLaunch(IMidletSuiteProject midletSuite, File temporaryDirectory, IProgressMonitor monitor)
          Return the JAD file to use for launching from the specified temporary directory.
 String getLaunchCommandTemplate()
           
 String getName()
          Return the name of this device.
protected  String getOTAURL(ILaunchConfiguration launchConfig, IMidletSuiteProject midletSuite)
          Return the Over the Air URL for accessing the JAD file via the built-in OTA HTTP server.
 IPreverifier getPreverifier()
          Return the preverifier to be used to preverify classes for this device.
 ILibrary getProfileLibrary()
          Return the library that provides the profile for this device or null if no such library can be found.
protected  String getProjectClasspathString(IMidletSuiteProject midletSuite, File temporaryDirectory, IProgressMonitor monitor)
          Return the classpath string to be used when launching the specified project.
 String[] getProtectionDomains()
          Return the list of protection domains specified by this device.
protected  String getSpecifiedJadURL(ILaunchConfiguration launchConfiguration)
          Return the url specified by the user for direct launching or null if none was specified.
 boolean isDebugServer()
          Return a boolean describing whether this device wants to act as a debug server rather than attaching to the debugger as a client.
 boolean isPredeploymentRequired()
          Deprecated. this method is no longer called during launching
 void loadUsing(IPersistenceProvider persistenceProvider)
          Load the state of this object using the specified persistence state information.
 void setBundle(String bundle)
          Set the bundle identifier that is used to load this persistable.
 void setClasspath(Classpath classpath)
           
 void setDebugServer(boolean debugServer)
           
 void setDescription(String description)
           
 void setDeviceProperties(Properties deviceProperties)
           
 void setExecutable(File executable)
           
 void setGroupName(String groupName)
           
 void setLaunchCommandTemplate(String launchCommandTemplate)
           
 void setName(String name)
          Set the name of this device.
 void setPredeploymentRequired(boolean predeploymentRequired)
          Deprecated.  
 void setPreverifier(IPreverifier preverifier)
           
 void setProtectionDomains(String[] protectionDomains)
           
protected  boolean shouldDirectLaunchJAD(ILaunchConfiguration configuration)
          Return a boolean indicating whether or not the emulation should just directly launch a specified JAD URL without the other things that normally happen during launching.
protected  boolean shouldDoOTA(ILaunchConfiguration configuration)
          Return a boolean indicating whether or not the emulation should be launched as OTA.
 void storeUsing(IPersistenceProvider persistenceProvider)
          Save the state of this object using the specified persistence state information.
 String toString()
           
protected  String urlEncoded(String value)
          Encode the specified information for a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.mtj.core.model.device.IDevice
getLaunchCommand
 

Field Detail

bundle

protected String bundle

classpath

protected Classpath classpath

debugServer

protected boolean debugServer

description

protected String description

deviceProperties

protected Properties deviceProperties

executable

protected File executable

name

protected String name

protectionDomains

protected String[] protectionDomains

groupName

protected String groupName

preverifier

protected IPreverifier preverifier

launchCommandTemplate

protected String launchCommandTemplate
Constructor Detail

AbstractDevice

public AbstractDevice()
Method Detail

equals

public boolean equals(AbstractDevice device)
Test equality on a AbstractDevice and return a boolean indicating equality.

Parameters:
device -
Returns:

getBundle

public String getBundle()
Description copied from interface: IBundleReferencePersistable
Return the bundle identifier that should be used to load this persistable.

Specified by:
getBundle in interface IBundleReferencePersistable
Returns:
See Also:
IBundleReferencePersistable.getBundle()

getClasspath

public Classpath getClasspath()
Description copied from interface: IDevice
Return the classpath provided by this device. This classpath includes all libraries for the device including configuration and profile libraries.

Specified by:
getClasspath in interface IDevice
Returns:
See Also:
IDevice.getClasspath()

getConfigurationLibrary

public ILibrary getConfigurationLibrary()
Description copied from interface: IDevice
Return the library that provides the configuration for this device or null if no such library can be found.

Specified by:
getConfigurationLibrary in interface IDevice
Returns:
See Also:
IDevice.getConfigurationLibrary()

getDescription

public String getDescription()
Description copied from interface: IDevice
Return the displayable description of this device. This description will be displayed within the user interface. If this method returns a null value, the device's name will be used as the description instead.

Specified by:
getDescription in interface IDevice
Returns:
the description of this device or null if the device's name should be used instead.

getDeviceProperties

public Properties getDeviceProperties()
Description copied from interface: IDevice
Return the properties associated with this device. The available properties will vary from emulator to emulator.

Specified by:
getDeviceProperties in interface IDevice
Returns:
the properties associated with this device.

getExecutable

public File getExecutable()
Returns:
Returns the executable.

getName

public String getName()
Description copied from interface: IDevice
Return the name of this device. This name will be used when interacting with the emulator. This name may or may not be displayed within the user interface, dependent on whether a display name is provided by this device. This method must never return null.

Specified by:
getName in interface IDevice
Returns:
the non-null name of this device.

getPreverifier

public IPreverifier getPreverifier()
Description copied from interface: IDevice
Return the preverifier to be used to preverify classes for this device.

Specified by:
getPreverifier in interface IDevice
Returns:
the platform's preverifier

getProfileLibrary

public ILibrary getProfileLibrary()
Description copied from interface: IDevice
Return the library that provides the profile for this device or null if no such library can be found.

Specified by:
getProfileLibrary in interface IDevice
Returns:

getProtectionDomains

public String[] getProtectionDomains()
Description copied from interface: IDevice
Return the list of protection domains specified by this device. Returning null from this method will imply that this device does not support protection domains.

Specified by:
getProtectionDomains in interface IDevice
Returns:
the list of protection domains or null if the device does not provide any protection domains.

getGroupName

public String getGroupName()
Description copied from interface: IDevice
Return the name of the device group to which this device belongs. This method must not return a null value.

Specified by:
getGroupName in interface IDevice
Returns:

isDebugServer

public boolean isDebugServer()
Description copied from interface: IDevice
Return a boolean describing whether this device wants to act as a debug server rather than attaching to the debugger as a client.

Specified by:
isDebugServer in interface IDevice
Returns:
if the device acts as a debug server

isPredeploymentRequired

public boolean isPredeploymentRequired()
Deprecated. this method is no longer called during launching

Description copied from interface: IDevice
Return a boolean indicating whether this device requires a deployed jar file to be created before launch can be done. If this device requires pre-deployment, standard packaging (without obfuscation) will be done if the currently deployed jar file is not up to date.

Specified by:
isPredeploymentRequired in interface IDevice
Returns:
whether or not pre-deployment is necessary.
See Also:
IDevice.isPredeploymentRequired()

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

setClasspath

public void setClasspath(Classpath classpath)
Parameters:
classpath - The classpath to set.

setDebugServer

public void setDebugServer(boolean debugServer)
Parameters:
debugServer - The debugServer to set.

setDescription

public void setDescription(String description)
Parameters:
description - The description to set.

setDeviceProperties

public void setDeviceProperties(Properties deviceProperties)
Parameters:
deviceProperties - The deviceProperties to set.

setExecutable

public void setExecutable(File executable)
Parameters:
executable - The executable to set.

setName

public void setName(String name)
Description copied from interface: IDevice
Set the name of this device. This name will be used when interacting with the emulator. This name may or may not be displayed within the user interface, dependent on whether a display name is provided by this device. This method must never return null.

Specified by:
setName in interface IDevice
Parameters:
name - The name to set.

setPredeploymentRequired

public void setPredeploymentRequired(boolean predeploymentRequired)
Deprecated. 

Parameters:
predeploymentRequired - The predeploymentRequired to set.

setPreverifier

public void setPreverifier(IPreverifier preverifier)
Parameters:
preverifier - The preverifier to set.

setProtectionDomains

public void setProtectionDomains(String[] protectionDomains)
Parameters:
protectionDomains - The protectionDomains to set.

setGroupName

public void setGroupName(String groupName)
Parameters:
groupName - The groupName to set.

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

toString

public String toString()
Overrides:
toString in class Object

setBundle

public void setBundle(String bundle)
Description copied from interface: IBundleReferencePersistable
Set the bundle identifier that is used to load this persistable.

Specified by:
setBundle in interface IBundleReferencePersistable

getLaunchCommandTemplate

public String getLaunchCommandTemplate()
Returns:
Returns the launchCommandTemplate.

setLaunchCommandTemplate

public void setLaunchCommandTemplate(String launchCommandTemplate)
Parameters:
launchCommandTemplate - The launchCommandTemplate to set.

addLaunchConfigurationValue

protected void addLaunchConfigurationValue(Map<String,String> executionProperties,
                                           String propertyName,
                                           ILaunchConfiguration launchConfiguration,
                                           String launchConstant)
                                    throws CoreException
Add a value from the launch configuration to the execution properties map.

Parameters:
executionProperties -
propertyName -
launchConfiguration -
launchConstant -
Throws:
CoreException

copyForLaunch

protected File copyForLaunch(IMidletSuiteProject suite,
                             IProgressMonitor monitor,
                             boolean launchFromJad)
                      throws CoreException
Copy the deployed jar and jad for use during launching. Return the folder into which the copy has been made.

Parameters:
suite -
monitor -
launchFromJad - - If launch from a JAD file.
Returns:
Throws:
IOException
CoreException

getJadForLaunch

protected File getJadForLaunch(IMidletSuiteProject midletSuite,
                               File temporaryDirectory,
                               IProgressMonitor monitor)
Return the JAD file to use for launching from the specified temporary directory.

Parameters:
midletSuite -
temporaryDirectory -
monitor -
Returns:

getSpecifiedJadURL

protected String getSpecifiedJadURL(ILaunchConfiguration launchConfiguration)
                             throws CoreException
Return the url specified by the user for direct launching or null if none was specified.

Parameters:
launchConfiguration -
Returns:
Throws:
CoreException

shouldDirectLaunchJAD

protected boolean shouldDirectLaunchJAD(ILaunchConfiguration configuration)
                                 throws CoreException
Return a boolean indicating whether or not the emulation should just directly launch a specified JAD URL without the other things that normally happen during launching.

Parameters:
configuration -
Returns:
Throws:
CoreException

shouldDoOTA

protected boolean shouldDoOTA(ILaunchConfiguration configuration)
                       throws CoreException
Return a boolean indicating whether or not the emulation should be launched as OTA.

Parameters:
configuration -
Returns:
Throws:
CoreException

urlEncoded

protected String urlEncoded(String value)
Encode the specified information for a URL.

Parameters:
value -
Returns:

getOTAURL

protected String getOTAURL(ILaunchConfiguration launchConfig,
                           IMidletSuiteProject midletSuite)
                    throws CoreException
Return the Over the Air URL for accessing the JAD file via the built-in OTA HTTP server.

Parameters:
launchConfig -
Returns:
Throws:
CoreException

getProjectClasspathString

protected String getProjectClasspathString(IMidletSuiteProject midletSuite,
                                           File temporaryDirectory,
                                           IProgressMonitor monitor)
                                    throws CoreException
Return the classpath string to be used when launching the specified project.

Parameters:
midletSuite -
Returns:
Throws:
CoreException

Mobile Tools for Java
Release 1.0