KickJava   Java API By Example, From Geeks To Geeks.

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


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
27 import com.sun.jdi.*;
28 import com.sun.jdi.request.*;
29 import com.sun.jdi.event.*;
30 import java.util.*;
31
32 /**
33  * ClassBreakpointRequestAction.java
34  *
35  *
36  * Created: Wed Aug 23 11:26:39 2000
37  *
38  * @author <a HREF="mailto:palm@parc.xerox.com"Jeffrey Palm</a>
39  */

40
41 public abstract class ClassBreakpointRequestAction extends BreakpointRequestAction {
42
43     protected String JavaDoc className;
44
45     ClassBreakpointRequestAction(Debugger debugger, String JavaDoc className) {
46         super(debugger);
47         this.className = className;
48     }
49
50     EventRequest resolve(ReferenceType refType)
51         throws MultipleLocationsException,
52                UnableToSetRequestException {
53         BreakpointRequest request = null;
54         try {
55             if (refType.name().equals(className)) {
56                 EventRequestManager em = vm().eventRequestManager();
57                 Location location = findLocation();
58                 if (location == null) {
59                     return null;
60                 }
61                 request = request(location);
62             }
63         } catch (NoVMException e) {
64         }
65         return request;
66     }
67
68     public String JavaDoc getRealSourceName() {
69         return ajdbg().getFullSourcePathFromAJCClass(getClassName());
70     }
71
72     public String JavaDoc getClassName() {
73         return className;
74     }
75
76     public int getLine() {
77         if (getLocation() != null) {
78             return getLocation().lineNumber();
79         }
80         return -1;
81     }
82
83     public String JavaDoc getSourceName() {
84         if (getLocation() != null) {
85             try {
86                 return getLocation().sourceName();
87             } catch (AbsentInformationException aie) {
88             }
89         }
90         return "<not-available>";
91     }
92
93     abstract Location findLocation()
94         throws NoVMException,
95                MultipleLocationsException,
96                UnableToSetRequestException;
97 }
98
Popular Tags