KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > jpda > expr > EvaluationContext


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 package org.netbeans.modules.debugger.jpda.expr;
21
22 import com.sun.jdi.StackFrame;
23
24 import java.util.*;
25
26 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
27
28 /**
29  * Defines the exection context in which to evaluate a given expression. The context consists of:
30  * the current stack frame and the source file in which the expression would exist. The source file
31  * is needed for the import facility to work.
32  *
33  * @author Maros Sandor
34  */

35 public class EvaluationContext {
36
37     /**
38      * The runtime context of a JVM is represented by a stack frame.
39      */

40     private StackFrame frame;
41     private List<String JavaDoc> sourceImports;
42     private List<String JavaDoc> staticImports;
43     private boolean canInvokeMethods;
44     private Runnable JavaDoc methodInvokePreproc;
45     private JPDADebuggerImpl debugger;
46
47     /**
48      * Creates a new context in which to evaluate expresions.
49      *
50      * @param frame the frame in which context evaluation occurrs
51      * @param imports list of imports
52      * @param staticImports list of static imports
53      */

54     public EvaluationContext(StackFrame frame, List<String JavaDoc> imports, List<String JavaDoc> staticImports,
55                              boolean canInvokeMethods, Runnable JavaDoc methodInvokePreproc,
56                              JPDADebuggerImpl debugger) {
57         if (frame == null) throw new IllegalArgumentException JavaDoc("Frame argument must not be null");
58         if (imports == null) throw new IllegalArgumentException JavaDoc("Imports argument must not be null");
59         if (staticImports == null) throw new IllegalArgumentException JavaDoc("Static imports argument must not be null");
60         this.frame = frame;
61         this.sourceImports = imports;
62         this.staticImports = staticImports;
63         this.canInvokeMethods = canInvokeMethods;
64         this.methodInvokePreproc = methodInvokePreproc;
65         this.debugger = debugger;
66     }
67
68     public List<String JavaDoc> getStaticImports() {
69         return staticImports;
70     }
71
72     public List<String JavaDoc> getImports() {
73         return sourceImports;
74     }
75
76     public StackFrame getFrame() {
77         return frame;
78     }
79     
80     public boolean canInvokeMethods() {
81         return canInvokeMethods;
82     }
83     
84     void setCanInvokeMethods(boolean canInvokeMethods) {
85         this.canInvokeMethods = canInvokeMethods;
86     }
87     
88     void methodToBeInvoked() {
89         if (methodInvokePreproc != null) {
90             methodInvokePreproc.run();
91         }
92     }
93     
94     JPDADebuggerImpl getDebugger() {
95         return debugger;
96     }
97     
98 }
99
100
Popular Tags