/** * Locate a value editor for a given target type. * * @param typeName The class name of the object to be edited. * @return An editor for the given type or null if none was found. * @throws ClassNotFoundException when the class could not be found */ public static PropertyEditor findEditor(final String typeName) throws ClassNotFoundException { // see if it is a primitive type first Class<?> type = Classes.getPrimitiveTypeForName(typeName); if (type == null) { // nope try look up ClassLoader loader = Thread.currentThread().getContextClassLoader(); type = loader.loadClass(typeName); } return PropertyEditorManager.findEditor(type); }
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { return Classes.loadClass(v.getName()); } }
/** * Get the short name of the specified class by striping off the package * name. * * @param type Class name. * @return Short class name. */ public static String stripPackageName(final Class type) { return stripPackageName(type.getName()); }
private Class loadClass(String clazz) throws ClassNotFoundException { Class isPrimitive = Classes.getPrimitiveTypeForName(clazz); if (isPrimitive != null) return Classes.getPrimitiveWrapper(isPrimitive); ClassLoader cl = TCLAction.UTIL.getContextClassLoader(); return cl.loadClass(clazz); }
/** * Checks if a class has a default (no args) constructor */ public boolean hasDefaultConstructor(Class c) { try { Constructor ctr = c.getConstructor(new Class[0]); } catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; } return true; }
if( isPrimitive(className) == true ) return (Class) Classes.PRIMITIVE_NAME_TYPE_MAP.get(className); Class componentType = loadClass(className.substring(arrayDimension), classLoader);
String className = getProperty(property, defaultClassName); Class clazz = null; try clazz = loadClass(className);
if(type.isPrimitive()) type = Classes.getPrimitiveWrapper(type);
public static synchronized ServerConfig getInstance() { if (instance != null) return instance; instance = (ServerConfig) Classes.instantiate(ServerConfig.class, SERVER_CONFIG_CLASS_PROPERTY, DEFAULT_SERVER_CONFIG_CLASS); return instance; }
private boolean writeAsValue(final Class type) { return Classes.isPrimitive(type) || type == String.class || type == java.util.Date.class || type == java.math.BigDecimal.class || type == java.math.BigInteger.class; }
if(Classes.isPrimitiveWrapper(valueType)) valueType = Classes.getPrimitive(valueType);
/** * Check if the given class is a primitive class or a primitive * wrapper class. * * @param type Class to check. * @return True if the class is a primitive or primitive wrapper. */ public static boolean isPrimitive(final Class type) { if (type.isPrimitive() || isPrimitiveWrapper(type)) { return true; } return false; } /** Check type against boolean, byte, char, short, int, long, float, double.
private Class loadClass(String clazz) throws ClassNotFoundException { Class isPrimitive = Classes.getPrimitiveTypeForName(clazz); if (isPrimitive != null) return Classes.getPrimitiveWrapper(isPrimitive); ClassLoader cl = TCLAction.UTIL.getContextClassLoader(); return cl.loadClass(clazz); }
public boolean hasMatchingEJBFind(Class bean, Method finder) { try { String methodName = "ejbF" + finder.getName().substring(1); return (bean.getMethod(methodName, finder.getParameterTypes()) != null); } catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; } }
if(type.isPrimitive()) type = Classes.getPrimitiveWrapper(type);
public static synchronized ServerConfig getInstance() { if (instance != null) return instance; instance = (ServerConfig) Classes.instantiate(ServerConfig.class, SERVER_CONFIG_CLASS_PROPERTY, DEFAULT_SERVER_CONFIG_CLASS); return instance; }
private static boolean writeAsValue(final Class type) { return Classes.isPrimitive(type) || type == String.class || type == java.util.Date.class || type == java.math.BigDecimal.class || type == java.math.BigInteger.class; }
Class<?> typeClass = Classes.getPrimitiveTypeForName(typeName); if (typeClass == null)
/** * This method acts equivalently to invoking * <code>Thread.currentThread().getContextClassLoader().loadClass(className);</code> but it also * supports primitive types and array classes of object types or primitive types. * * @param className the qualified name of the class or the name of primitive type or * array in the same format as returned by the * <code>java.lang.Class.getName()</code> method. * @return the Class object for the requested className * * @throws ClassNotFoundException when the <code>classLoader</code> can not find the requested class */ public static Class loadClass(String className) throws ClassNotFoundException { return loadClass(className, Thread.currentThread().getContextClassLoader()); }
/** * Check if a class (or its superclasses) declare a given method */ public boolean hasMatchingMethod(Class bean, Method method) { try { bean.getMethod(method.getName(), method.getParameterTypes()); return true; } catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; } }