KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > debugger > gui > AJValueNodeFactory


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.gui;
24
25 import org.aspectj.debugger.base.*;
26 import com.sun.jdi.*;
27
28 public class AJValueNodeFactory {
29
30     public static AJValueNode make(LocalVariable local, StackFrame frame) {
31         return make(new AJLocalVariableValueGetter(local, frame),
32                     local.signature());
33     }
34
35     public static AJValueNode make(ReferenceType refType, Field field) {
36         return make(new AJReferenceTypeMemberValueGetter(refType, field),
37                     field.signature());
38     }
39
40     public static AJValueNode make(ObjectReference object, String JavaDoc name) {
41         return make(new AJObjectReferenceValueGetter(object, name),
42                     object.referenceType().signature());
43     }
44
45     public static AJValueNode make(ObjectReference parent, Field field) {
46         return make(new AJMemberValueGetter(parent, field),
47                     field.signature());
48     }
49
50     public static AJValueNode make(ArrayReference arrayParent, int index) {
51         return make(new AJArrayMemberValueGetter(arrayParent, index),
52                     arrayParent.getValue(0).type().signature());
53     }
54
55     private static AJValueNode make(AJValueGetter g, String JavaDoc sig) {
56         if (sig.equals("Z")) return new AJBooleanValueNode(g);
57         else if (sig.equals("B")) return new AJByteValueNode(g);
58         else if (sig.equals("C")) return new AJCharValueNode(g);
59         else if (sig.equals("D")) return new AJDoubleValueNode(g);
60         else if (sig.equals("F")) return new AJFloatValueNode(g);
61         else if (sig.equals("I")) return new AJIntegerValueNode(g);
62         else if (sig.equals("J")) return new AJLongValueNode(g);
63         else if (sig.startsWith("S")) return new AJShortValueNode(g);
64         else if (sig.startsWith("L")) return new AJObjectValueNode(g);
65         else if (sig.startsWith("[")) return new AJArrayValueNode(g);
66         return new AJValueNode(g);
67     }
68 }
69
Popular Tags