<commit_before>/*
 * Copyright (C) 2010 BloatIt.
 * 
 * This file is part of BloatIt.
 * 
 * BloatIt is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BloatIt 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with BloatIt. If not, see <http://www.gnu.org/licenses/>.
 */

package com.bloatit.web.htmlrenderer.htmlcomponent;

import com.bloatit.web.htmlrenderer.HtmlResult;

public class HtmlTextField extends HtmlComponent {

    private String defaultValue = null;
    private final String label;

    public HtmlTextField(String label){
        this.label = label;
    }

    public HtmlTextField(){
        this("");
    }

    @Override
    public void generate(HtmlResult htmlResult) {
        if (defaultValue == null) {
            htmlResult.write("<p>"+ this.generateLabel() + "<input name=\"" + name + "\" type=\"text\" id=\""+this.name+"\"/></p>");
        } else {
            htmlResult.write("<p>"+ this.generateLabel() + "<input name=\"" + name + "\" type=\"text\" id=\""+this.name+"\" value=\"" + defaultValue + "\" /></p>");
        }
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }
<commit_msg>Small update to htmlTextField (fix to previous commit)<commit_after>/*
 * Copyright (C) 2010 BloatIt.
 * 
 * This file is part of BloatIt.
 * 
 * BloatIt is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * BloatIt 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with BloatIt. If not, see <http://www.gnu.org/licenses/>.
 */

package com.bloatit.web.htmlrenderer.htmlcomponent;

import com.bloatit.web.htmlrenderer.HtmlResult;

public class HtmlTextField extends HtmlComponent {

    private String defaultValue = null;
    private String label;

    /**
     * Creates a textField with a default value and the label
     * @param defaultValue
     *      The value displayed by default in the textField after page
     *      loaded
     * @param label
     *      The text displayed next to the textField
     */
    public HtmlTextField(String defaultValue, String label){
        this.label = label;
        this.defaultValue = defaultValue;
    }

    /**
     * Creates a textField with a default value
     * @param defaultValue
     *      The value displayed by default in the textField after page
     *      loaded
     */
    public HtmlTextField(String defaultValue){
        this(defaultValue, "");
    }

    /**
     * Creates a textField with no default value and no associated label
     */
    public HtmlTextField(){
        this("");
    }

    /**
     * Sets the display that will be used along with the text field
     * @param label
     *      The string that will ne displayed next to the text field
     */
    public void setLabel(String label){
        this.label = label;
    }

    /**
     * Sets the value displayed in the text field after page is loaded
     * @param defaultValue
     *      The displayed value
     */
    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    @Override
    public void generate(HtmlResult htmlResult) {
        if (defaultValue == null) {
            htmlResult.write("<p>"+ this.generateLabel() + "<input name=\"" + name + "\" type=\"text\" id=\""+this.name+"\"/></p>");
        } else {
            htmlResult.write("<p>"+ this.generateLabel() + "<input name=\"" + name + "\" type=\"text\" id=\""+this.name+"\" value=\"" + defaultValue + "\" /></p>");
        }
    }

{'fraction_non_alphanumeric': 0.10602628001812416, 'fraction_numerical': 0.0022655188038060714, 'mean_word_length': 2.7194608256107835, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563931', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1179, 'n_words': 459}