package com.cloudera.server.web.cmf.include;

import com.cloudera.server.web.cmf.ConfigRevisionInfo;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Constructor;
import java.util.List;
import org.jamon.AbstractRenderer;
import org.jamon.AbstractTemplateImpl;
import org.jamon.AbstractTemplateProxy;
import org.jamon.AbstractTemplateProxy.ImplData;
import org.jamon.AbstractTemplateProxy.Intf;
import org.jamon.Renderer;
import org.jamon.TemplateManager;
import org.jamon.annotations.Template;

@Template(signature="A54C1594B34ED4144AC421C9AF5BDB39", requiredArguments={@org.jamon.annotations.Argument(name="entries", type="List<ConfigRevisionInfo>"), @org.jamon.annotations.Argument(name="currentConfigRevision", type="ConfigRevisionInfo")})
public class ConfigRevisionsTable extends AbstractTemplateProxy
{
  public ConfigRevisionsTable(TemplateManager p_manager)
  {
    super(p_manager);
  }

  protected ConfigRevisionsTable(String p_path)
  {
    super(p_path);
  }

  public ConfigRevisionsTable()
  {
    super("/com/cloudera/server/web/cmf/include/ConfigRevisionsTable");
  }

  protected AbstractTemplateProxy.ImplData makeImplData()
  {
    return new ImplData();
  }

  public ImplData getImplData() {
    return (ImplData)super.getImplData();
  }

  public AbstractTemplateImpl constructImpl(Class<? extends AbstractTemplateImpl> p_class)
  {
    try
    {
      return (AbstractTemplateImpl)p_class.getConstructor(new Class[] { TemplateManager.class, ImplData.class }).newInstance(new Object[] { getTemplateManager(), getImplData() });
    }
    catch (RuntimeException e)
    {
      throw e;
    }
    catch (Exception e) {
    }
    throw new RuntimeException(e);
  }

  protected AbstractTemplateImpl constructImpl()
  {
    return new ConfigRevisionsTableImpl(getTemplateManager(), getImplData());
  }

  public Renderer makeRenderer(List<ConfigRevisionInfo> entries, ConfigRevisionInfo currentConfigRevision) {
    return new AbstractRenderer(entries, currentConfigRevision)
    {
      public void renderTo(Writer jamonWriter)
        throws IOException
      {
        ConfigRevisionsTable.this.render(jamonWriter, this.val$entries, this.val$currentConfigRevision);
      }
    };
  }

  public void render(Writer jamonWriter, List<ConfigRevisionInfo> entries, ConfigRevisionInfo currentConfigRevision) throws IOException
  {
    renderNoFlush(jamonWriter, entries, currentConfigRevision);
    jamonWriter.flush();
  }

  public void renderNoFlush(Writer jamonWriter, List<ConfigRevisionInfo> entries, ConfigRevisionInfo currentConfigRevision) throws IOException
  {
    ImplData implData = getImplData();
    implData.setEntries(entries);
    implData.setCurrentConfigRevision(currentConfigRevision);
    Intf instance = (Intf)getTemplateManager().constructImpl(this);
    instance.renderNoFlush(jamonWriter);
    reset();
  }

  public static class ImplData extends AbstractTemplateProxy.ImplData
  {
    private List<ConfigRevisionInfo> m_entries;
    private ConfigRevisionInfo m_currentConfigRevision;

    public void setEntries(List<ConfigRevisionInfo> entries)
    {
      this.m_entries = entries;
    }

    public List<ConfigRevisionInfo> getEntries() {
      return this.m_entries;
    }

    public void setCurrentConfigRevision(ConfigRevisionInfo currentConfigRevision)
    {
      this.m_currentConfigRevision = currentConfigRevision;
    }

    public ConfigRevisionInfo getCurrentConfigRevision() {
      return this.m_currentConfigRevision;
    }
  }

  public static abstract interface Intf extends AbstractTemplateProxy.Intf
  {
    public abstract void renderNoFlush(Writer paramWriter)
      throws IOException;
  }
}