Java by API/org.apache.commons.lang/ClassUtils — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 14:47, 31 мая 2010

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));
  }
}