KickJava   Java API By Example, From Geeks To Geeks.

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


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

31 public class PluginEntry extends PluginEntryModel implements IPluginEntry {
32     
33     // PERF: new instance variable
34
private VersionedIdentifier versionId;
35
36     /**
37      * Plug-in entry default constructor
38      */

39     public PluginEntry() {
40         super();
41     }
42
43     /**
44      * Returns the identifier of this plugin entry
45      *
46      * @see IPluginEntry#getVersionedIdentifier()
47      * @since 2.0
48      */

49     public VersionedIdentifier getVersionedIdentifier() {
50         if (versionId != null)
51             return versionId;
52
53         String JavaDoc id = getPluginIdentifier();
54         String JavaDoc ver = getPluginVersion();
55         if (id != null && ver != null) {
56             try {
57                 versionId = new VersionedIdentifier(id, ver);
58                 return versionId;
59             } catch (Exception JavaDoc e) {
60                 UpdateCore.warn("Unable to create versioned identifier:" + id + ":" + ver); //$NON-NLS-1$ //$NON-NLS-2$
61
}
62         }
63
64         versionId = new VersionedIdentifier("",null); //$NON-NLS-1$
65
return versionId;
66     }
67
68     /**
69      * Sets the identifier of this plugin entry.
70      *
71      * @see IPluginEntry#setVersionedIdentifier(VersionedIdentifier)
72      * @since 2.0
73      */

74     public void setVersionedIdentifier(VersionedIdentifier identifier) {
75         setPluginIdentifier(identifier.getIdentifier());
76         setPluginVersion(identifier.getVersion().toString());
77     }
78
79     /**
80      * Compares two plugin entries for equality
81      *
82      * @param object plugin entry object to compare with
83      * @return <code>true</code> if the two entries are equal,
84      * <code>false</code> otherwise
85      * @since 2.0
86      */

87     public boolean equals(Object JavaDoc object) {
88         if (!(object instanceof IPluginEntry))
89             return false;
90         IPluginEntry e = (IPluginEntry) object;
91         return getVersionedIdentifier().equals(e.getVersionedIdentifier());
92     }
93
94 }
95
Popular Tags