/*
 * 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.
 */
/*
* This file was automatically generated by Autotag.  Please do not edit it manually.
*/
package org.apache.tiles.web.jsp.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import org.apache.tiles.autotag.core.runtime.ModelBody;
import org.apache.tiles.autotag.core.runtime.AutotagRuntime;

/**
 * <p>
 * Inserts the value of an attribute into the page.
 * </p>
 * <p>
 * This tag can be flexibly used to insert the value of an attribute into a
 * page. As in other usages in Tiles, every attribute can be determined to have
 * a "type", either set explicitly when it was defined, or "computed". If the
 * type is not explicit, then if the attribute value is a valid definition, it
 * will be inserted as such. Otherwise, if it begins with a "/" character, it
 * will be treated as a "template". Finally, if it has not otherwise been
 * assigned a type, it will be treated as a String and included without any
 * special handling.
 * </p>
 * 
 * <p>
 * Example :
 * </p>
 * 
 * <pre>
 *     &lt;tiles:insertAttribute name=&quot;body&quot; /&gt;
 * </pre>
 */
public class InsertAttributeTag extends SimpleTagSupport {

    /**
     * The template model.
     */
    private org.apache.tiles.template.InsertAttributeModel model = new org.apache.tiles.template.InsertAttributeModel();

    /**
     * If true, if an exception happens during rendering, of if the attribute is
     * null, the problem will be ignored.
     */
    private boolean ignore;

    /**
     * The preparer to invoke before rendering the attribute.
     */
    private java.lang.String preparer;

    /**
     * A comma-separated list of roles. If present, the attribute will be rendered
     * only if the current user belongs to one of the roles.
     */
    private java.lang.String role;

    /**
     * The default value of the attribute. To use only if the attribute was not
     * computed.
     */
    private java.lang.Object defaultValue;

    /**
     * The default comma-separated list of roles. To use only if the attribute was
     * not computed.
     */
    private java.lang.String defaultValueRole;

    /**
     * The default type of the attribute. To use only if the attribute was not
     * computed.
     */
    private java.lang.String defaultValueType;

    /**
     * The name of the attribute.
     */
    private java.lang.String name;

    /**
     * The attribute to use immediately, if not null.
     */
    private org.apache.tiles.api.Attribute value;

    /**
     * If true, the response will be flushed after the insert.
     */
    private boolean flush;

    /**
     * Getter for ignore property.
     *
     * @return If true, if an exception happens during rendering, of if the
     *         attribute is null, the problem will be ignored.
     */
    public boolean isIgnore() {
        return ignore;
    }

    /**
     * Setter for ignore property.
     *
     * @param ignore If true, if an exception happens during rendering, of if the
     *               attribute is null, the problem will be ignored.
     */
    public void setIgnore(boolean ignore) {
        this.ignore = ignore;
    }

    /**
     * Getter for preparer property.
     *
     * @return The preparer to invoke before rendering the attribute.
     */
    public java.lang.String getPreparer() {
        return preparer;
    }

    /**
     * Setter for preparer property.
     *
     * @param preparer The preparer to invoke before rendering the attribute.
     */
    public void setPreparer(java.lang.String preparer) {
        this.preparer = preparer;
    }

    /**
     * Getter for role property.
     *
     * @return A comma-separated list of roles. If present, the attribute will be
     *         rendered only if the current user belongs to one of the roles.
     */
    public java.lang.String getRole() {
        return role;
    }

    /**
     * Setter for role property.
     *
     * @param role A comma-separated list of roles. If present, the attribute will
     *             be rendered only if the current user belongs to one of the roles.
     */
    public void setRole(java.lang.String role) {
        this.role = role;
    }

    /**
     * Getter for defaultValue property.
     *
     * @return The default value of the attribute. To use only if the attribute was
     *         not computed.
     */
    public java.lang.Object getDefaultValue() {
        return defaultValue;
    }

    /**
     * Setter for defaultValue property.
     *
     * @param defaultValue The default value of the attribute. To use only if the
     *                     attribute was not computed.
     */
    public void setDefaultValue(java.lang.Object defaultValue) {
        this.defaultValue = defaultValue;
    }

    /**
     * Getter for defaultValueRole property.
     *
     * @return The default comma-separated list of roles. To use only if the
     *         attribute was not computed.
     */
    public java.lang.String getDefaultValueRole() {
        return defaultValueRole;
    }

    /**
     * Setter for defaultValueRole property.
     *
     * @param defaultValueRole The default comma-separated list of roles. To use
     *                         only if the attribute was not computed.
     */
    public void setDefaultValueRole(java.lang.String defaultValueRole) {
        this.defaultValueRole = defaultValueRole;
    }

    /**
     * Getter for defaultValueType property.
     *
     * @return The default type of the attribute. To use only if the attribute was
     *         not computed.
     */
    public java.lang.String getDefaultValueType() {
        return defaultValueType;
    }

    /**
     * Setter for defaultValueType property.
     *
     * @param defaultValueType The default type of the attribute. To use only if the
     *                         attribute was not computed.
     */
    public void setDefaultValueType(java.lang.String defaultValueType) {
        this.defaultValueType = defaultValueType;
    }

    /**
     * Getter for name property.
     *
     * @return The name of the attribute.
     */
    public java.lang.String getName() {
        return name;
    }

    /**
     * Setter for name property.
     *
     * @param name The name of the attribute.
     */
    public void setName(java.lang.String name) {
        this.name = name;
    }

    /**
     * Getter for value property.
     *
     * @return The attribute to use immediately, if not null.
     */
    public org.apache.tiles.api.Attribute getValue() {
        return value;
    }

    /**
     * Setter for value property.
     *
     * @param value The attribute to use immediately, if not null.
     */
    public void setValue(org.apache.tiles.api.Attribute value) {
        this.value = value;
    }

    /**
     * Getter for flush property.
     *
     * @return If true, the response will be flushed after the insert.
     */
    public boolean isFlush() {
        return flush;
    }

    /**
     * Setter for flush property.
     *
     * @param flush If true, the response will be flushed after the insert.
     */
    public void setFlush(boolean flush) {
        this.flush = flush;
    }

    @Override
    public void doTag() throws JspException, IOException {
        AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.jsp.autotag.JspAutotagRuntime();
        if (runtime instanceof SimpleTagSupport) {
            SimpleTagSupport tag = (SimpleTagSupport) runtime;
            tag.setJspContext(getJspContext());
            tag.setJspBody(getJspBody());
            tag.setParent(getParent());
            tag.doTag();
        }
        org.apache.tiles.request.Request request = runtime.createRequest();
        ModelBody modelBody = runtime.createModelBody();
        model.execute(ignore, preparer, role, defaultValue, defaultValueRole, defaultValueType, name, value, flush,
                request, modelBody);
    }
}
