KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > core > model > PluginEntryModel


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.model;
12
13
14 /**
15  * Plug-in entry model object.
16  * <p>
17  * This class may be instantiated or subclassed by clients. However, in most
18  * cases clients should instead instantiate or subclass the provided
19  * concrete implementation of this model.
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.PluginEntry
28  * @since 2.0
29  */

30 public class PluginEntryModel extends ContentEntryModel {
31
32     private String JavaDoc pluginId;
33     private String JavaDoc pluginVersion;
34     private boolean isFragment = false;
35     private boolean unpack = true;
36     
37     /**
38      * Creates a uninitialized plug-in entry model object.
39      *
40      * @since 2.0
41      */

42     public PluginEntryModel() {
43         super();
44     }
45
46     /**
47      * Compares two plug-in models for equality
48      *
49      * @param obj other model to compare to
50      * @return <code>true</code> if the models are equal, <code>false</code> otherwise
51      * @since 2.0
52      */

53     public boolean equals(Object JavaDoc obj) {
54         if (!(obj instanceof PluginEntryModel))
55             return false;
56         PluginEntryModel model = (PluginEntryModel) obj;
57         
58         return (
59             (getPluginIdentifier().equals(model.getPluginIdentifier()))
60                 && (getPluginVersion().equals(model.getPluginVersion()))
61                 && (isFragment() == model.isFragment()));
62     }
63
64     /**
65      * Returns the plug-in identifier for this entry.
66      *
67      * @return the plug-in identifier, or <code>null</code>
68      * @since 2.0
69      */

70     public String JavaDoc getPluginIdentifier() {
71         return pluginId;
72     }
73
74     /**
75      * Returns the plug-in version for this entry.
76      *
77      * @return the plug-in version, or <code>null</code>
78      * @since 2.0
79      */

80     public String JavaDoc getPluginVersion() {
81         return pluginVersion;
82     }
83
84     /**
85      * Indicates whether the entry describes a full plug-in, or
86      * a plug-in fragment.
87      *
88      * @return <code>true</code> if the entry is a plug-in fragment,
89      * <code>false</code> if the entry is a plug-in
90      * @since 2.0
91      */

92     public boolean isFragment() {
93         return isFragment;
94     }
95
96     /**
97      * Sets the entry plug-in identifier.
98      * Throws a runtime exception if this object is marked read-only.
99      *
100      * @param pluginId the entry identifier.
101      * @since 2.0
102      */

103     public void setPluginIdentifier(String JavaDoc pluginId) {
104         assertIsWriteable();
105         this.pluginId = pluginId;
106     }
107
108     /**
109      * Sets the entry plug-in version.
110      * Throws a runtime exception if this object is marked read-only.
111      *
112      * @param pluginVersion the entry version.
113      * @since 2.0
114      */

115     public void setPluginVersion(String JavaDoc pluginVersion) {
116         assertIsWriteable();
117         this.pluginVersion = pluginVersion;
118     }
119
120     /**
121      * Indicates whether this entry represents a fragment or plug-in.
122      * Throws a runtime exception if this object is marked read-only.
123      *
124      * @param isFragment fragment setting
125      * @since 2.0
126      */

127     public void isFragment(boolean isFragment) {
128         assertIsWriteable();
129         this.isFragment = isFragment;
130     }
131
132     /**
133      * @return Indicates whether plugin should be unpacked during installation
134      * or can run from a jar
135      * @since 3.0
136      */

137     public boolean isUnpack() {
138         // TODO this is a candidate for IPluginEntry API
139
return unpack;
140     }
141     /**
142      * @param unpack Sets whether plugin should be unpacked during installation
143      * or can run from a jar
144      * @since 3.0
145      *
146      */

147     public void setUnpack(boolean unpack) {
148         // TODO this is a candidate for IPluginEntry API
149
assertIsWriteable();
150         this.unpack = unpack;
151     }
152
153     /**
154      * @see Object#toString()
155      */

156     public String JavaDoc toString() {
157         String JavaDoc msg = (getPluginIdentifier()!=null)?getPluginIdentifier().toString():""; //$NON-NLS-1$
158
msg += getPluginVersion()!=null?" "+getPluginVersion().toString():""; //$NON-NLS-1$ //$NON-NLS-2$
159
msg += isFragment()?" fragment":" plugin"; //$NON-NLS-1$ //$NON-NLS-2$
160
return msg;
161     }
162
163 }
164
Popular Tags