java类java.beans.PropertyEditorManager的实例源码

Test6963811.java 文件源码 项目:jdk8u-dev-jdk 阅读 21 收藏 0 点赞 0 评论 0
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                PropertyEditorManager.findEditor(Super.class);
            }
        }
        else {
            PropertyEditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
}
StringPEConverter.java 文件源码 项目:mocha-mvc 阅读 19 收藏 0 点赞 0 评论 0
@Override
public Object convertOne(Class<?> type, InvokeContext ctx, Object from) {
    if (from != null && !(from instanceof String)) {
        return NOT_CONVERTABLE;
    }
    PropertyEditor pe = PropertyEditorManager.findEditor(type);
    if (pe == null) {
        return NOT_CONVERTABLE;
    }
    if (from == null) {
        return null;
    } else {
        try {
            pe.setAsText((String) from);
            return pe.getValue();
        } catch (Exception e) {
            log.warn("Can't convert parameter to {}", type.getName(), e);
            return NOT_CONVERTABLE;
        }
    }
}
Test6963811.java 文件源码 项目:jdk7-jdk 阅读 19 收藏 0 点赞 0 评论 0
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                PropertyEditorManager.findEditor(Super.class);
            }
        }
        else {
            PropertyEditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
}
Test6963811.java 文件源码 项目:openjdk-source-code-learn 阅读 22 收藏 0 点赞 0 评论 0
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                PropertyEditorManager.findEditor(Super.class);
            }
        }
        else {
            PropertyEditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
}
JspRuntimeLibrary.java 文件源码 项目:class-guard 阅读 26 收藏 0 点赞 0 评论 0
public static Object getValueFromPropertyEditorManager(
                 Class<?> attrClass, String attrName, String attrValue) 
    throws JasperException 
{
    try {
        PropertyEditor propEditor = 
            PropertyEditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",
                                 attrValue, attrClass.getName(), attrName,
                                 ex.getMessage()));
    }
}
Test6963811.java 文件源码 项目:OLD-OpenJDK8 阅读 23 收藏 0 点赞 0 评论 0
public void run() {
    try {
        Thread.sleep(this.time); // increase the chance of the deadlock
        if (this.sync) {
            synchronized (Test6963811.class) {
                PropertyEditorManager.findEditor(Super.class);
            }
        }
        else {
            PropertyEditorManager.findEditor(Sub.class);
        }
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
}
ObjectPropertyUtils.java 文件源码 项目:rice 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Get a property editor given a property type.
 *
 * @param propertyType The property type to look up an editor for.
 * @param path The property path, if applicable.
 * @return property editor
 */
public static PropertyEditor getPropertyEditor(Class<?> propertyType) {
    PropertyEditorRegistry registry = getPropertyEditorRegistry();
    PropertyEditor editor = null;

    if (registry != null) {
        editor = registry.findCustomEditor(propertyType, null);
    } else {

        DataDictionaryService dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
        Map<Class<?>, String> editorMap = dataDictionaryService.getPropertyEditorMap();
        String editorPrototypeName = editorMap == null ? null : editorMap.get(propertyType);

        if (editorPrototypeName != null) {
            editor = (PropertyEditor) dataDictionaryService.getDataDictionary().getDictionaryPrototype(editorPrototypeName);
        }
    }

    if (editor == null && propertyType != null) {
        // Fall back to default beans lookup
        editor = PropertyEditorManager.findEditor(propertyType);
    }

    return editor;
}
PropertyEditorManagerTest.java 文件源码 项目:cn1 阅读 16 收藏 0 点赞 0 评论 0
public void testStringEditor_SetAsText_Null() {
    PropertyEditor editor = PropertyEditorManager.findEditor(String.class);

    editor.setAsText("null");
    assertEquals("null", editor.getAsText());
    assertEquals("\"null\"", editor.getJavaInitializationString());
    assertEquals("null", editor.getValue());

    editor.setAsText("");
    assertEquals("", editor.getAsText());
    assertEquals("\"\"", editor.getJavaInitializationString());

    editor.setAsText(null);
    assertEquals("null", editor.getAsText());
    assertEquals("\"null\"", editor.getJavaInitializationString());
    assertNull(editor.getValue());
}
PropertyEditorManagerRegressionTest.java 文件源码 项目:cn1 阅读 18 收藏 0 点赞 0 评论 0
public void testFindEditorAccordingPath_2() throws Exception {
    // Regression Harmony-1205
    String newPath[] = new String[origPath.length + 1];
    newPath[origPath.length] = "org.apache.harmony.beans.tests.support";
    for (int i = 0; i < origPath.length; i++) {
        newPath[i] = origPath[i];
    }

    PropertyEditorManager.setEditorSearchPath(newPath);

    PropertyEditor editor = PropertyEditorManager.findEditor(Class
            .forName("java.lang.String"));

    assertEquals(org.apache.harmony.beans.editors.StringEditor.class,
            editor.getClass());
}
JspRuntimeLibrary.java 文件源码 项目:apache-tomcat-7.0.57 阅读 23 收藏 0 点赞 0 评论 0
public static Object getValueFromPropertyEditorManager(
                 Class<?> attrClass, String attrName, String attrValue) 
    throws JasperException 
{
    try {
        PropertyEditor propEditor = 
            PropertyEditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",
                                 attrValue, attrClass.getName(), attrName,
                                 ex.getMessage()));
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号