propertyeditormanager.java

来自「kaffe是一个java虚拟机的源代码。里面包含了一些java例程和标准的jav」· Java 代码 · 共 98 行

JAVA
98
字号
/* * Java core library component. * * Copyright (c) 1997, 1998 *      Transvirtual Technologies, Inc.  All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */package java.beans;import java.util.Hashtable;public class PropertyEditorManager {  private static String[] editorpath = { "kaffe.beans.editors" };  private static Hashtable assoc = new Hashtable();  public static void registerEditor(Class targetType, Class editorClass)  {    if (editorClass == null) {      assoc.remove(targetType);    }    else {      assoc.put(targetType, editorClass);    }  }  public static PropertyEditor findEditor(Class targetType)  {    PropertyEditor editor = (PropertyEditor)assoc.get(targetType);    if (editor == null) {      editor = loadPropertyEditor(targetType);    }    return (editor);  }  public static String[] getEditorSearchPath()  {    return (editorpath);  }  public static void setEditorSearchPath(String path[])  {    editorpath = path;  }  private static PropertyEditor loadPropertyEditor(Class editorClass)  {    String editorname = editorClass.getName();    // First try to load editor from package.    PropertyEditor editor = loadNamedPropertyEditor(	editorClass.getClassLoader(), editorname + "Editor");    if (editor != null) {      return (editor);    }    // Extract the name without package information.    // We make allowances for both '.' and '/' seperators.    int pos = editorname.lastIndexOf('.');    int spos = editorname.lastIndexOf('/');    if (spos > pos) {      pos = spos;    }    editorname = editorname.substring(pos+1);    // Next try the search paths    for (int i = 0; i < editorpath.length; i++) {      editor = loadNamedPropertyEditor(editorClass.getClassLoader(),	editorpath[i] + "." + editorname + "Editor");      if (editor != null) {	return (editor);      }    }    return (null);  }  private static PropertyEditor loadNamedPropertyEditor(ClassLoader loader,	String cl)  {    try {      return (PropertyEditor)Class.forName(cl, true, loader).newInstance();    }    catch (ClassNotFoundException _) {    }    catch (ClassCastException _) {    }    catch (IllegalAccessException _) {    }    catch (InstantiationException _) {    }    return (null);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?