KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > search > UpdateSearchScope


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.search;
12
13 import java.net.*;
14 import java.util.Vector JavaDoc;
15
16 import org.eclipse.update.internal.search.*;
17
18 /**
19  * This class encapsulates update scope of the update search.
20  * Sites that need to be visited should be added to the scope.
21  * If some categories should be skipped, their names must be
22  * passed as array of strings to the method.
23  *
24  * <p>
25  * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
26  * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
27  * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
28  * (repeatedly) as the API evolves.
29  * </p>
30  * @see UpdateSearchRequest
31  * @since 3.0
32  */

33
34 public class UpdateSearchScope {
35     private Vector JavaDoc sites;
36     private URL updateMapURL;
37     private boolean isFeatureProvidedSitesEnabled = true;
38     
39     private static class UpdateSearchSite
40         extends UpdateSiteAdapter
41         implements IUpdateSearchSite {
42         private String JavaDoc[] categoriesToSkip;
43
44         public UpdateSearchSite(
45             String JavaDoc label,
46             URL siteURL,
47             String JavaDoc[] categoriesToSkip) {
48             super(label, siteURL);
49             this.categoriesToSkip = categoriesToSkip;
50         }
51         public String JavaDoc[] getCategoriesToSkip() {
52             return categoriesToSkip;
53         }
54     }
55
56     /**
57      * The default constructor.
58      */

59     public UpdateSearchScope() {
60         sites = new Vector JavaDoc();
61     }
62
63     /**
64      * Sets the optional URL of the update map file. This file
65      * is used to redirect search for new updates to other
66      * servers and is typically used when a local
67      * update site proxy (possibly behind the firewall) is
68      * set up.
69      * @param url the url of the Java properties file that
70      * contains the redirection information.
71      */

72     
73     public void setUpdateMapURL(URL url) {
74         this.updateMapURL = url;
75     }
76     
77     /**
78      * Returns the optional URL of the update map file. By
79      * default, no map file is set.
80      * @return the URL of the map file or <samp>null</samp>
81      * if not set.
82      */

83     
84     public URL getUpdateMapURL() {
85         return updateMapURL;
86     }
87
88     /**
89      * Adds the site to scan to the search scope.
90      * @param label the presentation name of the site to visit.
91      * @param siteURL the URL of the site to visit.
92      * @param categoriesToSkip an array of category names that should be skipped or <samp>null</samp> if all features should be considered.
93      */

94     public void addSearchSite(
95         String JavaDoc label,
96         URL siteURL,
97         String JavaDoc[] categoriesToSkip) {
98         sites.add(new UpdateSearchSite(label, siteURL, categoriesToSkip));
99     }
100
101     /**
102      * Returns the sites that should be visited during the search.
103      * @return an array of site adapters
104      */

105     public IUpdateSearchSite[] getSearchSites() {
106         return (UpdateSearchSite[]) sites.toArray(
107             new UpdateSearchSite[sites.size()]);
108     }
109     
110     /**
111      * In addition to the sites added by addSearchSite(), features contribute their own update url's.
112      * This method returns true if those sites are also searched.
113      * @return true if update site provided by features are also searched. Default is true.
114      */

115     public boolean isFeatureProvidedSitesEnabled(){
116         return isFeatureProvidedSitesEnabled;
117     }
118
119     /**
120      * Enable or disable searching of feature provided update sites.
121      * If disabled, only sites added by addSearchSite() are searched.
122      * @param enable false to disable searching of feature provided sites. By default, these sites are searched.
123      */

124     public void setFeatureProvidedSitesEnabled(boolean enable){
125         this.isFeatureProvidedSitesEnabled = enable;
126     }
127 }
128
Popular Tags