KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > core > UpdateSession


1 /*******************************************************************************
2  * Copyright (c) 2006, 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 - Initial API and implementation
10  * James D Miles (IBM Corp.) - bug 191783, NullPointerException in FeatureDownloader
11  *******************************************************************************/

12
13 package org.eclipse.update.internal.core;
14
15 import java.net.URL JavaDoc;
16 import java.util.Collections JavaDoc;
17 import java.util.HashSet JavaDoc;
18 import java.util.Set JavaDoc;
19
20 public class UpdateSession {
21     
22     private boolean enabled = false;
23     private Set JavaDoc visitedURLs = Collections.synchronizedSet(new HashSet JavaDoc());
24     
25     UpdateSession() {
26     }
27     
28     public boolean isVisited(URL JavaDoc url) {
29         if (!enabled)
30             return false;
31         return visitedURLs.contains(url.toExternalForm());
32     }
33
34     public void markVisited(URL JavaDoc url) {
35         if (!enabled)
36             return ;
37         visitedURLs.add(url.toExternalForm());
38     }
39     
40     /*
41      * Session will not start caching URLs prior to calling this
42      * method. If you want to use update session facility make sure
43      * you call this method first
44      */

45     public void reset() {
46         this.enabled = true;
47         visitedURLs.clear();
48     }
49
50 }
51
Popular Tags