Java by API/org.apache.commons.lang/ClassUtils

Материал из Java эксперт
Версия от 14:47, 31 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

ClassUtils: getAllInterfaces(Class cls)

import org.apache.rumons.lang.ClassUtils;
public class ClassUtilsTrial {
  public static void main(String[] args) {
    System.out.println("1) Interfaces implemented by java.lang.String >>> "
        + ClassUtils.getAllInterfaces(String.class));
    System.out.println("2) SuperClasses of java.lang.String >>> "
        + ClassUtils.getAllSuperclasses(String.class));
    System.out.println("3) PackageName of a string >>> "
        + ClassUtils.getPackageName("A String", "IfNull"));
    System.out.println("4) Every String is an Object = "
        + ClassUtils.isAssignable(String.class, Object.class));
    System.out.println("5) Every Object is an String = "
        + ClassUtils.isAssignable(Object.class, String.class));
  }
}





ClassUtils.getAllSuperclasses(Class cls)

import org.apache.rumons.lang.ClassUtils;
public class ClassUtilsTrial {
  public static void main(String[] args) {
    System.out.println("1) Interfaces implemented by java.lang.String >>> "
        + ClassUtils.getAllInterfaces(String.class));
    System.out.println("2) SuperClasses of java.lang.String >>> "
        + ClassUtils.getAllSuperclasses(String.class));
    System.out.println("3) PackageName of a string >>> "
        + ClassUtils.getPackageName("A String", "IfNull"));
    System.out.println("4) Every String is an Object = "
        + ClassUtils.isAssignable(String.class, Object.class));
    System.out.println("5) Every Object is an String = "
        + ClassUtils.isAssignable(Object.class, String.class));
  }
}





ClassUtils.getPackageName(Object object, String valueIfNull)

import org.apache.rumons.lang.ClassUtils;
public class ClassUtilsTrial {
  public static void main(String[] args) {
    System.out.println("1) Interfaces implemented by java.lang.String >>> "
        + ClassUtils.getAllInterfaces(String.class));
    System.out.println("2) SuperClasses of java.lang.String >>> "
        + ClassUtils.getAllSuperclasses(String.class));
    System.out.println("3) PackageName of a string >>> "
        + ClassUtils.getPackageName("A String", "IfNull"));
    System.out.println("4) Every String is an Object = "
        + ClassUtils.isAssignable(String.class, Object.class));
    System.out.println("5) Every Object is an String = "
        + ClassUtils.isAssignable(Object.class, String.class));
  }
}





ClassUtils: isAssignable(Class cls, Class toClass)

import org.apache.rumons.lang.ClassUtils;
public class ClassUtilsTrial {
  public static void main(String[] args) {
    System.out.println("1) Interfaces implemented by java.lang.String >>> "
        + ClassUtils.getAllInterfaces(String.class));
    System.out.println("2) SuperClasses of java.lang.String >>> "
        + ClassUtils.getAllSuperclasses(String.class));
    System.out.println("3) PackageName of a string >>> "
        + ClassUtils.getPackageName("A String", "IfNull"));
    System.out.println("4) Every String is an Object = "
        + ClassUtils.isAssignable(String.class, Object.class));
    System.out.println("5) Every Object is an String = "
        + ClassUtils.isAssignable(Object.class, String.class));
  }
}