KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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  * James D Miles (IBM Corp.) - bug 191783, NullPointerException in FeatureDownloader
11  *******************************************************************************/

12
13 package org.eclipse.update.core.model;
14
15
16 import java.net.MalformedURLException JavaDoc;
17 import java.net.URL JavaDoc;
18 import java.util.ArrayList JavaDoc;
19 import java.util.Arrays JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.eclipse.update.core.IIncludedFeatureReference;
24 import org.eclipse.update.core.IncludedFeatureReference;
25 import org.eclipse.update.core.VersionedIdentifier;
26 import org.eclipse.update.internal.core.UpdateCore;
27
28 /**
29  * Feature model object.
30  * <p>
31  * This class may be instantiated or subclassed by clients. However, in most
32  * cases clients should instead instantiate or subclass the provided
33  * concrete implementation of this model.
34  * </p>
35  * <p>
36  * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
37  * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
38  * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
39  * (repeatedly) as the API evolves.
40  * </p>
41  * @see org.eclipse.update.core.Feature
42  * @since 2.0
43  */

44 public class FeatureModel extends ModelObject {
45
46     private String JavaDoc featureId;
47     private String JavaDoc featureVersion;
48     private String JavaDoc label;
49     private String JavaDoc localizedLabel;
50     private String JavaDoc provider;
51     private String JavaDoc localizedProvider;
52     private String JavaDoc imageURLString;
53     private URL JavaDoc imageURL;
54     private String JavaDoc os;
55     private String JavaDoc ws;
56     private String JavaDoc nl;
57     private String JavaDoc arch;
58     private boolean primary = false;
59     private boolean exclusive=false;
60     private String JavaDoc primaryPluginID;
61     private String JavaDoc application;
62     private String JavaDoc affinity;
63     private InstallHandlerEntryModel installHandler;
64     private URLEntryModel description;
65     private URLEntryModel copyright;
66     private URLEntryModel license;
67     private URLEntryModel updateSiteInfo;
68     private List JavaDoc /*of InfoModel*/ discoverySiteInfo;
69     private List JavaDoc /*of ImportModel*/ imports;
70     private List JavaDoc /*of PluginEntryModel*/ pluginEntries;
71     private List JavaDoc /*of IncludedFeatureReferenceModel */ featureIncludes;
72     private List JavaDoc /*of NonPluginEntryModel*/ nonPluginEntries;
73
74     // performance
75
private URL JavaDoc bundleURL;
76     private URL JavaDoc base;
77     private boolean resolved = false;
78
79     /**
80      * Creates an uninitialized feature object.
81      *
82      * @since 2.0
83      */

84     public FeatureModel() {
85         super();
86     }
87
88     /**
89      * Compares 2 feature models for equality
90      *
91      * @param obj feature model to compare with
92      * @return <code>true</code> if the two models are equal,
93      * <code>false</code> otherwise
94      * @since 2.0
95      */

96     public boolean equals(Object JavaDoc obj) {
97         if (!(obj instanceof FeatureModel))
98             return false;
99         FeatureModel model = (FeatureModel) obj;
100
101         return (featureId.toLowerCase().equals(model.getFeatureIdentifier()) && featureVersion.toLowerCase().equals(model.getFeatureVersion()));
102     }
103
104     /**
105      * Returns the feature identifier as a string
106      *
107      * @see org.eclipse.update.core.IFeature#getVersionedIdentifier()
108      * @return feature identifier
109      * @since 2.0
110      */

111     public String JavaDoc getFeatureIdentifier() {
112         //delayedResolve(); no delay
113
return featureId;
114     }
115
116     /**
117      * Returns the feature version as a string
118      *
119      * @see org.eclipse.update.core.IFeature#getVersionedIdentifier()
120      * @return feature version
121      * @since 2.0
122      */

123     public String JavaDoc getFeatureVersion() {
124         //delayedResolve(); no delay
125
return featureVersion;
126     }
127
128     /**
129      * Retrieve the displayable label for the feature. If the model
130      * object has been resolved, the label is localized.
131      *
132      * @return displayable label, or <code>null</code>.
133      * @since 2.0
134      */

135     public String JavaDoc getLabel() {
136         delayedResolve();
137         if (localizedLabel != null)
138             return localizedLabel;
139         else
140             return label;
141     }
142
143     /**
144      * Retrieve the non-localized displayable label for the feature.
145      *
146      * @return non-localized displayable label, or <code>null</code>.
147      * @since 2.0
148      */

149     public String JavaDoc getLabelNonLocalized() {
150         return label;
151     }
152
153     /**
154      * Retrieve the displayable label for the feature provider. If the model
155      * object has been resolved, the label is localized.
156      *
157      * @return displayable label, or <code>null</code>.
158      * @since 2.0
159      */

160     public String JavaDoc getProvider() {
161         delayedResolve();
162         if (localizedProvider != null)
163             return localizedProvider;
164         else
165             return provider;
166     }
167
168     /**
169      * Retrieve the non-localized displayable label for the feature provider.
170      *
171      * @return non-localized displayable label, or <code>null</code>.
172      * @since 2.0
173      */

174     public String JavaDoc getProviderNonLocalized() {
175         return provider;
176     }
177
178     /**
179      * Returns the unresolved URL string for the feature image.
180      *
181      * @return url string, or <code>null</code>
182      * @since 2.0
183      */

184     public String JavaDoc getImageURLString() {
185         delayedResolve();
186         return imageURLString;
187     }
188
189     /**
190      * Returns the resolved URL for the image.
191      *
192      * @return url, or <code>null</code>
193      * @since 2.0
194      */

195     public URL JavaDoc getImageURL() {
196         delayedResolve();
197         return imageURL;
198     }
199
200     /**
201      * Get optional operating system specification as a comma-separated string.
202      *
203      * @return the operating system specification string, or <code>null</code>.
204      * @since 2.0
205      */

206     public String JavaDoc getOS() {
207         return os;
208     }
209
210     /**
211      * Get optional windowing system specification as a comma-separated string.
212      * @return the windowing system specification string, or <code>null</code>.
213      * @since 2.0
214      */

215     public String JavaDoc getWS() {
216         return ws;
217     }
218
219     /**
220      * Get optional system architecture specification as a comma-separated string.
221      *
222      * @return the system architecture specification string, or <code>null</code>.
223      * @since 2.0
224      */

225     public String JavaDoc getOSArch() {
226         return arch;
227     }
228
229     /**
230      * Get optional locale specification as a comma-separated string.
231      *
232      * @return the locale specification string, or <code>null</code>.
233      * @since 2.0
234      */

235     public String JavaDoc getNL() {
236         return nl;
237     }
238
239     /**
240      * Indicates whether the feature can be used as a primary feature.
241      *
242      * @return <code>true</code> if this is a primary feature,
243      * otherwise <code>false</code>
244      * @since 2.0
245      */

246     public boolean isPrimary() {
247         return primary;
248     }
249     
250     /**
251      * Indicates whether the feature must be processed alone
252      * during installation and configuration. Features that
253      * are not exclusive can be installed in a batch.
254      *
255      * @return <code>true</code> if feature requires
256      * exclusive processing, <code>false</code> otherwise.
257      * @since 2.1
258      */

259     public boolean isExclusive() {
260         return exclusive;
261     }
262
263     /**
264      * Returns an optional identifier for the feature application
265      *
266      * @return application identifier, or <code>null</code>.
267      * @since 2.0
268      */

269     public String JavaDoc getApplication() {
270         return application;
271     }
272
273     /**
274      * Returns an optional identifier for the colocation affinity feature
275      *
276      * @return feature identifier, or <code>null</code>.
277      * @since 2.0
278      */

279     public String JavaDoc getAffinityFeature() {
280         return affinity;
281     }
282
283     /**
284      * Returns and optional custom install handler entry.
285      *
286      * @return install handler entry, or <code>null</code> if
287      * none was specified
288      * @since 2.0
289      */

290     public InstallHandlerEntryModel getInstallHandlerModel() {
291         //delayedResolve(); no delay
292
return installHandler;
293     }
294
295     /**
296      * Returns the feature description.
297      *
298      * @return feature rescription, or <code>null</code>.
299      * @since 2.0
300      */

301     public URLEntryModel getDescriptionModel() {
302         //delayedResolve(); no delay
303
return description;
304     }
305
306     /**
307      * Returns the copyright information for the feature.
308      *
309      * @return copyright information, or <code>null</code>.
310      * @since 2.0
311      */

312     public URLEntryModel getCopyrightModel() {
313         //delayedResolve(); no delay
314
return copyright;
315     }
316
317     /**
318      * Returns the license information for the feature.
319      *
320      * @return feature license, or <code>null</code>.
321      * @since 2.0
322      */

323     public URLEntryModel getLicenseModel() {
324         //delayedResolve(); no delay;
325
return license;
326     }
327
328     /**
329      * Returns an information entry referencing the location of the
330      * feature update site.
331      *
332      * @return update site entry, or <code>null</code>.
333      * @since 2.0
334      */

335     public URLEntryModel getUpdateSiteEntryModel() {
336         //delayedResolve(); no delay;
337
return updateSiteInfo;
338     }
339
340     /**
341      * Return an array of information entries referencing locations of other
342      * update sites.
343      *
344      * @return an array of site entries, or an empty array.
345      * @since 2.0
346      * @since 2.0
347      */

348     public URLEntryModel[] getDiscoverySiteEntryModels() {
349         //delayedResolve(); no delay;
350
if (discoverySiteInfo == null || discoverySiteInfo.size() == 0)
351             return new URLEntryModel[0];
352
353         return (URLEntryModel[]) discoverySiteInfo.toArray(arrayTypeFor(discoverySiteInfo));
354     }
355
356     /**
357      * Return a list of plug-in dependencies for this feature.
358      *
359      * @return the list of required plug-in dependencies, or an empty array.
360      * @since 2.0
361      */

362     public ImportModel[] getImportModels() {
363         //delayedResolve(); no delay;
364
if (imports == null || imports.size() == 0)
365             return new ImportModel[0];
366
367         return (ImportModel[]) imports.toArray(arrayTypeFor(imports));
368     }
369
370     /**
371      * Returns an array of plug-in entries referenced by this feature
372      *
373      * @return an erray of plug-in entries, or an empty array.
374      * @since 2.0
375      */

376     public PluginEntryModel[] getPluginEntryModels() {
377         if (pluginEntries == null || pluginEntries.size() == 0)
378             return new PluginEntryModel[0];
379
380         return (PluginEntryModel[]) pluginEntries.toArray(arrayTypeFor(pluginEntries));
381     }
382
383     /**
384      * Returns an array of versioned identifier referenced by this feature
385      *
386      * @return an array of versioned identifier, or an empty array.
387      * @deprecated use getFeatureIncludeIdentifier instead.
388      * @since 2.0
389      */

390     public VersionedIdentifier[] getFeatureIncludeVersionedIdentifier() {
391         //delayedResolve(); no delay
392
if (featureIncludes == null)
393             return new VersionedIdentifier[0];
394
395         //
396
Iterator JavaDoc iter = featureIncludes.iterator();
397         VersionedIdentifier[] versionIncluded = new VersionedIdentifier[featureIncludes.size()];
398         int index = 0;
399         while (iter.hasNext()) {
400             IncludedFeatureReferenceModel model = (IncludedFeatureReferenceModel) iter.next();
401             versionIncluded[index] = model.getVersionedIdentifier();
402             index++;
403         }
404         return versionIncluded;
405     }
406
407     /**
408      * Returns an array of included feature reference model referenced by this feature.
409      *
410      * @return an array of included feature reference model, or an empty array.
411      * @since 2.0
412      */

413     public IIncludedFeatureReference[] getFeatureIncluded() {
414         //delayedResolve(); no delay
415
if (featureIncludes == null || featureIncludes.size() == 0)
416             return new IIncludedFeatureReference[0];
417         return (IIncludedFeatureReference[]) featureIncludes.toArray(arrayTypeFor(featureIncludes));
418     }
419
420     /**
421      * Returns an array of non-plug-in entries referenced by this feature
422      *
423      * @return an erray of non-plug-in entries, or an empty array.
424      * @since 2.0
425      */

426     public NonPluginEntryModel[] getNonPluginEntryModels() {
427         if (nonPluginEntries == null || nonPluginEntries.size() == 0)
428             return new NonPluginEntryModel[0];
429
430         return (NonPluginEntryModel[]) nonPluginEntries.toArray(arrayTypeFor(nonPluginEntries));
431     }
432
433     /**
434      * Sets the feature identifier.
435      * Throws a runtime exception if this object is marked read-only.
436      *
437      * @param featureId feature identifier
438      * @since 2.0
439      */

440     public void setFeatureIdentifier(String JavaDoc featureId) {
441         assertIsWriteable();
442         this.featureId = featureId;
443     }
444
445     /**
446      * Sets the feature version.
447      * Throws a runtime exception if this object is marked read-only.
448      *
449      * @param featureVersion feature version
450      * @since 2.0
451      */

452     public void setFeatureVersion(String JavaDoc featureVersion) {
453         assertIsWriteable();
454         this.featureVersion = featureVersion;
455     }
456
457     /**
458      * Sets the feature displayable label.
459      * Throws a runtime exception if this object is marked read-only.
460      *
461      * @param label displayable label
462      * @since 2.0
463      */

464     public void setLabel(String JavaDoc label) {
465         assertIsWriteable();
466         this.label = label;
467         this.localizedLabel = null;
468     }
469
470     /**
471      * Sets the feature provider displayable label.
472      * Throws a runtime exception if this object is marked read-only.
473      *
474      * @param provider provider displayable label
475      * @since 2.0
476      */

477     public void setProvider(String JavaDoc provider) {
478         assertIsWriteable();
479         this.provider = provider;
480         this.localizedProvider = null;
481     }
482
483     /**
484      * Sets the unresolved URL for the feature image.
485      * Throws a runtime exception if this object is marked read-only.
486      *
487      * @param imageURLString unresolved URL string
488      * @since 2.0
489      */

490     public void setImageURLString(String JavaDoc imageURLString) {
491         assertIsWriteable();
492         this.imageURLString = imageURLString;
493         this.imageURL = null;
494     }
495
496     /**
497      * Sets the operating system specification.
498      * Throws a runtime exception if this object is marked read-only.
499      *
500      * @param os operating system specification as a comma-separated list
501      * @since 2.0
502      */

503     public void setOS(String JavaDoc os) {
504         assertIsWriteable();
505         this.os = os;
506     }
507
508     /**
509      * Sets the windowing system specification.
510      * Throws a runtime exception if this object is marked read-only.
511      *
512      * @param ws windowing system specification as a comma-separated list
513      * @since 2.0
514      */

515     public void setWS(String JavaDoc ws) {
516         assertIsWriteable();
517         this.ws = ws;
518     }
519
520     /**
521      * Sets the locale specification.
522      * Throws a runtime exception if this object is marked read-only.
523      *
524      * @param nl locale specification as a comma-separated list
525      * @since 2.0
526      */

527     public void setNL(String JavaDoc nl) {
528         assertIsWriteable();
529         this.nl = nl;
530     }
531
532     /**
533      * Sets the system architecture specification.
534      * Throws a runtime exception if this object is marked read-only.
535      *
536      * @param arch system architecture specification as a comma-separated list
537      * @since 2.0
538      */

539     public void setArch(String JavaDoc arch) {
540         assertIsWriteable();
541         this.arch = arch;
542     }
543
544     /**
545      * Indicates whether this feature can act as a primary feature.
546      * Throws a runtime exception if this object is marked read-only.
547      *
548      * @param primary <code>true</code> if this feature can act as primary,
549      * <code>false</code> otherwise
550      *
551      * @since 2.0
552      */

553     public void setPrimary(boolean primary) {
554         assertIsWriteable();
555         this.primary = primary;
556     }
557     
558     /**
559      * Indicates whether this feature can act as a primary feature.
560      * Throws a runtime exception if this object is marked read-only.
561      *
562      * @param exclusive <code>true</code> if this feature must be
563      * processed independently from other features, <code>false</code>
564      * if feature can be processed in a batch with other features.
565      *
566      * @since 2.1
567      */

568     public void setExclusive(boolean exclusive) {
569         assertIsWriteable();
570         this.exclusive = exclusive;
571     }
572
573     /**
574      * Sets the feature application identifier.
575      * Throws a runtime exception if this object is marked read-only.
576      *
577      * @param application feature application identifier
578      * @since 2.0
579      */

580     public void setApplication(String JavaDoc application) {
581         assertIsWriteable();
582         this.application = application;
583     }
584
585     /**
586      * Sets the identifier of the Feature this feature should be
587      * installed with.
588      * Throws a runtime exception if this object is marked read-only.
589      *
590      * @param affinity the identifier of the Feature
591      * @since 2.0
592      */

593     public void setAffinityFeature(String JavaDoc affinity) {
594         assertIsWriteable();
595         this.affinity = affinity;
596     }
597
598     /**
599      * Sets the custom install handler for the feature.
600      * Throws a runtime exception if this object is marked read-only.
601      *
602      * @param installHandler install handler entry
603      * @since 2.0
604      */

605     public void setInstallHandlerModel(InstallHandlerEntryModel installHandler) {
606         assertIsWriteable();
607         this.installHandler = installHandler;
608     }
609
610     /**
611      * Sets the feature description information.
612      * Throws a runtime exception if this object is marked read-only.
613      *
614      * @param description feature description information
615      * @since 2.0
616      */

617     public void setDescriptionModel(URLEntryModel description) {
618         assertIsWriteable();
619         this.description = description;
620     }
621
622     /**
623      * Sets the feature copyright information.
624      * Throws a runtime exception if this object is marked read-only.
625      *
626      * @param copyright feature copyright information
627      * @since 2.0
628      */

629     public void setCopyrightModel(URLEntryModel copyright) {
630         assertIsWriteable();
631         this.copyright = copyright;
632     }
633
634     /**
635      * Sets the feature license information.
636      * Throws a runtime exception if this object is marked read-only.
637      *
638      * @param license feature license information
639      * @since 2.0
640      */

641     public void setLicenseModel(URLEntryModel license) {
642         assertIsWriteable();
643         this.license = license;
644     }
645
646     /**
647      * Sets the feature update site reference.
648      * Throws a runtime exception if this object is marked read-only.
649      *
650      * @param updateSiteInfo feature update site reference
651      * @since 2.0
652      */

653     public void setUpdateSiteEntryModel(URLEntryModel updateSiteInfo) {
654         assertIsWriteable();
655         this.updateSiteInfo = updateSiteInfo;
656     }
657
658     /**
659      * Sets additional update site references.
660      * Throws a runtime exception if this object is marked read-only.
661      *
662      * @param discoverySiteInfo additional update site references
663      * @since 2.0
664      */

665     public void setDiscoverySiteEntryModels(URLEntryModel[] discoverySiteInfo) {
666         assertIsWriteable();
667         if (discoverySiteInfo == null)
668             this.discoverySiteInfo = null;
669         else
670             this.discoverySiteInfo = new ArrayList JavaDoc(Arrays.asList(discoverySiteInfo));
671     }
672
673     /**
674      * Sets the feature plug-in dependency information.
675      * Throws a runtime exception if this object is marked read-only.
676      *
677      * @param imports feature plug-in dependency information
678      * @since 2.0
679      */

680     public void setImportModels(ImportModel[] imports) {
681         assertIsWriteable();
682         if (imports == null)
683             this.imports = null;
684         else
685             this.imports = new ArrayList JavaDoc(Arrays.asList(imports));
686     }
687
688     /**
689      * Sets the feature plug-in references.
690      * Throws a runtime exception if this object is marked read-only.
691      *
692      * @param pluginEntries feature plug-in references
693      * @since 2.0
694      */

695     public void setPluginEntryModels(PluginEntryModel[] pluginEntries) {
696         assertIsWriteable();
697         if (pluginEntries == null)
698             this.pluginEntries = null;
699         else
700             this.pluginEntries = new ArrayList JavaDoc(Arrays.asList(pluginEntries));
701     }
702
703     /**
704      * Sets the feature non-plug-in data references.
705      * Throws a runtime exception if this object is marked read-only.
706      *
707      * @param nonPluginEntries feature non-plug-in data references
708      * @since 2.0
709      */

710     public void setNonPluginEntryModels(NonPluginEntryModel[] nonPluginEntries) {
711         assertIsWriteable();
712         if (nonPluginEntries == null)
713             this.nonPluginEntries = null;
714         else
715             this.nonPluginEntries = new ArrayList JavaDoc(Arrays.asList(nonPluginEntries));
716     }
717
718     /**
719      * Adds an additional update site reference.
720      * Throws a runtime exception if this object is marked read-only.
721      *
722      * @param discoverySiteInfo update site reference
723      * @since 2.0
724      */

725     public void addDiscoverySiteEntryModel(URLEntryModel discoverySiteInfo) {
726         assertIsWriteable();
727         if (this.discoverySiteInfo == null)
728             this.discoverySiteInfo = new ArrayList JavaDoc();
729         if (!this.discoverySiteInfo.contains(discoverySiteInfo))
730             this.discoverySiteInfo.add(discoverySiteInfo);
731     }
732
733     /**
734      * Adds a plug-in dependency entry.
735      * Throws a runtime exception if this object is marked read-only.
736      *
737      * @param importEntry plug-in dependency entry
738      * @since 2.0
739      */

740     public void addImportModel(ImportModel importEntry) {
741         assertIsWriteable();
742         if (this.imports == null)
743             this.imports = new ArrayList JavaDoc();
744         if (!this.imports.contains(importEntry))
745             this.imports.add(importEntry);
746     }
747
748     /**
749      * Adds a plug-in reference.
750      * Throws a runtime exception if this object is marked read-only.
751      *
752      * @param pluginEntry plug-in reference
753      * @since 2.0
754      */

755     public void addPluginEntryModel(PluginEntryModel pluginEntry) {
756         assertIsWriteable();
757         if (this.pluginEntries == null)
758             this.pluginEntries = new ArrayList JavaDoc();
759         //PERF: no ListContains()
760
//if (!this.pluginEntries.contains(pluginEntry))
761
this.pluginEntries.add(pluginEntry);
762     }
763
764     /**
765      * Adds a feature identifier.
766      * Throws a runtime exception if this object is marked read-only.
767      * @param include the included feature
768      * @since 2.1
769      */

770     public void addIncludedFeatureReferenceModel(IncludedFeatureReferenceModel include) {
771         assertIsWriteable();
772         if (this.featureIncludes == null)
773             this.featureIncludes = new ArrayList JavaDoc();
774         //PERF: no ListContains()
775
//if (!this.featureIncludes.contains(include))
776
this.featureIncludes.add(new IncludedFeatureReference(include));
777     }
778
779     /**
780      * Adds a non-plug-in data reference.
781      * Throws a runtime exception if this object is marked read-only.
782      *
783      * @param nonPluginEntry non-plug-in data reference
784      * @since 2.0
785      */

786     public void addNonPluginEntryModel(NonPluginEntryModel nonPluginEntry) {
787         assertIsWriteable();
788         if (this.nonPluginEntries == null)
789             this.nonPluginEntries = new ArrayList JavaDoc();
790         //PERF: no ListContains()
791
//if (!this.nonPluginEntries.contains(nonPluginEntry))
792
this.nonPluginEntries.add(nonPluginEntry);
793     }
794
795     /**
796      * Removes an update site reference.
797      * Throws a runtime exception if this object is marked read-only.
798      *
799      * @param discoverySiteInfo update site reference
800      * @since 2.0
801      */

802     public void removeDiscoverySiteEntryModel(URLEntryModel discoverySiteInfo) {
803         assertIsWriteable();
804         if (this.discoverySiteInfo != null)
805             this.discoverySiteInfo.remove(discoverySiteInfo);
806     }
807
808     /**
809      * Removes a plug-in dependency entry.
810      * Throws a runtime exception if this object is marked read-only.
811      *
812      * @param importEntry plug-in dependency entry
813      * @since 2.0
814      */

815     public void removeImportModel(ImportModel importEntry) {
816         assertIsWriteable();
817         if (this.imports != null)
818             this.imports.remove(importEntry);
819     }
820
821     /**
822      * Removes a plug-in reference.
823      * Throws a runtime exception if this object is marked read-only.
824      *
825      * @param pluginEntry plug-in reference
826      * @since 2.0
827      */

828     public void removePluginEntryModel(PluginEntryModel pluginEntry) {
829         assertIsWriteable();
830         if (this.pluginEntries != null)
831             this.pluginEntries.remove(pluginEntry);
832     }
833
834     /**
835      * Removes a non-plug-in data reference.
836      * Throws a runtime exception if this object is marked read-only.
837      *
838      * @param nonPluginEntry non-plug-in data reference
839      * @since 2.0
840      */

841     public void removeNonPluginEntryModel(NonPluginEntryModel nonPluginEntry) {
842         assertIsWriteable();
843         if (this.nonPluginEntries != null)
844             this.nonPluginEntries.remove(nonPluginEntry);
845     }
846
847     /**
848      * Marks the model object as read-only.
849      *
850      * @since 2.0
851      */

852     public void markReadOnly() {
853         super.markReadOnly();
854         markReferenceReadOnly(getDescriptionModel());
855         markReferenceReadOnly(getCopyrightModel());
856         markReferenceReadOnly(getLicenseModel());
857         markReferenceReadOnly(getUpdateSiteEntryModel());
858         markListReferenceReadOnly(getDiscoverySiteEntryModels());
859         markListReferenceReadOnly(getImportModels());
860         markListReferenceReadOnly(getPluginEntryModels());
861         markListReferenceReadOnly(getNonPluginEntryModels());
862     }
863
864     /**
865      * Resolve the model object.
866      * Any URL strings in the model are resolved relative to the
867      * base URL argument. Any translatable strings in the model that are
868      * specified as translation keys are localized using the supplied
869      * resource bundle.
870      *
871      * @param base URL
872      * @param bundleURL resource bundle url
873      * @exception MalformedURLException
874      * @since 2.0
875      */

876     public void resolve(URL JavaDoc base,URL JavaDoc bundleURL) throws MalformedURLException JavaDoc {
877         this.bundleURL = bundleURL;
878         this.base = base;
879
880         // plugin entry and nonpluginentry are optimized too
881
resolveListReference(getPluginEntryModels(), base, bundleURL);
882         resolveListReference(getNonPluginEntryModels(), base, bundleURL);
883         
884         //URLSiteModel are optimized
885
resolveReference(getDescriptionModel(),base, bundleURL);
886         resolveReference(getCopyrightModel(),base, bundleURL);
887         resolveReference(getLicenseModel(),base, bundleURL);
888         resolveReference(getUpdateSiteEntryModel(),base, bundleURL);
889         resolveListReference(getDiscoverySiteEntryModels(),base, bundleURL);
890         
891         // Import Models are optimized
892
resolveListReference(getImportModels(),base, bundleURL);
893     }
894
895     private void delayedResolve() {
896
897         // PERF: delay resolution
898
if (resolved)
899             return;
900
901         // resolve local elements
902
localizedLabel = resolveNLString(bundleURL, label);
903         localizedProvider = resolveNLString(bundleURL, provider);
904         try {
905             imageURL = resolveURL(base,bundleURL, imageURLString);
906             resolved = true;
907         } catch (MalformedURLException JavaDoc e){
908             UpdateCore.warn("",e); //$NON-NLS-1$
909
}
910     }
911
912     /**
913      * Method setPrimaryPlugin.
914      * @param plugin
915      */

916     public void setPrimaryPluginID(String JavaDoc plugin) {
917         if (primary && primaryPluginID == null) {
918             primaryPluginID = featureId;
919         }
920         primaryPluginID = plugin;
921     }
922     /**
923      * Returns the primaryPluginID.
924      * @return String
925      */

926     public String JavaDoc getPrimaryPluginID() {
927         return primaryPluginID;
928     }
929
930     /**
931      * Returns <code>true</code> if this feature is patching another feature,
932      * <code>false</code> otherwise
933      * @return boolean
934      */

935     public boolean isPatch() {
936         ImportModel[] imports = getImportModels();
937
938         for (int i = 0; i < imports.length; i++) {
939             if (imports[i].isPatch())
940                 return true;
941         }
942         return false;
943     }
944 }
Popular Tags