KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > classfile > Global


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.classfile;
21
22 /**
23  * Static methods for accessing objects that are global
24  * to an analysis session. Hopefully, this will be
25  * limited to the analysis cache.
26  *
27  * @author David Hovemeyer
28  */

29 public abstract class Global {
30     private static final InheritableThreadLocal JavaDoc<IAnalysisCache> analysisCacheThreadLocal =
31         new InheritableThreadLocal JavaDoc<IAnalysisCache>();
32     
33     /**
34      * Set the analysis cache for the current thread.
35      * This should be called before any detectors or analyses that
36      * need the cache are used.
37      *
38      * @param analysisCache the analysis cache to set for the current thread
39      */

40     public static void setAnalysisCacheForCurrentThread(IAnalysisCache analysisCache) {
41         analysisCacheThreadLocal.set(analysisCache);
42     }
43
44     /**
45      * Get the analysis cache for the current thread.
46      *
47      * @return the analysis cache for the current thread
48      */

49     public static IAnalysisCache getAnalysisCache() {
50         return analysisCacheThreadLocal.get();
51     }
52 }
53
Popular Tags