⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dependencychecker.java

📁 一个比较不错的java分页标签,有源代码,开发者 可以学习学习
💻 JAVA
字号:
/**
 * Licensed under the Artistic License; you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://displaytag.sourceforge.net/license.html
 *
 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */
package org.displaytag.util;

import javax.servlet.jsp.JspTagException;

import org.displaytag.Messages;


/**
 * An user-friendly dependency checker. This will check the presence of libraries needed by displaytag, throwing an
 * Exception with an informative message if the library is missing or the version is not compatible.
 * @author Fabrizio Giustina
 * @version $Revision: 956 $ ($Author: fgiust $)
 */
public final class DependencyChecker
{

    /**
     * Has the commons-lang dependency been checked?
     */
    private static boolean commonsLangChecked;

    /**
     * Don't instantiate.
     */
    private DependencyChecker()
    {
        // unused
    }

    /**
     * Displaytag requires commons-lang 2.x or better; it is not compatible with earlier versions.
     * @throws JspTagException if the wrong library, or no library at all, is found.
     */
    public static void check() throws JspTagException
    {
        if (commonsLangChecked)
        {
            return;
        }
        try
        {
            // Do they have commons lang ?
            Class stringUtils = Class.forName("org.apache.commons.lang.StringUtils"); //$NON-NLS-1$
            try
            {
                // this method is new in commons-lang 2.1
                stringUtils.getMethod("splitPreserveAllTokens", new Class[]{String.class}); //$NON-NLS-1$
            }
            catch (NoSuchMethodException ee)
            {
                throw new JspTagException(Messages.getString("DependencyChecker.lib.incompatible", //$NON-NLS-1$
                    new Object[]{"commons-lang", "2.1", "http://jakarta.apache.org/commons/lang"} //$NON-NLS-1$ //$NON-NLS-1$
                    ));
            }
        }
        catch (ClassNotFoundException e)
        {
            throw new JspTagException(Messages.getString("DependencyChecker.lib.missing", //$NON-NLS-1$
                new Object[]{"commons-lang", "2.1", "http://jakarta.apache.org/commons/lang"} //$NON-NLS-1$ //$NON-NLS-1$
                ));
        }
        commonsLangChecked = true;
    }

}

⌨️ 快捷键说明

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