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

org.jwall.apache.httpd.config.Comment 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;

import com.thoughtworks.xstream.annotations.XStreamAlias;

@XStreamAlias("Comment")
public class Comment
    extends AbstractDirective
{
    private static final long serialVersionUID = 2474508350113605443L;
    String encodedEntities = "&";
    String content;
    int end;
    
    public Comment( String content, File file, int line, int end ){
        super( content, file, line );
        this.content = content;
        this.end = end;
    }
    
    public String toString(){
        StringBuffer s = new StringBuffer();
        
        s.append( "\n");
        
        //s.append( prefix() + "" );
        //s.append("]]>");
        s.append( "");
        return s.toString();
    }

    public String toXML(){
        return toString();
    }
    
    public String toPlainTxt(){
        StringBuffer s = new StringBuffer();
        s.append( content );
        return s.toString();
    }
    
    public String partialEntityEncode( String s )
    {
        StringBuffer buf = new StringBuffer();
        int len = (s == null ? -1 : s.length());

        for ( int i = 0; i < len; i++ )
        {
            char c = s.charAt( i );
            if ( encodedEntities.indexOf( c ) >= 0 )
            {
                buf.append( "&#" + (int)c + ";" );
            }
            else
            {
                buf.append( c );
            }
        }
        return buf.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy