deviceimporterelement.java

来自「配置文件」· Java 代码 · 共 90 行

JAVA
90
字号
/**
 * Copyright (c) 2003-2006 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.device;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;

import eclipseme.core.importer.IDeviceImporter;

/**
 * Wraps an IConfigurationElement for use as a device importer.
 * <p />
 * Copyright (c) 2003-2006 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.1 $
 * <br>
 * $Date: 2006/02/11 21:26:57 $
 * <br>
 * @author Craig Setera
 */
public class DeviceImporterElement {
	private static final String ATTR_ID = "id";
	private static final String ATTR_NAME = "name";
	private static final String ATTR_CLASS = "class";
	private static final String ATTR_PRIORITY = "priority";
	
	private IConfigurationElement configurationElement;
	
	/**
	 * Construct a new wrapper around the specified element.
	 * 
	 * @param element
	 */
	public DeviceImporterElement(IConfigurationElement element) {
		super();
		configurationElement = element;
	}

	/**
	 * Get the device importer for the configuration element.
	 * 
	 * @return
	 * @throws CoreException
	 */
	public IDeviceImporter getDeviceImporter() 
		throws CoreException 
	{
		return (IDeviceImporter) configurationElement.createExecutableExtension(ATTR_CLASS);
	}
	
	/**
	 * Return the id of this extension element.
	 * 
	 * @return
	 */
	public String getId() {
		return configurationElement.getAttribute(ATTR_ID);
	}
	
	/**
	 * Return the name of this extension element.
	 * 
	 * @return
	 */
	public String getName() {
		return configurationElement.getAttribute(ATTR_NAME);
	}
	
	/**
	 * Return the priority of this element.
	 * 
	 * @return
	 */
	public int getPriority() {
		int priority = 50;
		
		try {
			priority = Integer.parseInt(configurationElement.getAttribute(ATTR_PRIORITY));
		} catch (NumberFormatException e) {}
		
		return priority;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?