SearchForm.java 2.5 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.sling.api.SlingHttpServletRequest
 */
package com.day.cq.searchpromote.xml.form;

import com.day.cq.searchpromote.xml.form.AutoComplete;
import com.day.cq.searchpromote.xml.form.Form;
import com.day.cq.searchpromote.xml.form.Input;
import com.day.cq.searchpromote.xml.form.Tnt;
import java.util.List;
import org.apache.sling.api.SlingHttpServletRequest;

public class SearchForm {
    private SlingHttpServletRequest request;
    private AutoComplete autocomplete;
    private Tnt tnt;
    private Form form;
    private String action;

    public SearchForm(SlingHttpServletRequest request, AutoComplete autocomplete, Tnt tnt, Form form) {
        this.request = request;
        this.autocomplete = autocomplete;
        this.tnt = tnt;
        this.form = form;
    }

    public SearchForm(AutoComplete autocomplete, Tnt tnt, Form form) {
        this(null, autocomplete, tnt, form);
    }

    public SlingHttpServletRequest getRequest() {
        return this.request;
    }

    public void setRequest(SlingHttpServletRequest request) {
        this.request = request;
    }

    public String getAction() {
        return this.action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public AutoComplete getAutocomplete() {
        return this.autocomplete;
    }

    public Tnt getTnt() {
        return this.tnt;
    }

    public Form getForm() {
        return this.form;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("<form method=\"GET\"");
        if (this.form.getId() != null) {
            sb.append(" id=\"" + this.form.getId() + "\"");
        }
        if (this.form.getName() != null) {
            sb.append(" name=\"" + this.form.getName() + "\"");
        }
        sb.append(" action=\"" + (this.action != null ? this.action : this.form.getAction()) + "\"");
        sb.append(">\n");
        for (Input input : this.form.getInputs()) {
            sb.append(input.toString() + "\n");
        }
        if (this.autocomplete != null && this.autocomplete.getEnabled().booleanValue() && this.autocomplete.getFormContent() != null) {
            sb.append(this.autocomplete.getFormContent());
        }
        if (this.tnt != null && this.tnt.getEnabled().booleanValue() && this.tnt.getFormContent() != null) {
            sb.append(this.tnt.getFormContent());
        }
        sb.append("</form>");
        return sb.toString();
    }
}