KickJava   Java API By Example, From Geeks To Geeks.

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


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.AbsentInformationException;
23 import com.sun.jdi.ObjectReference;
24 import com.sun.jdi.ReferenceType;
25 import com.sun.jdi.Value;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.List JavaDoc;
29 import java.util.logging.Level JavaDoc;
30 import java.util.logging.Logger JavaDoc;
31
32 import org.netbeans.api.debugger.jpda.ClassVariable;
33 import org.netbeans.api.debugger.jpda.Field;
34 import org.netbeans.api.debugger.jpda.JPDAClassType;
35 import org.netbeans.api.debugger.jpda.ObjectVariable;
36
37 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
38
39 /**
40  *
41  * @author Martin Entlicher
42  */

43 public class JPDAClassTypeImpl implements JPDAClassType {
44     
45     private static final Logger JavaDoc loggerValue = Logger.getLogger("org.netbeans.modules.debugger.jpda.getValue"); // NOI8N
46

47     private JPDADebuggerImpl debugger;
48     private ReferenceType classType;
49     
50     /**
51      * Creates a new instance of JPDAClassTypeImpl
52      */

53     public JPDAClassTypeImpl(JPDADebuggerImpl debugger, ReferenceType classType) {
54         this.debugger = debugger;
55         this.classType = classType;
56     }
57
58     public String JavaDoc getName() {
59         return classType.name();
60     }
61
62     public String JavaDoc getSourceName() throws AbsentInformationException {
63         return classType.sourceName();
64     }
65
66     public ClassVariable classObject() {
67         return new ClassVariableImpl(debugger, classType.classObject(), "");
68     }
69
70     public List JavaDoc<Field> staticFields() {
71         List JavaDoc<com.sun.jdi.Field> allFieldsOrig = classType.allFields();
72         List JavaDoc<Field> staticFields = new ArrayList JavaDoc<Field>();
73         for (int i = 0; i < allFieldsOrig.size(); i++) {
74             Value value = null;
75             com.sun.jdi.Field origField = allFieldsOrig.get(i);
76             if (origField.isStatic()) {
77                 if (loggerValue.isLoggable(Level.FINE)) {
78                     loggerValue.fine("STARTED : "+classType+".getValue("+origField+")");
79                 }
80                 value = classType.getValue(origField);
81                 if (loggerValue.isLoggable(Level.FINE)) {
82                     loggerValue.fine("FINISHED: "+classType+".getValue("+origField+") = "+value);
83                 }
84                 staticFields.add(new FieldVariable(debugger, value, origField, "", (ObjectReference) null));
85             }
86         }
87         return staticFields;
88     }
89     
90 }
91
Popular Tags