01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.ui.wizards;
11:
12: import java.util.StringTokenizer;
13:
14: import org.eclipse.core.runtime.IConfigurationElement;
15:
16: public class Category {
17: private IConfigurationElement config;
18: private String[] parentCategoryPath;
19: public static final String ATT_ID = "id"; //$NON-NLS-1$
20: public static final String ATT_CATEGORY = "parentCategory"; //$NON-NLS-1$
21: public static final String ATT_NAME = "name"; //$NON-NLS-1$
22:
23: public Category(IConfigurationElement aConfig) {
24: config = aConfig;
25: }
26:
27: public String getID() {
28: return config.getAttribute(ATT_ID);
29: }
30:
31: public String getLabel() {
32: return config.getAttribute(ATT_NAME);
33: }
34:
35: public String[] getParentCategoryPath() {
36: if (parentCategoryPath != null)
37: return parentCategoryPath;
38: String category = config.getAttribute(ATT_CATEGORY);
39: if (category == null)
40: return null;
41: StringTokenizer stok = new StringTokenizer(category, "/"); //$NON-NLS-1$
42: parentCategoryPath = new String[stok.countTokens()];
43: for (int i = 0; stok.hasMoreTokens(); i++) {
44: parentCategoryPath[i] = stok.nextToken();
45: }
46: return parentCategoryPath;
47:
48: }
49: }
|