KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > text > bundle > BundleModelFactory


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.text.bundle;
12
13 import org.eclipse.jface.text.TextUtilities;
14 import org.eclipse.pde.internal.core.ICoreConstants;
15 import org.eclipse.pde.internal.core.ibundle.IBundle;
16 import org.eclipse.pde.internal.core.ibundle.IBundleModel;
17 import org.eclipse.pde.internal.core.ibundle.IBundleModelFactory;
18 import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
19 import org.osgi.framework.Constants;
20
21 public class BundleModelFactory implements IBundleModelFactory {
22     
23     private IBundleModel fModel;
24
25     public BundleModelFactory(IBundleModel model) {
26         fModel = model;
27     }
28     
29
30     public IManifestHeader createHeader() {
31         return null;
32     }
33
34     public IManifestHeader createHeader(String JavaDoc key, String JavaDoc value) {
35         ManifestHeader header = null;
36         IBundle bundle = fModel.getBundle();
37         String JavaDoc newLine;
38         if (fModel instanceof BundleModel)
39             newLine = TextUtilities.getDefaultLineDelimiter(((BundleModel)fModel).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, newLine);
45         } else if (key.equalsIgnoreCase(Constants.BUNDLE_LOCALIZATION)){
46             header = new BundleLocalizationHeader(key, value, bundle, newLine);
47         } else if (key.equalsIgnoreCase(Constants.BUNDLE_NAME)) {
48             header = new BundleNameHeader(key, value, bundle, newLine);
49         } else if (key.equalsIgnoreCase(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)) {
50             header = new RequiredExecutionEnvironmentHeader(key, value, bundle, newLine);
51         } else if (key.equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME)) {
52             header = new BundleSymbolicNameHeader(key, value, bundle, newLine);
53         } else if (key.equalsIgnoreCase(Constants.BUNDLE_VENDOR)) {
54             header = new BundleVendorHeader(key, value, bundle, newLine);
55         } else if (key.equalsIgnoreCase(Constants.BUNDLE_VERSION)) {
56             header = new BundleVersionHeader(key, value, bundle, newLine);
57         } else if (key.equalsIgnoreCase(Constants.BUNDLE_CLASSPATH)) {
58             header = new BundleClasspathHeader(key, value, bundle, newLine);
59         } else if (key.equalsIgnoreCase(ICoreConstants.ECLIPSE_LAZYSTART) || key.equalsIgnoreCase(ICoreConstants.ECLIPSE_AUTOSTART)) {
60             header = new LazyStartHeader(key, value, bundle, newLine);
61         } else if (key.equalsIgnoreCase(Constants.EXPORT_PACKAGE) || key.equalsIgnoreCase(ICoreConstants.PROVIDE_PACKAGE)) {
62             header = new ExportPackageHeader(key, value, bundle, newLine);
63         } else if (key.equalsIgnoreCase(Constants.FRAGMENT_HOST)) {
64             header = new FragmentHostHeader(key, value, bundle, newLine);
65         } else if (key.equalsIgnoreCase(Constants.IMPORT_PACKAGE)){
66             header = new ImportPackageHeader(key, value, bundle, newLine);
67         } else if (key.equalsIgnoreCase(Constants.REQUIRE_BUNDLE)) {
68             header = new RequireBundleHeader(key, value, bundle, newLine);
69         } else {
70             header = new ManifestHeader(key, value, bundle, newLine);
71         }
72         return header;
73     }
74
75 }
76
Popular Tags