KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > jpda > models > ReturnVariableImpl


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.models;
21
22 import com.sun.jdi.ObjectReference;
23 import com.sun.jdi.PrimitiveValue;
24 import com.sun.jdi.Value;
25 import com.sun.jdi.VoidValue;
26
27 import org.netbeans.api.debugger.jpda.ReturnVariable;
28
29 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
30
31 /**
32  *
33  * @author Martin Entlicher
34  */

35 public class ReturnVariableImpl extends AbstractVariable implements ReturnVariable {
36     
37     private String JavaDoc methodName;
38     
39     /** Creates a new instance of ClassVariableImpl */
40     public ReturnVariableImpl(
41         JPDADebuggerImpl debugger,
42         Value returnValue,
43         String JavaDoc parentID,
44         String JavaDoc methodName
45     ) {
46         super (
47             debugger,
48             returnValue,
49             parentID + ".return " + methodName + "=" + getStringValue(returnValue) // To have good equals()
50
);
51         this.methodName = methodName;
52     }
53     
54     private static String JavaDoc getStringValue(Value v) {
55         if (v == null) return "null";
56         if (v instanceof VoidValue) return "void";
57         if (v instanceof PrimitiveValue) return v.toString ();
58         else return "#" + ((ObjectReference) v).uniqueID ();
59     }
60     
61     public String JavaDoc methodName() {
62         return methodName;
63     }
64
65     public ReturnVariableImpl clone() {
66         return new ReturnVariableImpl(
67                 getDebugger(),
68                 getJDIValue(),
69                 getID().substring(0, getID().length() - ".return".length()),
70                 methodName);
71     }
72     
73     public String JavaDoc toString () {
74         return "ReturnVariable " + getValue();
75     }
76
77 }
78
Popular Tags