KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > core > Import


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.update.core;
12
13 import org.eclipse.update.core.model.ImportModel;
14 import org.eclipse.update.internal.core.UpdateCore;
15 import org.eclipse.update.internal.core.UpdateManagerUtils;
16
17 /**
18  * Convenience implementation of a plug-in dependency.
19  * <p>
20  * This class may be instantiated or subclassed by clients.
21  * </p>
22  * <p>
23  * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
24  * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
25  * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
26  * (repeatedly) as the API evolves.
27  * </p>
28  * @see org.eclipse.update.core.IImport
29  * @see org.eclipse.update.core.model.ImportModel
30  * @since 2.0
31  */

32 public class Import extends ImportModel implements IImport {
33
34     //PERF: new instance variable
35
private VersionedIdentifier versionId;
36
37     /**
38      * Returns an identifier of the dependent plug-in.
39      * @see IImport#getVersionedIdentifier()
40      */

41     public VersionedIdentifier getVersionedIdentifier() {
42         if (versionId != null)
43             return versionId;
44
45         String JavaDoc id = getIdentifier();
46         String JavaDoc ver = getVersion();
47         if (id != null && ver != null) {
48             try {
49                 versionId = new VersionedIdentifier(id, ver);
50                 return versionId;
51             } catch (Exception JavaDoc e) {
52                 UpdateCore.warn("Unable to create versioned identifier:" + id + ":" + ver); //$NON-NLS-1$ //$NON-NLS-2$
53
}
54         }
55
56         
57         versionId = new VersionedIdentifier("",null); //$NON-NLS-1$
58
return versionId;
59     }
60
61     /**
62      * Returns the matching rule for the dependency.
63      * @see IImport#getRule()
64      */

65     public int getRule() {
66         return UpdateManagerUtils.getMatchingRule(getMatchingRuleName());
67     }
68     
69     /**
70      * Returns the matching rule for the dependency identifier.
71      * @see IImport#getIdRule()
72      */

73     public int getIdRule() {
74         return UpdateManagerUtils.getMatchingIdRule(getMatchingIdRuleName());
75     }
76     
77     /**
78      *
79      * @see org.eclipse.update.core.IImport#getKind()
80      */

81
82     /**
83      * Returns the dependency kind
84      * @see org.eclipse.update.core.IImport#getKind()
85      */

86     public int getKind() {
87         return isFeatureImport()?KIND_FEATURE:KIND_PLUGIN;
88     }
89
90 }
91
Popular Tags