1 package org.ozoneDB.tools.OPP.srcgen.query; 9 10 import org.ozoneDB.tools.OPP.srcgen.ClassQuery; 11 12 17 public class ReflectionClassQuery implements ClassQuery { 18 public boolean isAssignable(String itf, String from) throws ClassNotFoundException { 19 Class itfClass = Class.forName(itf); 20 Class fromClass = Class.forName(from); 21 return itfClass.isAssignableFrom(fromClass); 22 } 23 24 public String [] getInterfaces(String className) throws ClassNotFoundException { 25 Class clazz = Class.forName(className); 26 Class interfaces [] = clazz.getInterfaces(); 27 return classesToStrings(interfaces); 28 } 29 30 public boolean isInterface(String className) throws ClassNotFoundException { 31 Class clazz = Class.forName(className); 32 return clazz.isInterface(); 33 } 34 35 36 private String [] classesToStrings(Class classes[]) { 37 String names [] = new String [classes.length]; 38 for (int i = 0; i < classes.length; i++) { 39 Class aClass = classes[i]; 40 names[i] = aClass.getName(); 41 } 42 return names; 43 } 44 } 45 | Popular Tags |