org.jwall.apache.httpd.config.Include Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apache-config Show documentation
Show all versions of apache-config Show documentation
A Java library for reading Apache httpd configuration files
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;
import java.util.LinkedList;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
/**
*
* This class represents the include directive of Apache.
*
* @author Christian Bockermann <[email protected]>
*
*/
@XStreamAlias("Include")
public class Include
extends ContainerDirective
{
/** The unique class id */
private static final long serialVersionUID = -3377718126165895115L;
@XStreamAlias("pattern")
@XStreamAsAttribute
protected String pattern = "";
/**
*
* @param line
* @param file
* @param lineNum
* @throws ParseException
*/
public Include( String line, File file, int lineNum ) throws ParseException {
super( line, file, lineNum );
name = "Include";
args = new LinkedList();
String[] token = line.split("\\s+", 2);
if( token.length > 1 )
for( String param : token[1].split( "\\s+" ) )
args.add( this.removeQuotes( param ) );
else
throw new ParseException("Include-directive must be followed by a path or pattern!");
pattern = args.getFirst();
}
/* (non-Javadoc)
* @see org.apache.httpd.config.ContainerDirective#toPlainTxt()
*/
@Override
public String toPlainTxt()
{
return rawLine;
}
public String toXML(){
StringBuffer s = new StringBuffer();
s.append( prefix() + "\n" );
for( Directive d : nested )
s.append( d.toXML() );
s.append( prefix() + " " );
return s.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy