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

📄 urlrewritedoctask.java

📁 urlrewritefilter-2.6-src.zip
💻 JAVA
字号:
/**
 * Copyright (c) 2005, Paul Tuckey
 * All rights reserved.
 *
 * Each copy or derived work must preserve the copyright notice and this
 * notice unmodified.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
package org.tuckey.web.filters.urlrewrite;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;


/**
 * Used for javadoc style output of conf file.
 *
 * @author Paul Tuckey
 * @version $Revision: 1.10 $ $Date: 2005/12/07 10:27:04 $
 */
public class UrlRewriteDocTask extends Task {

    private String conf = UrlRewriteFilter.DEFAULT_WEB_CONF_PATH;

    private String dest = "urlrewrite-conf-overview.html";


    public void execute() throws BuildException {
        try {
            show();

        } catch (FileNotFoundException e) {
            throw new BuildException(e);
        } catch (IOException e) {
            throw new BuildException(e);
        }


    }

    private void show() throws IOException {
        // make sure we don't have claspath issues when we load runs
        Run.setCheckRunObjectExists(false);

        Conf confObj = new Conf(new FileInputStream(conf), conf);
        confObj.initialise();

        if (!confObj.isOk()) {
            throw new BuildException("conf is not ok");
        }
        log("loaded fine with " + confObj.getRules().size() + " rules");

        File reportFile = new File(dest);
        if (reportFile.exists()) {
            reportFile.delete();
        }
        FileWriter writer;
        writer = new FileWriter(reportFile);

        Status status = new Status(confObj);
        status.displayStatusOffline();

        writer.write(status.getBuffer().toString());
        writer.close();
    }

    public void setConf(String conf) {
        this.conf = conf;
    }

    public void setDest(String dest) {
        this.dest = dest;
    }

    /**
     * @deprecated use setConf
     */
    public void setConffile(String conffile) {
        setConf(conffile);
    }

    /**
     * @deprecated use setDest and specify a file not a dir.
     */
    public void setDestdir(String destdir) {
        setDest(destdir + "index.html");
    }
}

⌨️ 快捷键说明

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