FileDocCategorySizeDatePackage
DeclarationInfoDemo.javaAPI DocExample2448Sun Dec 14 22:47:32 GMT 2003oreilly.hcj.reflection

DeclarationInfoDemo

public class DeclarationInfoDemo extends Object
Demonstrates how to get declaration information on a Class.
author
Robert Simmons jr. (kraythe)
version
$Revision: 1.3 $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)
Demonstration Method.

param
args Command line arguments.

		printModifiers(Object.class);
		printModifiers(Float.class);
		printModifiers(Collection.class);
		printModifiers(Account.class);
		printModifiers(int.class);
		printModifiers(String.class);
	
public static voidprintModifiers(java.lang.Class dataType)
Prints out the modifiers for a class.

param
dataType The class for which to print out modifiers.

		final int modifiers = dataType.getModifiers();
		if (Modifier.isPrivate(modifiers)) {
			System.out.print("private ");
		}
		if (Modifier.isPrivate(modifiers)) {
			System.out.print("private ");
		}
		if (Modifier.isPublic(modifiers)) {
			System.out.print("private ");
		}
		if (Modifier.isAbstract(modifiers)) {
			System.out.print("abstract ");
		}
		if (Modifier.isFinal(modifiers)) {
			System.out.print("final ");
		}
		if (Modifier.isNative(modifiers)) {
			System.out.print("native ");
		}
		if (Modifier.isInterface(modifiers)) {
			System.out.print("interface ");
		}
		if (Modifier.isStatic(modifiers)) {
			System.out.print("static ");
		}
		if (Modifier.isStrict(modifiers)) {
			System.out.print("strict ");
		}
		if (Modifier.isSynchronized(modifiers)) {
			System.out.print("synchronized ");
		}
		if (Modifier.isTransient(modifiers)) {
			System.out.print("transient ");
		}
		if (Modifier.isVolatile(modifiers)) {
			System.out.print("volatile ");
		}
		System.out.println(dataType.getName());