All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jwall.apache.httpd.config.RewriteRule Maven / Gradle / Ivy

The newest version!
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *   Copyright (C) 2010-2014 Christian Bockermann 
 *    
 *   This file is part of the jwall.org apache-config library. The apache-config library is
 *   a parsing library to handle Apache HTTPD configuration files.
 *
 *   More information and documentation for the jwall-tools can be found at
 *   
 *                      http://www.jwall.org/apache-config
 *   
 *   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 3 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, see .
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package org.jwall.apache.httpd.config;

import java.io.File;

public class RewriteRule
    extends LineDirective
{
    private static final long serialVersionUID = -6430284010887629181L;
    private String cond;
    private String match;
    private String act;
    
    public RewriteRule( String line, File file, int lineNum ) throws ParseException {
        super( line, file, lineNum );
        
        if( args.size() > 0 )
            cond = args.get(0);
        
        if( args.size() > 1 )
            match = args.get(1);

        if( args.size() > 2 )
            act = args.get(2).replaceAll("(^[|]$)", "");;

    }
    
    public String toXML(){
        StringBuffer s = new StringBuffer();
        
        s.append( prefix() + " \n");

        if( cond != null )
            s.append( prefix() + "  "+cond+"\n" );
        
        if( match != null )
            s.append( prefix() + "  "+match+"\n");
        
        if( act != null ){
            s.append( prefix() + "  " );
            s.append( act );
            /*
            for( String flag : this.args ){
                s.append( prefix() + "  " + flag + "\n" );
            }
            s.append( prefix() );
            */
            s.append( "\n" );
        }
        
        s.append( prefix() + "\n");
        return s.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy