/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.struts2.views.jsp.ui;

import org.apache.struts2.util.ValueStack;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Component;
import org.apache.struts2.components.Script;

/**
 * @see Script
 */
public class ScriptTag extends AbstractUITag {

    protected String async;
    protected String charset;
    protected String defer;
    protected String src;
    protected String type;
    protected String referrerpolicy;
    protected String nomodule;
    protected String integrity;
    protected String crossorigin;

    @Override
    public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new Script(stack, req, res);
    }

    protected void populateParams() {
        super.populateParams();
        Script script = ((Script) component);
        script.setAsync(async);
        script.setCharset(charset);
        script.setDefer(defer);
        script.setSrc(src);
        script.setType(type);
        script.setReferrerpolicy(referrerpolicy);
        script.setNomodule(nomodule);
        script.setIntegrity(integrity);
        script.setCrossorigin(crossorigin);
    }

    public void setAsync(String async) {
        this.async = async;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    public void setSrc(String src) {
        this.src = src;
    }

    public void setDefer(String defer) {
        this.defer = defer;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setReferrerpolicy(String referrerpolicy) {
        this.referrerpolicy = referrerpolicy;
    }

    public void setNomodule(String nomodule) {
        this.nomodule = nomodule;
    }

    public void setIntegrity(String integrity) {
        this.integrity = integrity;
    }

    public void setCrossorigin(String crossorigin) {
        this.crossorigin = crossorigin;
    }
}
