FileDocCategorySizeDatePackage
PropertyEditorManager.javaAPI DocAndroid 1.5 API3808Wed May 06 22:41:54 BST 2009java.beans

PropertyEditorManager

public class PropertyEditorManager extends Object

Fields Summary
private static String[]
path
private static final Map
registeredEditors
Constructors Summary
public PropertyEditorManager()


      
    
Methods Summary
public static synchronized java.beans.PropertyEditorfindEditor(java.lang.Class targetType)

        if (targetType == null) {
            throw new NullPointerException();
        }

        Class<?> editorClass = null;
        PropertyEditor editor = null;

        editorClass = registeredEditors.get(targetType);

        if (editorClass == null) {
            String editorClassName = targetType.getName() + "Editor"; //$NON-NLS-1$
            ClassLoader loader = targetType.getClassLoader();

            if (loader == null) {
                loader = Thread.currentThread().getContextClassLoader();
            }

            try {
                editorClass = Class.forName(editorClassName, true, loader);
            } catch (ClassNotFoundException cnfe) {
                String shortEditorClassName = editorClassName
                        .substring(editorClassName.lastIndexOf(".") + 1); //$NON-NLS-1$

                if (targetType.isPrimitive()) {
                    shortEditorClassName = shortEditorClassName.substring(0, 1)
                            .toUpperCase()
                            + shortEditorClassName.substring(1);
                }

                for (String element : path) {
                    editorClassName = element + "." + shortEditorClassName; //$NON-NLS-1$

                    try {
                        editorClass = Class.forName(editorClassName, true,
                                loader);
                        break;
                    } catch (Exception e) {
                    }
                }
            } catch (Exception e) {
            }
        }

        if (editorClass != null) {
            try {
                editor = (PropertyEditor) editorClass.newInstance();
            } catch (Exception e) {
            }
        }

        return editor;
    
public static synchronized java.lang.String[]getEditorSearchPath()

        return path;
    
public static voidregisterEditor(java.lang.Class targetType, java.lang.Class editorClass)

        if (targetType == null) {
            throw new NullPointerException();
        }

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPropertiesAccess();
        }
        if (editorClass != null) {
            registeredEditors.put(targetType, editorClass);
        } else {
            registeredEditors.remove(targetType);
        }
    
public static synchronized voidsetEditorSearchPath(java.lang.String[] apath)

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPropertiesAccess();
        }

        path = apath;