HelpCtx.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:incubator-netbeans 作者:
/** Finds help context for a generic object. Right now checks
 * for HelpCtx.Provider and handles java.awt.Component in a
 * special way compatible with JavaHelp.
 * Also {@link BeanDescriptor}'s are checked for a string-valued attribute
 * <code>helpID</code>, as per the JavaHelp specification (but no help sets
 * will be loaded).
 *
 * @param instance to search help for
 * @return the help for the object or <code>HelpCtx.DEFAULT_HELP</code> if HelpCtx cannot be found
 *
 * @since 4.3
 */
public static HelpCtx findHelp(Object instance) {
    if (instance instanceof java.awt.Component) {
        return findHelp((java.awt.Component) instance);
    }

    if (instance instanceof HelpCtx.Provider) {
        return ((HelpCtx.Provider) instance).getHelpCtx();
    }

    try {
        BeanDescriptor d = Introspector.getBeanInfo(instance.getClass()).getBeanDescriptor();
        String v = (String) d.getValue("helpID"); // NOI18N

        if (v != null) {
            return new HelpCtx(v);
        }
    } catch (IntrospectionException e) {
        err.log(Level.FINE, "findHelp on {0}: {1}", new Object[]{instance, e});
    }

    return HelpCtx.DEFAULT_HELP;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号