List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
public static String[] getMethodParameter(Method method) { Class<?>[] paramTypes = method.getParameterTypes(); if (paramTypes.length == 0) { return null; }/* w w w.j a va 2 s. com*/ String[] result = new String[paramTypes.length]; int i = 0; for (Class<?> c : paramTypes) { result[i++] = c.getName(); } return result; }
From source file:Main.java
public static String javaClassToSmali(Class<?> klazz) { return javaClassToSmali(klazz.getName()); }
From source file:Main.java
public static String escaped(Class<?> clazz) { return escaped(clazz.getName()); }
From source file:SampleArrayReflection.java
static void printArrayNames(Object target) { Class targetClass = target.getClass(); Field[] publicFields = targetClass.getFields(); for (int i = 0; i < publicFields.length; i++) { String fieldName = publicFields[i].getName(); Class typeClass = publicFields[i].getType(); String fieldType = typeClass.getName(); if (typeClass.isArray()) { System.out.println("Name: " + fieldName + ", Type: " + fieldType); }// w ww . j a v a2 s . com } }
From source file:Main.java
/** * Gives back the string of the package name where the class is defined. * Note: this has nothing to do with the notion of classloader Packages. * @param clazz/* ww w .j a va 2s.c o m*/ * @return */ public static String getPackageName(final Class<?> clazz) { String classname = clazz.getName(); if (classname == null) return null; // Should not happen. It is not a canonical name int index = classname.lastIndexOf("."); return (index == -1) ? "" : classname.substring(0, index); }
From source file:Main.java
public static String writeClass(Class<?> clazz) { if (clazz == null) return null; return clazz.getName(); }
From source file:Main.java
/** * Convenience method for retrieving a subset of the UIDefaults pertaining * to a particular class./* w w w. j av a2 s . c o m*/ * * @param clazz * the class of interest * @return the UIDefaults of the class */ public static UIDefaults getUIDefaultsOfClass(final Class clazz) { String name = clazz.getName(); name = name.substring(name.lastIndexOf(".") + 2); return getUIDefaultsOfClass(name); }
From source file:Main.java
/** * Convenience method to obtain the Swing class from which this * component was directly or indirectly derived. * //www.jav a 2s. c om * @param <T> * @param component The component whose Swing superclass is to be * determined * @return The nearest Swing class in the inheritance tree */ public static <T extends JComponent> Class<?> getJClass(T component) { Class<?> clazz = component.getClass(); while (!clazz.getName().matches("javax.swing.J[^.]*$")) { clazz = clazz.getSuperclass(); } return clazz; }
From source file:Main.java
/** * Indicates if the collection has been wrapped by Collections.unmodifiableCollection(...) * //from w w w .ja v a 2 s . c om * @param collection * @return */ public static boolean isUnmodifiableCollection(Object collection) { // Precondition checking // if (collection == null) { return false; } // Get class // Class<?> collectionClass = collection.getClass(); return (collectionClass.getName().startsWith("java.util.Collections$Unmodifiable")); }
From source file:com.topsoft.botspider.io.UnionData.java
public static void setParseClass(Configuration conf, Class... classez) { if (conf == null || classez == null) return;/* w w w. j av a 2 s.c o m*/ ArrayList<String> arrParse = new ArrayList<String>(classez.length); for (Class clzss : classez) { arrParse.add(clzss.getName()); } conf.setStrings(UNION_CLASS, arrParse.toArray(new String[arrParse.size()])); }