KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > parser > LocalVarScope


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19  /*
20  * LocalVarScope.java
21  *
22  * Created on April 28, 2003, 4:11 PM
23  */

24
25 package org.netbeans.modules.javacore.parser;
26
27 import org.netbeans.jmi.javamodel.Variable;
28
29 /**
30  *
31  * @author Tomas Hurka
32  */

33 class LocalVarScope implements ScopeMember {
34     private String JavaDoc varName;
35     private Variable variable;
36     private Object JavaDoc refInfo;
37
38     LocalVarScope(String JavaDoc name,Object JavaDoc ref) {
39         varName=name;
40         refInfo=ref;
41     }
42
43     LocalVarScope(Variable var) {
44         varName=var.getName();
45         variable=var;
46     }
47
48     public Object JavaDoc lookup(Object JavaDoc key) {
49         if (varName.equals(key)) {
50             return variable!=null?variable:refInfo;
51         }
52         return null;
53     }
54 }
55
Popular Tags