01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.text.bundle;
11:
12: import org.eclipse.jface.text.TextUtilities;
13: import org.eclipse.pde.internal.core.ICoreConstants;
14: import org.eclipse.pde.internal.core.ibundle.IBundle;
15: import org.eclipse.pde.internal.core.ibundle.IBundleModel;
16: import org.eclipse.pde.internal.core.ibundle.IBundleModelFactory;
17: import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
18: import org.osgi.framework.Constants;
19:
20: public class BundleModelFactory implements IBundleModelFactory {
21:
22: private IBundleModel fModel;
23:
24: public BundleModelFactory(IBundleModel model) {
25: fModel = model;
26: }
27:
28: public IManifestHeader createHeader() {
29: return null;
30: }
31:
32: public IManifestHeader createHeader(String key, String value) {
33: ManifestHeader header = null;
34: IBundle bundle = fModel.getBundle();
35: String newLine;
36: if (fModel instanceof BundleModel)
37: newLine = TextUtilities
38: .getDefaultLineDelimiter(((BundleModel) fModel)
39: .getDocument());
40: else
41: newLine = System.getProperty("line.separator"); //$NON-NLS-1$
42:
43: if (key.equalsIgnoreCase(Constants.BUNDLE_ACTIVATOR)) {
44: header = new BundleActivatorHeader(key, value, bundle,
45: newLine);
46: } else if (key.equalsIgnoreCase(Constants.BUNDLE_LOCALIZATION)) {
47: header = new BundleLocalizationHeader(key, value, bundle,
48: newLine);
49: } else if (key.equalsIgnoreCase(Constants.BUNDLE_NAME)) {
50: header = new BundleNameHeader(key, value, bundle, newLine);
51: } else if (key
52: .equalsIgnoreCase(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)) {
53: header = new RequiredExecutionEnvironmentHeader(key, value,
54: bundle, newLine);
55: } else if (key.equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME)) {
56: header = new BundleSymbolicNameHeader(key, value, bundle,
57: newLine);
58: } else if (key.equalsIgnoreCase(Constants.BUNDLE_VENDOR)) {
59: header = new BundleVendorHeader(key, value, bundle, newLine);
60: } else if (key.equalsIgnoreCase(Constants.BUNDLE_VERSION)) {
61: header = new BundleVersionHeader(key, value, bundle,
62: newLine);
63: } else if (key.equalsIgnoreCase(Constants.BUNDLE_CLASSPATH)) {
64: header = new BundleClasspathHeader(key, value, bundle,
65: newLine);
66: } else if (key
67: .equalsIgnoreCase(ICoreConstants.ECLIPSE_LAZYSTART)
68: || key
69: .equalsIgnoreCase(ICoreConstants.ECLIPSE_AUTOSTART)) {
70: header = new LazyStartHeader(key, value, bundle, newLine);
71: } else if (key.equalsIgnoreCase(Constants.EXPORT_PACKAGE)
72: || key.equalsIgnoreCase(ICoreConstants.PROVIDE_PACKAGE)) {
73: header = new ExportPackageHeader(key, value, bundle,
74: newLine);
75: } else if (key.equalsIgnoreCase(Constants.FRAGMENT_HOST)) {
76: header = new FragmentHostHeader(key, value, bundle, newLine);
77: } else if (key.equalsIgnoreCase(Constants.IMPORT_PACKAGE)) {
78: header = new ImportPackageHeader(key, value, bundle,
79: newLine);
80: } else if (key.equalsIgnoreCase(Constants.REQUIRE_BUNDLE)) {
81: header = new RequireBundleHeader(key, value, bundle,
82: newLine);
83: } else {
84: header = new ManifestHeader(key, value, bundle, newLine);
85: }
86: return header;
87: }
88:
89: }
|