1 11 package org.eclipse.pde.internal.core.text.bundle; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.jdt.launching.environments.IExecutionEnvironment; 16 import org.eclipse.osgi.util.ManifestElement; 17 import org.eclipse.pde.internal.core.ibundle.IBundle; 18 19 public class RequiredExecutionEnvironmentHeader extends CompositeManifestHeader { 20 21 private static final long serialVersionUID = 1L; 22 23 public RequiredExecutionEnvironmentHeader(String name, String value, IBundle bundle, String lineDelimiter) { 24 super(name, value, bundle, lineDelimiter); 25 } 26 27 protected PDEManifestElement createElement(ManifestElement element) { 28 return new ExecutionEnvironment(this, element.getValue()); 29 } 30 31 public boolean hasExecutionEnvironment(IExecutionEnvironment env) { 32 return hasElement(env.getId()); 33 } 34 35 public void addExecutionEnvironment(IExecutionEnvironment env) { 36 addManifestElement(new ExecutionEnvironment(this, env.getId())); 37 } 38 39 public void addExecutionEnvironments(Object [] envs) { 40 ArrayList list = new ArrayList (envs.length); 41 for (int i = 0; i < envs.length; i++) { 42 ExecutionEnvironment env = null; 43 if (envs[i] instanceof ExecutionEnvironment) { 44 env = (ExecutionEnvironment)envs[i]; 45 } else if (envs[i] instanceof IExecutionEnvironment) { 46 env = new ExecutionEnvironment(this, ((IExecutionEnvironment)envs[i]).getId()); 47 } 48 if (env != null && !hasElement(env.getName())) 49 list.add(env); 50 } 51 52 if (list.size() > 0) 53 addManifestElements((ExecutionEnvironment[])list.toArray(new ExecutionEnvironment[list.size()])); 54 } 55 56 public void addExecutionEnvironments(ExecutionEnvironment[] envs) { 57 addManifestElements(envs); 58 } 59 60 public ExecutionEnvironment removeExecutionEnvironment(ExecutionEnvironment env) { 61 return (ExecutionEnvironment)removeManifestElement(env); 62 } 63 64 public ExecutionEnvironment[] getEnvironments() { 65 PDEManifestElement[] elements = getElements(); 66 ExecutionEnvironment[] result = new ExecutionEnvironment[elements.length]; 67 System.arraycopy(elements, 0, result, 0, elements.length); 68 return result; 69 } 70 71 } 72 | Popular Tags |