KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.pde.internal.core.ibundle.IBundle;
14 import org.osgi.framework.Constants;
15
16 public class BundleSymbolicNameHeader extends SingleManifestHeader {
17
18     private static final long serialVersionUID = 1L;
19
20     public BundleSymbolicNameHeader(String JavaDoc name, String JavaDoc value, IBundle bundle, String JavaDoc lineDelimiter) {
21         super(name, value, bundle, lineDelimiter);
22     }
23     
24     public void setId(String JavaDoc id) {
25         setMainComponent(id);
26     }
27     
28     public String JavaDoc getId() {
29         return getMainComponent();
30     }
31     
32     public void setSingleton(boolean singleton) {
33         if (getManifestVersion() > 1) {
34             setDirective(Constants.SINGLETON_DIRECTIVE,
35                         singleton ? Boolean.toString(true) : null);
36             if (getAttribute(Constants.SINGLETON_DIRECTIVE) != null)
37                 setAttribute(Constants.SINGLETON_DIRECTIVE, null);
38         } else {
39             setAttribute(Constants.SINGLETON_DIRECTIVE,
40                     singleton ? Boolean.toString(true) : null);
41             if (getDirective(Constants.SINGLETON_DIRECTIVE) != null)
42                 setDirective(Constants.SINGLETON_DIRECTIVE, null);
43         }
44     }
45     
46     public boolean isSingleton() {
47         String JavaDoc value = getManifestVersion() > 1
48                         ? getDirective(Constants.SINGLETON_DIRECTIVE)
49                         : getAttribute(Constants.SINGLETON_DIRECTIVE);
50         return "true".equals(value); //$NON-NLS-1$
51
}
52     
53     public void fixUnsupportedDirective() {
54         String JavaDoc value = getDirective(Constants.SINGLETON_DIRECTIVE);
55         if (value != null) {
56             setAttribute(Constants.SINGLETON_DIRECTIVE, value);
57             setDirective(Constants.SINGLETON_DIRECTIVE, null);
58         }
59     }
60     
61     
62 }
63
Popular Tags