home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
DTReflectTest.java
< prev
next >
Wrap
Text File
|
1998-10-25
|
5KB
|
113 lines
/*
* Copyright 1998 Symantec Corporation, All Rights Reserved.
*/
package com.symantec.itools.vcafe.openapi.dtreflect;
import java.lang.reflect.*;
import com.symantec.itools.vcafe.openapi.*;
public class DTReflectTest
{
static DTClass objectClass;
static DTClass stringClass;
static DTClass intClass;
static DTClass longClass;
static DTClass booleanClass;
static DTClass projClass;
public static void test() {
VisualProject project = VisualCafe.getVisualCafe().getTargetProject();
if (project == null) {
System.err.println("**Error: no target project");
return;
}
objectClass = DTClass.findClass(project,"java.lang.Object");
if (objectClass == null) {
System.err.println("**Error: couldn't find java.lang.Object");
objectClass.nonNull();
}
DTClass stringClass = DTClass.findClass(project,"java.lang.String");
if (stringClass == null) {
System.err.println("**Error: couldn't find java.lang.String");
stringClass.nonNull();
}
DTClass intClass = DTClass.getPrimitiveClass("int");
if (intClass == null) {
System.err.println("**Error: couldn't find int");
intClass.nonNull();
}
DTClass longClass = DTClass.getPrimitiveClass("long");
if (longClass == null) {
System.err.println("**Error: couldn't find long");
longClass.nonNull();
}
DTClass booleanClass = DTClass.getPrimitiveClass("boolean");
if (booleanClass == null) {
System.err.println("**Error: couldn't find boolean");
booleanClass.nonNull();
}
dumpClass("object", objectClass);
dumpClass("string", stringClass);
dumpClass("int", intClass);
}
static void dumpClass(String name, DTClass clazz) {
System.out.println(clazz.getName() + " properties");
System.out.println(" " + name + ".getName()=\"" + clazz.getName() + "\"");
System.out.println(" " + name + ".toString()=\"" + clazz.toString() + "\"");
System.out.println(" " + name + ".isAssignableFrom(string)=" + clazz.isAssignableFrom(stringClass));
System.out.println("**string.isAssignableFrom(object)=" + stringClass.isAssignableFrom(clazz));
System.out.println(" " + name + ".isAssignableFrom(object)=" + clazz.isAssignableFrom(clazz));
System.out.println(" " + name + ".isAssignableFrom(int)=" + clazz.isAssignableFrom(intClass));
System.out.println(" " + name + ".isAssignable(string)=" + clazz.isAssignable(stringClass));
System.out.println("**string.isAssignable(object)=" + stringClass.isAssignable(clazz));
System.out.println(" " + name + ".isAssignable(object)=" + clazz.isAssignable(clazz));
System.out.println(" " + name + ".isAssignable(int)=" + clazz.isAssignable(intClass));
System.out.println(" " + name + ".isAssignable(23)=" + clazz.isAssignable(23));
System.out.println(" " + name + ".isImplementationOf(string)=" + clazz.isImplementationOf(stringClass));
System.out.println("**string.isImplementationOf(object)=" + stringClass.isImplementationOf(clazz));
System.out.println(" " + name + ".isInterface()=" + clazz.isInterface());
System.out.println(" " + name + ".isArray()=" + clazz.isArray());
System.out.println(" " + name + ".getBounds()=" + clazz.getBounds());
System.out.println(" " + name + ".isPrimitive()=" + clazz.isPrimitive());
System.out.println(" " + name + ".getSuperclass()=" + clazz.getSuperclass());
System.out.println(" " + name + ".getInterfaces()=" + clazz.getInterfaces());
System.out.println(" " + name + ".getComponentType()=" + clazz.getComponentType());
System.out.println(" " + name + ".getComponentName()=" + clazz.getComponentName());
System.out.println(" " + name + ".getModifiers()=" + Modifier.toString(clazz.getModifiers()));
System.out.println(" " + name + ".getDeclaringClass()=" + clazz.getDeclaringClass());
System.out.println(" " + name + ".getClasses()=" + clazz.getClasses());
System.out.println(" " + name + ".getFields()=");
DTField[] fields = clazz.getFields();
for (int i = 0; i < fields.length; i++)
System.out.println(" " + fields[i].toString());
System.out.println(" " + name + ".getMethods()=");
DTMethod[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++)
System.out.println(" " + methods[i].toString());
System.out.println(" " + name + ".getConstructors()=");
DTConstructor[] constructors = clazz.getConstructors();
for (int i = 0; i < constructors.length; i++)
System.out.println(" " + constructors[i].toString());
System.out.println(" " + name + ".getDeclaredFields()=");
fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++)
System.out.println(" " + fields[i].toString());
System.out.println(" " + name + ".getDeclaredMethods()=");
methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++)
System.out.println(" " + methods[i].toString());
System.out.println(" " + name + ".getDeclaredConstructors()=");
constructors = clazz.getDeclaredConstructors();
for (int i = 0; i < constructors.length; i++)
System.out.println(" " + constructors[i].toString());
System.out.println(" " + name + ".getProject()=" + clazz.getProject());
System.out.println(" " + name + ".validate()=" + clazz.validate());
}
}