<commit_before>/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package ch.epfl.lamp.util;

import java.io.Writer;

/** This class provides methods to print XHTML document.
 */
public class XHTMLPrinter extends HTMLPrinter {

    //########################################################################
    // Public Constructors

    /** Creates a new instance */
    public XHTMLPrinter(Writer writer, String title, HTMLRepresentation repr) {
        super(writer, title, repr);
    }

    /** Creates a new instance */
    public XHTMLPrinter(Writer writer, String title, String encoding) {
        super(writer, title, encoding);
    }

    /** Creates a new instance */
    public XHTMLPrinter(Writer writer, String title) {
        super(writer, title, "utf-8");
    }

    //########################################################################
    // Public Methods

    /** Prints text 'text' in bold followed by a new line. */
    public HTMLPrinter printlnBold(String text) {
        return printlnTag("span",
            new XMLAttribute[]{ new XMLAttribute("style", "font-weight:bold;") },
            text);
    }

    /** Prints text 'text' in bold. */
    public HTMLPrinter printBold(String text) {
        return printTag("span",
            new XMLAttribute[]{ new XMLAttribute("style", "font-weight:bold;") },
            text);
    }

    /** Prints an horizontal line separator
     *  @ param n gives the number of printed blank spaces
     */
    public HTMLPrinter printHLine() {
        printOTag("div", new XMLAttribute[] {
            new XMLAttribute("style", "border:1px solid #aaaaaa; " +
                              "margin:10px 0px 5px 0px;height:1px;") });
        return printlnCTag("div");
    }

    /** Prints an horizontal line separator with attributes 'attrs'. */
    public HTMLPrinter printHLine(XMLAttribute[] attrs) {
        return printHLine();
    }

    /** Prints the <meta/> tag with attributes 'attrs' followed by a new line. */
    public HTMLPrinter printlnMeta(XMLAttribute[] attrs) {
	return printlnSTag("meta", attrs);
    }

    /** Prints the <link> tag with attributes 'attrs' followed by a new line. */
    public HTMLPrinter printlnLink(XMLAttribute[] attrs) {
	return printlnSTag("link", attrs);
    }

    //########################################################################

    /** Prints XHTML preamble.
     */
    protected void printPreamble() {
	println("<!--");
	println("< ?xml version=\"1.0\" encoding=\"" +
            representation.getEncoding() + "\"?>");
	println("//-->");
	println("<!DOCTYPE html PUBLIC \"-//W3C//DTD " +
            representation.getType() + "//" + representation.getLanguage() +
            "\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");<commit_msg>- improved javadoc comments<commit_after>/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package ch.epfl.lamp.util;

import java.io.Writer;

/**
 * This class provides methods to print XHTML document.
 *
 *  @author     <NAME>
 *  @version    1.1
 */
public class XHTMLPrinter extends HTMLPrinter {

    //########################################################################
    // Public Constructors

    /**
     * Creates a new instance.
     *
     * @param writer
     * @param title
     * @param repr
     */
    public XHTMLPrinter(Writer writer, String title, HTMLRepresentation repr) {
        super(writer, title, repr);
    }

    /**
     * Creates a new instance with "XHTML 1.0 Transitional" as default document type.
     *
     * @param writer
     * @param title
     * @param encoding
     */
    public XHTMLPrinter(Writer writer, String title, String encoding) {
        this(writer, title, new HTMLRepresentation("XHTML 1.0 Transitional", encoding));
    }

    /**
     * Creates a new instance with "utf-8" as default character encoding.
     *
     * @param writer
     * @param title
     */
    public XHTMLPrinter(Writer writer, String title) {
        this(writer, title, "utf-8");
    }

    //########################################################################
    // Public Methods - Printing simple values followed by a new line

    /**
     * Prints text <code>text</code> in bold followed by a new line.
     *
     * @param text
     */
    public HTMLPrinter printlnBold(String text) {
        return printlnTag("span",
            new XMLAttribute[]{ new XMLAttribute("style", "font-weight:bold;") },
            text);
    }

    /**
     * Prints an horizontal line separator followed by a new line.
     */
    public HTMLPrinter printlnHLine() {
        printOTag("div", new XMLAttribute[] {
            new XMLAttribute("style", "border:1px solid #aaaaaa; " +
                              "margin:10px 0px 5px 0px;height:1px;") });
        return printlnCTag("div");
    }

    //########################################################################
    // Public Methods - Printing simple values

    /**
     * Prints text <code>text</code> in bold.
     *
     * @param text
     */
    public HTMLPrinter printBold(String text) {
        return printTag("span",
            new XMLAttribute[]{ new XMLAttribute("style", "font-weight:bold;") },
            text);
    }

    /**
     * Prints an horizontal line separator
     */
    public HTMLPrinter printHLine() {
        printOTag("div", new XMLAttribute[] {
            new XMLAttribute("style", "border:1px solid #aaaaaa; " +
                              "margin:10px 0px 5px 0px;height:1px;") });
        return printCTag("div");
    }

    /**
     * Prints an horizontal line separator with attributes <code>attrs</code>.
     *
     * @param attrs
     */
    public HTMLPrinter printHLine(XMLAttribute[] attrs) {
        return printHLine();
    }

    /**
     * Prints the &lt;meta/&gt; tag with attributes <code>attrs</code>
     * followed by a new line.
     *
     * @param attrs
     */
    public HTMLPrinter printlnMeta(XMLAttribute[] attrs) {
	return printlnSTag("meta", attrs);
    }

    /**
     * Prints the &lt;link&gt; tag with attributes <code>attrs</code>
     * followed by a new line.
     *
     * @param attrs
     */
    public HTMLPrinter printlnLink(XMLAttribute[] attrs) {
	return printlnSTag("link", attrs);
    }

    //########################################################################

    /**
     * Prints XHTML preamble.
     */
    protected void printPreamble() {
	println("<!--");
	println("< ?xml version=\"1.0\" encoding=\"" +
            representation.getEncoding() + "\"?>");
	println("//-->");
	println("<!DOCTYPE html PUBLIC \"-//W3C//DTD " +
            representation.getType() + "//" + representation.getLanguage() +
            "\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
{'fraction_non_alphanumeric': 0.1969309462915601, 'fraction_numerical': 0.006730380939561179, 'mean_word_length': 2.0689797604295745, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 2, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7310095', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2011, 'n_words': 503}