📄 abstractdevice.java
字号:
/**
* Copyright (c) 2003-2005 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.model.impl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.mortbay.util.MultiException;
import eclipseme.core.IEclipseMECoreConstants;
import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.internal.overtheair.OTAServer;
import eclipseme.core.internal.preverification.builder.PreverificationBuilder;
import eclipseme.core.internal.utils.ColonDelimitedProperties;
import eclipseme.core.internal.utils.TemporaryFileManager;
import eclipseme.core.internal.utils.Utils;
import eclipseme.core.launching.ILaunchConstants;
import eclipseme.core.model.APIType;
import eclipseme.core.model.Classpath;
import eclipseme.core.model.ILibrary;
import eclipseme.core.model.IMidletSuiteProject;
import eclipseme.core.model.IPreverifier;
import eclipseme.core.model.device.IDevice;
import eclipseme.core.persistence.IBundleReferencePersistable;
import eclipseme.core.persistence.IPersistenceProvider;
import eclipseme.core.persistence.PersistenceException;
/**
* Abstract superclass of the various device implementations.
* <p />
* Copyright (c) 2003-2005 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.9 $
* <br>
* $Date: 2006/12/03 13:58:46 $
* <br>
* @author Craig Setera
*/
public abstract class AbstractDevice implements IDevice, IBundleReferencePersistable {
// Variables that define this device
protected String bundle;
protected Classpath classpath;
protected boolean debugServer;
protected String description;
protected Properties deviceProperties;
protected File executable;
protected String name;
protected String[] protectionDomains;
protected String groupName;
protected IPreverifier preverifier;
protected String launchCommandTemplate;
/**
* Test equality on a AbstractDevice and return a boolean
* indicating equality.
*
* @param device
* @return
*/
public boolean equals(AbstractDevice device) {
return
classpath.equals(device.classpath) &&
executable.equals(device.executable) &&
name.equals(device.name) &&
groupName.equals(device.groupName);
}
/**
* @see eclipseme.core.persistence.IBundleReferencePersistable#getBundle()
*/
public String getBundle() {
return bundle;
}
/**
* @see eclipseme.core.model.device.IDevice#getClasspath()
*/
public Classpath getClasspath() {
return classpath;
}
/**
* @see eclipseme.core.model.device.IDevice#getConfigurationLibrary()
*/
public ILibrary getConfigurationLibrary() {
return getLibraryWithType(APIType.CONFIGURATION);
}
/**
* @see eclipseme.core.model.device.IDevice#getDescription()
*/
public String getDescription() {
return description;
}
/**
* @see eclipseme.core.model.device.IDevice#getDeviceProperties()
*/
public Properties getDeviceProperties() {
return deviceProperties;
}
/**
* @return Returns the executable.
*/
public File getExecutable() {
return executable;
}
/**
* @see eclipseme.core.model.device.IDevice#getName()
*/
public String getName() {
return name;
}
/**
* @see eclipseme.core.model.device.IDevice#getPreverifier()
*/
public IPreverifier getPreverifier() {
return preverifier;
}
/**
* @see eclipseme.core.model.device.IDevice#getProfileLibrary()
*/
public ILibrary getProfileLibrary() {
return getLibraryWithType(APIType.PROFILE);
}
/**
* @see eclipseme.core.model.device.IDevice#getProtectionDomains()
*/
public String[] getProtectionDomains() {
return protectionDomains;
}
/**
* @see eclipseme.core.model.device.IDevice#getGroupName()
*/
public String getGroupName() {
return groupName;
}
/**
* @see eclipseme.core.model.device.IDevice#isDebugServer()
*/
public boolean isDebugServer() {
return debugServer;
}
/**
* @see eclipseme.core.model.device.IDevice#isPredeploymentRequired()
* @deprecated this method is no longer called during launching
*/
public boolean isPredeploymentRequired() {
return false;
}
/**
* @see eclipseme.core.persistence.IPersistable#loadUsing(eclipseme.core.persistence.IPersistenceProvider)
*/
public void loadUsing(IPersistenceProvider persistenceProvider)
throws PersistenceException
{
classpath = (Classpath) persistenceProvider.loadPersistable("classpath");
debugServer = persistenceProvider.loadBoolean("debugServer");
description = persistenceProvider.loadString("description");
deviceProperties = persistenceProvider.loadProperties("deviceProperties");
name = persistenceProvider.loadString("name");
protectionDomains = new String[persistenceProvider.loadInteger("protectionDomainsCount")];
for (int i = 0; i < protectionDomains.length; i++) {
protectionDomains[i] = persistenceProvider.loadString("protectionDomain" + i).trim();
}
groupName = persistenceProvider.loadString("groupName");
preverifier = (IPreverifier) persistenceProvider.loadPersistable("preverifier");
launchCommandTemplate = persistenceProvider.loadString("rawLaunchCommand");
String executableString = persistenceProvider.loadString("executable");
if ((executableString != null) && (executableString.trim().length() > 0)) {
executable = new File(executableString);
}
}
/**
* @param classpath The classpath to set.
*/
public void setClasspath(Classpath classpath) {
this.classpath = classpath;
}
/**
* @param debugServer The debugServer to set.
*/
public void setDebugServer(boolean debugServer) {
this.debugServer = debugServer;
}
/**
* @param description The description to set.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @param deviceProperties The deviceProperties to set.
*/
public void setDeviceProperties(Properties deviceProperties) {
this.deviceProperties = deviceProperties;
}
/**
* @param executable The executable to set.
*/
public void setExecutable(File executable) {
this.executable = executable;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @param predeploymentRequired The predeploymentRequired to set.
* @deprecated
*/
public void setPredeploymentRequired(boolean predeploymentRequired) {
}
/**
* @param preverifier The preverifier to set.
*/
public void setPreverifier(IPreverifier preverifier) {
this.preverifier = preverifier;
}
/**
* @param protectionDomains The protectionDomains to set.
*/
public void setProtectionDomains(String[] protectionDomains) {
this.protectionDomains = protectionDomains;
// Trim any spaces that could cause problems
for (int i = 0; i < protectionDomains.length; i++) {
protectionDomains[i] = protectionDomains[i].trim();
}
}
/**
* @param groupName The groupName to set.
*/
public void setGroupName(String groupName) {
this.groupName = groupName;
}
/**
* @see eclipseme.core.persistence.IPersistable#storeUsing(eclipseme.core.persistence.IPersistenceProvider)
*/
public void storeUsing(IPersistenceProvider persistenceProvider)
throws PersistenceException
{
persistenceProvider.storePersistable("classpath", classpath);
persistenceProvider.storeBoolean("debugServer", debugServer);
persistenceProvider.storeString("description", description);
persistenceProvider.storeProperties("deviceProperties", deviceProperties);
persistenceProvider.storeString("name", name);
persistenceProvider.storeInteger("protectionDomainsCount", protectionDomains.length);
for (int i = 0; i < protectionDomains.length; i++) {
persistenceProvider.storeString("protectionDomain" + i, protectionDomains[i]);
}
persistenceProvider.storeString("groupName", groupName);
persistenceProvider.storePersistable("preverifier", preverifier);
persistenceProvider.storeString("rawLaunchCommand", launchCommandTemplate);
if (executable != null) {
persistenceProvider.storeString("executable", executable.toString());
}
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
StringBuffer sb = new StringBuffer(getGroupName());
sb.append("/").append(getName());
return sb.toString();
}
/**
* @see eclipseme.core.persistence.IBundleReferencePersistable#setBundle(java.lang.String)
*/
public void setBundle(String bundle) {
this.bundle = bundle;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -