KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > debugger > request > BreakpointRequestAction


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the debugger and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  */

22
23 package org.aspectj.debugger.request;
24
25 import org.aspectj.debugger.base.*;
26 import org.aspectj.debugger.gui.*;
27 import org.aspectj.debugger.ide.IDEInterface;
28 import org.aspectj.tools.ide.*;
29 import java.io.File JavaDoc;
30 import com.sun.jdi.*;
31 import com.sun.jdi.event.*;
32 import com.sun.jdi.request.*;
33
34 /**
35  * BreakpointRequestAction.java
36  *
37  *
38  * Created: Wed Aug 30 08:55:19 2000
39  *
40  * @author <a HREF="mailto:palm@parc.xerox.com"Jeffrey Palm</a>
41  */

42
43 public abstract class BreakpointRequestAction
44     extends RequestAction
45     implements IDEInterface.SourceLineBreakable
46 {
47
48     private Location location;
49
50     public BreakpointRequestAction(Debugger debugger) {
51         super(debugger);
52         if (!isSetting()) {
53             debugger.removeStopListener(this);
54         }
55     }
56
57     public boolean isBreakpoint() {
58         return true;
59     }
60
61     public abstract int getLine();
62     public abstract String JavaDoc getSourceName();
63     public abstract String JavaDoc getProto();
64
65     public int getRealLine() {
66         return getLine();
67     }
68     public String JavaDoc getRealSourceName() {
69         return getSourceName();
70     }
71
72     protected void setLocation(Location location) {
73         this.location = location;
74     }
75
76     protected BreakpointRequest request(Location location) throws NoVMException {
77         setLocation(location);
78         BreakpointRequest req = (BreakpointRequest)getRequest();
79         if (isSetting()) {
80             req = vm().eventRequestManager().createBreakpointRequest(getLocation());
81             req.setSuspendPolicy(EventRequest.SUSPEND_ALL);
82             req.enable();
83         } else if (req != null) {
84             vm().eventRequestManager().deleteEventRequest(req);
85         }
86         return req;
87     }
88
89     public Location getLocation() {
90         return location;
91     }
92
93     public String JavaDoc toString() {
94         return "breakpoint " + getProto();
95     }
96
97     public SourceLine sourceLine() {
98         return null;
99     }
100
101     public boolean equals(Object JavaDoc o) {
102         if (o instanceof AJStackFrameFormatter.MethodAndSource) {
103             AJStackFrameFormatter.MethodAndSource ms = (AJStackFrameFormatter.MethodAndSource)o;
104             return ms != null && getProto().equals(ms.getProto());
105         }
106         if (o instanceof BreakpointRequestAction) {
107             BreakpointRequestAction bra = (BreakpointRequestAction)o;
108             return
109 // getRealSourceName() != null && bra.getRealSourceName() != null &&
110
getRealSourceName().equals(bra.getRealSourceName()) &&
111                 getRealLine() == bra.getRealLine();
112         }
113         return super.equals(o);
114     }
115
116     public void breakpointEvent(BreakpointEvent e) { print(e); }
117 }
118
Popular Tags