KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > core > logicalstructures > LogicalObjectStructureClassType


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.core.logicalstructures;
12
13 import org.eclipse.debug.core.DebugException;
14 import org.eclipse.debug.core.model.ILogicalStructureTypeDelegate;
15 import org.eclipse.debug.core.model.IValue;
16 import org.eclipse.jdt.debug.core.IJavaClassType;
17 import org.eclipse.jdt.debug.core.IJavaObject;
18 import org.eclipse.jdt.debug.core.IJavaType;
19
20 /**
21  * Common facilities for logical structure types for instances/subtypes of a class
22  */

23 public abstract class LogicalObjectStructureClassType extends LogicalObjectStructureInterfaceType implements ILogicalStructureTypeDelegate {
24     
25     /* (non-Javadoc)
26      * @see org.eclipse.debug.core.model.ILogicalStructureType#providesLogicalStructure(org.eclipse.debug.core.model.IValue)
27      */

28     public boolean providesLogicalStructure(IValue value) {
29         if (value instanceof IJavaObject) {
30             IJavaObject object = (IJavaObject) value;
31             try {
32                 IJavaType type = object.getJavaType();
33                 if (type instanceof IJavaClassType) {
34                     IJavaClassType classType = (IJavaClassType) type;
35                     String JavaDoc targetClass = getTargetClassName();
36                     while (classType != null) {
37                         if (classType.getName().equals(targetClass)) {
38                             return true;
39                         }
40                         classType = classType.getSuperclass();
41                     }
42                 }
43             } catch (DebugException e) {
44             }
45         }
46         return false;
47     }
48     
49     /**
50      * Returns the name of a class that an object must be an instance or subtype of
51      * for this structure type to be appropriate.
52      *
53      * @return the name of a class that an object must be an instance or subtype of
54      * for this structure type to be appropriate
55      */

56     protected abstract String JavaDoc getTargetClassName();
57     
58     /* (non-Javadoc)
59      * @see org.eclipse.jdt.internal.debug.core.logicalstructures.LogicalObjectStructureInterfaceType#getTargetInterfaceName()
60      */

61     protected String JavaDoc getTargetInterfaceName() {
62         // not used
63
return null;
64     }
65
66 }
67
Popular Tags