|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jutil.java.reflect.Classes
Utility methods for class reflection.
Field Summary | |
static java.lang.String |
CVS_REVISION
|
static Filter |
PACKAGE_ACCESS_FILTER
|
static Filter |
PRIVATE_ACCESS_FILTER
|
static Filter |
PROTECTED_ACCESS_FILTER
|
static Filter |
PUBLIC_ACCESS_FILTER
|
Constructor Summary | |
Classes()
|
Method Summary | |
static boolean |
areInSamePackage(java.lang.Class t1,
java.lang.Class t2)
// The types to compare are not null. pre (t1 != null) && (t2 != null); // The result is true if the 2 given classes are defined // in the same package. |
static java.util.Set |
getImmediateSuperTypes(java.lang.Class clazz)
// The given Class must be effective pre clazz != null; // The set contains elements of type Class post (\forall Object o; \result.contains(o); o instanceof Class); // The set contains no null references post (\forall Object o; \result.contains(o); o != null); // The set only contains immediate supertypes of post (\forall Class c; \result.contains(c); c == clazz.getSuperClass() || clazz.getInterfaces().contains(c)); // If the this method is applied to class Class, the result is the empty set. post (clazz == Class.class) ==> \result.isEmpty(); |
static java.util.SortedSet |
getSuperClasses(java.lang.Class clazz)
// The given Class must be effective pre clazz != null; // The set contains elements of type Class post (\forall Object o; \result.contains(o); o instanceof Class); // The set contains no null references post (\forall Class c; \result.contains(c); c != null); // The set contains only classes, no interfaces. post (\forall Class c; \result.contains(c); ! c.isInterface()); // The set contains only super classes of clazz. post (\forall Class c; \result.contains(c); c.isAssignableFrom(clazz)); // The set contains all the super classes of post (\forall Class c; (c.isAssignableFrom(clazz)) && (! c.isInterface()); \result.contains(c)); // If post (clazz.isInterface()) ==> \result.size() == 0; post (* The order of the result set is that subclasses are smaller than superclasses.*); |
static java.util.Set |
getSuperTypes(java.lang.Class clazz)
// The given Class must be effective pre clazz != null; // The set contains elements of type Class post (\forall Object o; \result.contains(o); o instanceof Class); // The set contains no null references post (\forall Class c; \result.contains(c); c != null); // The set contains only super types of clazz. post (\forall Class c; \result.contains(c); c.isAssignableFrom(clazz)); // The set contains post \result.contains(clazz); //If the this method is applied to class Object, the result //is the singleton {Object}. post (clazz == Object.class) ==> (\result.contains(Object.class)) && (\result.size() == 1); |
static java.lang.String |
packageName(java.lang.Class t)
// The given class must be effective. pre t != null; // The result is never null. post \result != null; // The result never contains illegal characters. post Character.isJavaIdentifierStart(\result.charAt(1)); post (\forall int i; (i>0) && (i<\result.length()); Character.isJavaIdentifierPart(\result.charAt(i))); The fully qualified package name of type |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CVS_REVISION
public static final Filter PUBLIC_ACCESS_FILTER
public static final Filter PROTECTED_ACCESS_FILTER
public static final Filter PACKAGE_ACCESS_FILTER
public static final Filter PRIVATE_ACCESS_FILTER
Constructor Detail |
public Classes()
Method Detail |
public static java.util.Set getImmediateSuperTypes(java.lang.Class clazz)
All immediate syper types of implements
and extends
clauses, or Object
when there is no extends
.
If the this method is applied to class Class, the result is the empty set.
clazz
- The class to get all immediate super types for.public static java.util.Set getSuperTypes(java.lang.Class clazz)
All syper types of
clazz
- The class to get all super types for.public static java.util.SortedSet getSuperClasses(java.lang.Class clazz)
All super classes of Object
.
If
clazz
- The class to get all super classes for.
//MvDMvDMvD : The following 2 postconditions are not required I think.public static boolean areInSamePackage(java.lang.Class t1, java.lang.Class t2)
t1
- The first type to compare.t2
- The second type to compare.public static java.lang.String packageName(java.lang.Class t)
t
- The type to get the fully qualified package name for.
//MvDMvDMvD : for JDK 1.2+ this can be specified in terms of
getPackage().getName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |